I was wondering if there anyone willing to guide me a bit. I am trying to read the temperature of a Bluetooth thermometer using gatttool, but I don't know how to work with the indicate property.
I am able to connect to the device, get the device name, etc., but it has proven to be more challenging to get the actual temperature data.
Does any one have an idea? Also if you have more questions for me, let me know.
Assuming that your device uses the adopted thermometer profile, then you want to enable indications on the temperature measurement characteristic. To do this, there are several steps:-
Find the handle of the temperature characteristic using:-
gatttool -b 00:11:22:33:44:55 --characteristics
Replace 00:11:22:33:44:55 with the Bluetooth address of your device. You basically want to find the uuid that contains 2a1c and note down its corresponding 'char value handle'.
Find the descriptors at that handle using
gatttool -b 00:11:22:33:44:55 char-desc --handle=0xXX
Where XX is the char value handle that you noted down earlier. You should be able to see a couple of characteristic descriptors at that handle. Note down the char handle with uuid 2902.
Enable indications by writing '0200' at that handle using
gatttool -b 00:11:22:33:44:55 --sec-level=high --char-write --handle=0xYYYY --value=0200
Where 0xYYYY is the handle of the CCCD descriptor that you noted in step 2. Once this happens, you should start getting indication data, which you can decipher using the temperature data structure found here.
If your device does not use the adopted thermometer profile, then you need to repeat the above three steps, but at step 1, instead of looking for a characteristic with uuid 2a1c, look for a characteristic which has 'char properties = 0x20' as this means that the characteristic can be indicatable.
You can find more information about using the BlueZ commands at the following links:-
- How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
- Bluetooth Low Energy: listening for notifications/indications in linux
- Using Bluetooth low energy in linux command line
I hope this helps.