H2 read Float BLE Characteristic

adesandr
Posts: 22
Joined: Sat May 05, 2018 10:51 am

H2 read Float BLE Characteristic

Postby adesandr » Wed Nov 07, 2018 7:05 pm

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.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: H2 read Float BLE Characteristic

Postby chegewara » Thu Nov 08, 2018 5:55 am

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

Weijian-Espressif
Posts: 29
Joined: Wed Aug 09, 2017 6:16 am

Re: H2 read Float BLE Characteristic

Postby Weijian-Espressif » Mon Nov 19, 2018 7:15 am

thanks for chegewara's help. please Please follow the chegewara to try.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: H2 read Float BLE Characteristic

Postby chegewara » Mon Nov 19, 2018 11:32 am

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.

Who is online

Users browsing this forum: snutw_, TeeVee and 124 guests