on oct 24th, 2005
tagged bluetooth, mac, nerd, razr
and
never commented on
share this page
a while back i was trying to automate the bluetooth file exchange application that comes with mac os, which was not very successful.
i've since given up on that and have begun writing my own bluetooth application which is command-line based. after battling with apple's bluetooth api for a few days, i finally have an application that can find a given bluetooth device, look up its name, connect to it, and establish an obex session. i don't have the directory browsing done yet, but it should hopefully be done soon.
while writing this app (named "blueutil" since it will eventually be a general purpose command-line bluetooth utility) i played around with building a proximity sensor between my razr and my powerbook. establishing a connection and trying to keep it open forever while waiting for a disconnect event does not work very well. so instead, i switched to a polling method which tries to connect to the device, quickly disconnects, and then sleeps for a while.
the result of this is a separate utility i've named blueping. you can give it commands to execute when the device becomes reachable and/or stops being reachable. the easiest example i can think of would be to monitor my phone and when i walk away from my desk with my phone in my pocket, launch the screen saver and lock the machine:
$ blueping -d 00-14-9a-d8-10-18 -x \ "/System/Library/Frameworks/ScreenSaver.framework/Resources/\ ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine"
another example i thought of was to watch for the device becoming reachable (the "-e" option) and launch a helper script that reads the log of isync (~/Library/Logs/Sync/iSync.log), finds the last date that isync ran, compares it to the current date, and if it's been over, say, a few days, it will automatically launch isync and start the sync process.
i don't have the log comparison part done yet (parsing/comparing dates in perl is always a pain in the ass), but to launch isync every time the device becomes reachable:
$ blueping -d 00-14-9a-d8-10-18 -e "osascript -e 'tell Application "'"iSync"'" to synchronize'"
of course, once blueutil has its obex functionality, i will be using blueping to automatically pull down pictures from my razr whenever it becomes reachable. i am giddy at the idea of just standing near (~20 feet?) my powerbook with my phone in my pocket and have my powerbook automatically pull pictures down, add them to cvs, delete them from the phone, and have the pictures show up on my site without having to do anything at all (not even log into the machine).
leave the first comment or contact me