I am replicating an iOS exclusive app for a ble device to Android. The device has a notify and write custom gatt service.
I understood the meaning of some data, but I have no clue to the rest. From the part I understood, in order to get data, an app should subscribe the notification of the custom gatt service. Then writing a not so human readable "command" to control whether a certain data can be notified.
The app writes octets of sensorDataCodeName + action(read/write/subscribe/unsubscribe)
and the device responses octets of sensorDataCodeName + action + sensorDataValue(if applicable)
For example, if I write a0b0c0d0e0f0 00
, the device gives notifications of its accelerometer data a0b0c0d0e0f0 00 xx yy zz
. If I write a0b0c0d0e0f0 10
, I can unsubscribe the notification from this particular sensor.
I wonder if there is standard for this process. It may help me to decode the "code names" of the unknown data.
Unfortunately there isn't a standard for this interface. It seems that this is a custom GATT service/characteristic that is specific to the device you're working with. I've worked with API designs in the past and while the command/response that you describe is relatively common, there are always differences that are relevant to the device (in your case it's the sensor data codename).
Your best bet is to reach out to the manufacturer of the device for some documentation or explanation of the API interface. If this is not possible, then the reverse engineering that you are doing now is probably the next best thing.
If the manufacturer is somehow using non-custom GATT services characteristics, you can find some specification documents here:-
https://www.bluetooth.com/specifications/specs/
It might be tricky to find the right profile, but you can start by searching for the UUID of the service/characteristic you are using (e.g. UUID 0x180D is the UUID of the heart rate service).
There used to be a better service/characteristic documentation that is currently archieved here:-
Services: https://web.archive.org/web/20170711074819/https://www.bluetooth.com/specifications/gatt/services Characteristics: https://web.archive.org/web/20170711141105/https://www.bluetooth.com/specifications/gatt/characteristics