Enabling BLE Notifications

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Enabling BLE Notifications

Postby mpulis » Wed Jun 30, 2021 2:06 pm

Hi!

Sorry about this question, but I'm not that familiar with the ESP32's BLE handling :? How do I setup a characteristic on a GATT server which will notify a connected client on the characteristic being updated? I'm calling esp_ble_gatts_send_indicate() with the parameter set to false, but this doesn't seem to be working with the app I'm testing with.

zamek42@gmail.com
Posts: 34
Joined: Sat Dec 02, 2017 7:27 pm

Re: Enabling BLE Notifications

Postby zamek42@gmail.com » Thu Jul 01, 2021 2:59 pm

Hi,

I used it for a heart rate sensor, esp ble gattc client example was good for me.
In nutshell (GATT parts):

1. on ESP_GATTC_CONNECT_EVT you need to call esp_ble_gattc_send_mtu_req()
2. on ESP_GATTC_CFG_MTU_EVT you need to call esp_ble_gattc_search_service()
3. on ESP_GATTC_SEARCH_RES_EVT you need to save start handle and end handle parameters
4. on ESP_GATTC_SEARCH_CMPL_EVT you need to call esp_ble_gattc_get_attr_count() and esp_ble_gattc_get_char_by_uuid() and esp_ble_gattc_register_for_notify()
5. on ESP_GATTC_REG_FOR_NOTIFY_EVT you need to call esp_ble_gattc_get_attr_count() and esp_ble_gattc_get_descr_by_char_handle() and esp_ble_gattc_write_char_descr()

6. on ESP_GATTC_NOTIFY_EVT you can get the characteristic value

bye,
Zamek

Who is online

Users browsing this forum: No registered users and 277 guests