I'm planning to create a fitness android application. Among other things, I want some integration with wearable devices. The device I have at hand now is an Honor Band 4 (Huawei). I haven't found any clear explanations of how to approach this problem and if it's even possible.
My first idea was periodically getting data from the HuaweiHealth application and importing it inside mine. But it seems that the HuaweiHealth app doesn't play nice with others, as I haven't seen a way of accessing this data.
Another thing I came across is the Android Sensors API: https://developers.google.com/fit/android/ble-sensors Could I use this to get data from my Honor Band? I assume that this would only get me raw data and I would have to handle all the logic to get the accurate pedometer, heart rate meter, etc.
Any input would be appreciated.
An app in a smartphone can collect data from a wearable. To do so, a native app running in the smartphone subscribes as a listener to events in wearable sensors. The wearable periodically notifies new data and the smartphone collects it.
In simple terms, it's a technology that you wear on your body parts or clothing, connected to the internet (through smartphones, computers, tablets, etc.), The data is exchanged from the wearable apps to the device/network in order to perform tasks, monitoring, and analysis of bodily functions, and enhance physical ...
Wearable devices capture, filter, and archive long-term physiological and activity data from the wearer. Due to their limited storage and computing capabilities, wearables may be unable to process data locally.
Proposed system that transmits data from a smartwatch to a touch device by modulating high-frequency mechanical waves. The signal is mechanically generated by the watch-mounted bone-conductor transducer.
The Wearable Data Layer API, which is part of Google Play services, provides an optional communication channel for apps. This API is only available on Wear OS watches and paired Android devices. For Wear OS watches paired with iOS phones, apps can query other cloud-based APIs if Internet connectivity is available.
When the user taps the handheld’s Talk to the Wearable button, the handheld will attempt to send a message to the Data Layer. The system only considers this message successfully sent once it’s queued for delivery to a specific device, which means at least one paired device needs to be available.
For example, a mobile Android app could advertise that it supports remote control of video playback. When the wearable version of that app is installed, it can use the CapabilityClient to check if the mobile version of the app is installed and supports that feature.
As a general rule, if your wearable app needs to perform a task that requires significant battery or processing power, or complex user interactions, then you should consider offloading this work to the corresponding handheld app.
I don't know much about Google Fit, so maybe it is easier to interact with the watch using that application. However, I will explain how I dealt with the Bluetooth communication in the past in a similar scenario
The device uses the protocol Bluetooth Low Energy
for data transmission. First of all, you should read a general description of how the protocol works. A good start would be the Bluetooth SIG website.
The most important thing you need to know is what's the software model presented in the protocol: each device exposes a Generic Attribute Profile (GATT)
. The way I see it, the GATT is just an API: it says what data the device "offers" and how you can consume it from a client. You should get familiar with the following terminology:
The Bluetooth SIG specifies a complete list of common services and characteristics, and how to interact with them. Again, all that information is in their website.
So, what you need to do before you can start writing code to interact with the watch is to find out which services and characteristics the device exposes. The ideal thing would be that the manual, that came with the watch when you bought it, said something about it... but that's unfortunately probably not the case.
Therefore, you have to figure it out by yourself. First thing you can do is to download an app that let you connect to a BLE Device and explore its GATT profile. I recommend LightBlue Explorer. Using it, you can connect to the watch and find out the characteristics and services that are exposed by the device. Then, you go and read the specification in the Bluetooth SIG website and you have everything you need to start writing code.
However, manufactures of BLE devices are not limited to the services and characteristics defined by the Bluetooth SIG. They can create and implement their own. In the image below I am connected to a digital scale. As you can see, it has many "standard" services (User Index, Body Composition, Battery service, etc.) but surrounded by a red square you can see a service with five characteristics that have no name.
Since that service wasn't defined by the Bluetooth SIG, you need to do some reverse engineering (which can be very difficult and frustrating) to figure out what those characteristics mean and how to consume them.
What I did, was to download the device's official app, I enabled the Bluetooth Snoop HCI and started to interact with the device in as many different ways as possible. After that, I opened the Bluetooth Log with Wireshark and analysed the Bluetooth packets transmissions to try to deduct how to work with those device specific characteristics.
Finally, once you know how the Bluetooth GATT server works in the device, you are ready to write your own application to interact with it. I highly suggest that you use a library for the communication implementation, otherwise you will struggle a lot. The best one I have seen and used is RxAndroidBle (they have other versions of the library for different platforms).
It is a long process, and what I have a written here is only some general information so you have a point to start from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With