Experiments with a smart band using Bluetooth and Flutter
I have a Fastrack reflex 2.0 smart band, capable of connecting to my mobile via Bluetooth, track health and all what a smart band is supposed to do.
Now, the problem is that it is very inaccurate in terms of counting steps, it definitely counts in excess (IDK if this is just a problem with my item), and, the functions that the band can trigger in a smartphone are not of so much use to me, and are not customizable too. So I decided to tinker around with it.
Research
So, first I decided to look around for what are the parts, model numbers etc. I did come around a teardown video:
It was not very helpful to me though, because I was definitely not willing to break open the band just to throw it into trash. Then I started researching about Bluetooth in particular. Here is what I found:
- These devices work on BLE(Bluetooth Low Energy) technology, allowing them to keep Bluetooth service on all time while consuming minimal power.
- Each device has an address, something like:
XX:XX:XX:XX:XX:XX
, whereX
is a hexadecimal character. - When connected, the mobile device searches for the services available in the device, each service consists of a set of characteristics.
- These characteristics are responsible for reading and writing data to the device and are of three types:
read
,write
andnotify
.
About services and characteristics
Both of these are identified using hexadecimal strings of type: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
, called UUIDs.
Types of characteristics:
- Read: Allows the master device(mobile) to read data on demand.
- Write: Allows the master device to write data on the other(band in this case) device on demand.
- Notify: Allows the other device to send custom data(maybe a command) to the master device.
Some more research
About my band in particular. I found the exact UUIDs for the characteristic and its parent service which I wanted to tinker around with. In my case, I wanted to work with the notify
characteristic, in order to send some custom commands to my mobile device. All this was done using the “Light Blue” app.
Now one thing I found out was that you cannot change the command sent by the band, simply because it is pre-saved in the firmware of the band.
But there is a work around! The commands sent by the band are interpreted by the app, which knows what command does what, we can make our custom app that can interpret the command in a different way!
My band in particular can command the reflex app to open camera and click picture, and another one is find device, where it just starts ringing in full volume and blinks the flash light so that I can find the phone if it is lost.
These commands are sent using the notify characteristics, and are HEX arrays (at least Light Blue recognizes them like that).
Monitoring the band using Light Blue and sending the command, I could record which command meant what.
Implementation
For implementation, you can go for a variety of ways, I chose flutter because I know how to work with that.
Steps:
- Find the device
- Connect to it
- Discover Services
- Go to the service that we researched about earlier
- Get characteristics of that service
- Go to the particular selected characteristic
- In my case, since it is notify, I will work with notify and will monitor the input coming from the band
- Trigger whatever I want to do when I receive a particular command!
Thanks for reading!