One of the functions of the Vortex Manipulator I always wanted to add was a way to display notifications from my phone. This is pretty standard stuff on commercial wrist devices so shouldn't be too hard. Well, it mostly wasn't hard, but I did have to pick up some skills in programming on Android, especially the bluetooth API.
There, in fact two Bluetooth APIs. The ordinary one and the Bluetooth Low Energy (BLE) one. BLE was the obvious choice to save battery life. I ended up doing both because I already had an ordinary Bluesmirf board which does non-BLE and I wanted to get started before my BLE board arrived, but I removed the code for the Bluesmirf and kept only the BLE code.
The board I used is am AT-09, sometimes called an HM10 and it has a CC2540 chip on it. It provides a serial interface, so the programming for that is pretty simple. I already had most of the programming done by tieing it to the serial monitor and just typing at it. But there was a small surprise.
When the actual messages from the BLE board came in I found they could not be more then about 20 characters, so I had to add a little logic to acculumate the messages into a buffer until a terminator character arrives. The code for this is in Vortexmanipulator.cpp in the class SerialCheck. This is derived from the abstract Action class, and therefore uses the Intervals mechanism, so the main loop of the Vortex Manipulator checks this for anything to do at regular intervals (along with all the other things like touch, gesture and heart rate). Once a complete message is detected it gets passed to the Notification app.
The Notification app is on the menu. Its icon looks like an exclamation. When Notification receives a message it reverses the icon image (white background rather than black) and beeps. Pressing on the icon gives the list of messages, stamped with a time.
Putting it together was just a matter of wiring the TX/RX pair from the Teensy to the TX/RS pair on the AT-09 and giving it a power supply. Remember the RX (green) on the Teensy connects to the TX on the AT-09 and vice versa. This is how it looks before I tidied it up.
Notice I used the VCC and GND connections for the HRM (green board) rather than running them all the way from the main board. Then I put it together. The AT-09 slips inside the 3D printed assembly and I replaced the cover on the teensy. I also taped down the tangle of exposed wires. This is the underside, of course, so they don't show when I wear it, but I don't want to have them working loose.
When a message arrives, as I said above, the app icon changes:
And opening the app displays the mVMBLE.essage:
(It was supposed to read 'test message' but... spell corrector?)
Now that the VM can receive Bluetooth messages I needed something that would send messages to it. For this I built an Android App. Source code is on github.
Follow the instructions there for building and running the app on your phone.
Although the VM includes a way to set the time I found it better to use the time from the phone to sync the VM time. When a Bluetooth conection is made the app sends the current time to the VM and it updates. Naturally the phone has the advantage of being able to sync its time with the internet so it is more accurate than the VM clock which will drift a little off accuracy if left unsync'd for long.