Page 1 of 1

H2 read Float BLE Characteristic

Posted: Wed Nov 07, 2018 7:05 pm
by adesandr
Hi,

My project is designed around two tasks :
1 - First task for global init and periodical sensors reading
2 - Second task is running a gatt_server with gatts_services_table initialization.

One of my sensor return a float value, and i want to map it on a BLE characteristic.

Reading the various examples given with the ESP-IDF and various topics on reading BLE characteristic, it seems that the characterics values are always managed as a string ? is it possible to set directly a float value using the esp_ble_gatts_set_attr_value ? In this case, what is the way to define the characteristic in the service table ?

I try to used the native Gatts-server API.

Thanks a lot for your responses.

Regards.

Re: H2 read Float BLE Characteristic

Posted: Thu Nov 08, 2018 5:55 am
by chegewara
Characteristic value is just a byte representation of any value, so all what you need is to find a way to store float value in byte array. I know you are using esp-idf, but here you have only example how it can be done:
https://github.com/nkolban/esp32-snippe ... #L715-L716


EDIT you can add descriptor 0x2904 to allow client to get information about value in characteristic:
https://www.bluetooth.com/specification ... format.xml

Re: H2 read Float BLE Characteristic

Posted: Mon Nov 19, 2018 7:15 am
by Weijian-Espressif
thanks for chegewara's help. please Please follow the chegewara to try.

Re: H2 read Float BLE Characteristic

Posted: Mon Nov 19, 2018 11:32 am
by chegewara
Weijian-Espressif wrote:
Mon Nov 19, 2018 7:15 am
thanks for chegewara's help. please Please follow the chegewara to try.
Congrats on your first comment on forum.