December 18, 2009 Jeffery MacEachern This is an initial demo of a scrolling message alert for the Bluetooth-enabled Bracelet available from DealExtreme[0] and other vendors. Please note that this does *not* conform to the Bluetooth HFP spec, does not have the endorsement or knowledge of anyone remotely connected to the Bluetooth standards bodies, and is actually a complete hack. There is absolutely no guarantee with anything provided here; it is intended to work with the particular product mentioned, but it might not, and it probably won't work with many other devices, if any at all. If doing anything with this information or code causes your house to burn down or your little brother to turn into a werewolf, don't blame me. You have been warned. Now, to the point: The Story: I saw this nice little device at Hack a Day[1], when they issued a challenge to hack it back in February 2009, and quickly ordered it from DealExtreme. As suggested, it only displayed numerical callerID, as per the HFP spec. (The HFP spec also contains a diagram using the red sports car from the MS Office '97 clipart gallery, but that's irrelevant.) However, I had a hunch... Prudence would say that the HFP device should validate input, but the quality of the device didn't exactly scream prudence. Presuming it didn't validate input, assuming that it /was/ to spec, I figured it should pass the ASCII data more or less straight to the display. Most simple display controllers I've seen implement some subset or variant of ASCII, at least for the alphanumeric characters, so - all things going well - it should work. I tried to fiddle with it in the spring, but due to lack of knowledge about Bluetooth, and that pesky thing called school, the project got shelved. After exams this semester, I picked it up again and went at it. The result is provided here: a python script that will (once the Bracelet is paired) use BlueZ's DBus API to send arbitrary text to the display. Technical Details: - Not much to explain about the script - it should be straight-forward enough. This is just a demo, and could be tweaked some more. The one thing to note is the (seemingly odd) sequence of IncomingCall()/CancelCall() calls. Here's why. HFP is meant for a particular purpose - to ring/vibe and display a number that is constant for a given call. Calling IndicateCall() will display the string given indefinitely (as far as I can tell), vibrating all the while. Not only is this a waste of battery, but BlueZ does not appear to queue the method calls (understandably), so messages will be lost. Furthermore, the user has to push the accept/reject button to dismiss the message, which displays a "Call Rejected' message, or similar, which is out of place for this use-case. The workaround is to flash the message, and then cancel the call notification after a finite interval, before repeating the cycle. - The callerID display is managed by a telephony backend for BlueZ's audio component. Currently, the Maemo backend (and presumably the other phone backends do not support external access to the callerID functionality. The implication of this is that you must build BlueZ with the dummy backend rather than the one for your phone. The implication of *that* is that you will not be able to use an HFP device with your phone for any normal uses. This can be rectified, but given that this feature will not be put into mainline distribution, the work required to cleanly add that functionality does not seem practical for me. - For further reference, see the bluez-test-telephony script (may be called test-telephony) that should come in the BlueZ Test package for your distro. Instructions: 1) Rebuild BlueZ with the dummy backend. On Debian-based systems, this can be accomplished by editing the $srcdir/debian/rules file, or more generally, changing whatever your distro uses to run the configure script. 2) Pair the bracelet with the computer/phone you built BlueZ for, and connect the device manually. (bluez-test-telephony can do this easily for you, given the BT address.) 3) Run the python script with a single string as an argument. It will attempt to connect to the bracelet, and then display "New Alert", vibrating for a moment to get your attention, before flashing the message across the screen. Note that there is almost no error checking at the moment, so if something goes wrong, it will probably bail. Caveats: - I haven't worked out what's up with special characters yet. Slashes (back and forward) work, but other common symbols do not display. This is probably a sign that the controller maps them differently than ASCII, and will take some tests to find out more. I will update this file with more information when I find out. The Rest: I am not formally licensing this script, due to its trivial nature, however, I would very much appreciate it if you could attribute me if you use it, or a substantial portion of it, in your work, or if you reproduce or redistribute it. A note saying "Original code by Jeffery MacEachern" with a link to http://ffejery.creativemisconfiguration.com would be sufficient. If you have any serious comments or inquiries, please e-mail me. Please do not e-mail me asking things like "Please make this work on my phone", or other stupid questions. This is experimental, non-standard, and done primarily because it's made of Win. If it doesn't work, make it work, and e-mail me a diff. If it does work, let me know you like it - it'll make me feel I've done something useful. Happy Hacking! - The Ffejery