I have made some changes and improvements - and also I organized directory structure and added some comments.
- upgraded DB support to sqlite3
- rate of looking for a device decreases after specified time the device hasn't been seen
- optimized for less number of disk writes
- addes some comments ;-)
- more minor improvements in all parts
Starting from this version, temporary files are created in /tmp/btproximity, but option for your own handler scripts remains. You only need to manually create directory with the same name as BT device located in the directory which contains blueproximity.sh script and put script named run-in and/or run-out into.
Script gets following arguments when it is run:
device_name mac_address minutes_away
minutes_away has meaning only for IN event.
I've learned how to handle sqlite3 via DSO class in PHP, so there is no need to use old sqlite2. Lines
Code:
extension=pdo.so
extension=pdo_sqlite.so
must be present in your /opt/etc/php.ini file
initializing database:
Code:
sqlite3 btlog.db < db.sql
or migrating database from sqlite v2 to sqlite v3:
Code:
sqlite btlog.db ".dump" > btlog_dump
ipkg remove sqlite2 ; ipkg install sqlite
rm btlog.db
sqlite3 btlog.db < btlog_dump
I've added optional decreasing of search rate because it takes about 20 second to look for device that's not present (at least in my case) and time to look for all devices is limited by length of cycle. So it saves some time on devicess that haven't been present for longer time (default setting is 24 hours).
There is still no web management of devices, maybe in next version or up to someone else ;-)
PS etc/init.d/S99local contains a small mistake - a quote char at line 9 is needed to remove. Newest version below is OK.