how to TRIGGER BLE notification to client using Bluedroid stack

stock86c
Posts: 18
Joined: Mon Aug 19, 2019 10:15 am

how to TRIGGER BLE notification to client using Bluedroid stack

Postby stock86c » Mon Aug 26, 2019 3:51 am

Hi guys,

I am looking for a way to automatically update the response of the gatt response that is based off the gatt-server-service-table. Specifically, i would like to update this example to be able to function like the NimBLE example "blehr" where the heart rate data is automatically sent from the esp32 to the phone App in intervals, say every second. For the blehr example, in the main loop there is a timer function

/* name, period/time, auto reload, timer ID, callback */
blehr_tx_timer = xTimerCreate("blehr_tx_timer", pdMS_TO_TICKS(1000), pdTRUE, (void *)0, blehr_tx_hrate);"
that calls the blehr_tx_hrate function every second and updates the heart beat rate to the phone App.

As I have no idea at all how to update the gatt response and update data fields for the Bluedroid stack, any clues would be appreciated, thanks.
Last edited by stock86c on Mon Aug 26, 2019 7:54 am, edited 1 time in total.

stock86c
Posts: 18
Joined: Mon Aug 19, 2019 10:15 am

Re: Update the gatt response in intervals for gatt-server-service-table

Postby stock86c » Mon Aug 26, 2019 7:45 am

digging into this question, i realize that this has to do with the "notify" service. For the NimbLE stack, there seems to be "ble_gattc_notify_custom" and ble_gattc_notify" functions that are used to trigger the characteristic value update and send the updated values to the client; specifically for the blehr example, the following are the handles used to do just that
om = ble_hs_mbuf_from_flat(hrm, sizeof(hrm));
rc = ble_gattc_notify_custom(conn_handle, hrs_hrm_handle, om);

However, for the Bluedroid stack, the gatt-server-service-table example does not seem to have such API functions. The only thing related to notify for the gatt api using bluedroid is
"esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,uint16_t value_len, uint8_t *value, bool need_confirm); " as can be seen here.
https://github.com/espressif/esp-idf/bl ... atts_api.h

So does that mean Bluedroid stack has no way to send notifications to the client ?

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

Re: how to TRIGGER BLE notification to client using Bluedroid stack

Postby chegewara » Mon Aug 26, 2019 12:15 pm

Code: Select all

esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,uint16_t value_len, uint8_t *value, bool need_confirm);

need_confirm = true; => indication

need_confirm = false; => notification

stock86c
Posts: 18
Joined: Mon Aug 19, 2019 10:15 am

Re: how to TRIGGER BLE notification to client using Bluedroid stack

Postby stock86c » Tue Aug 27, 2019 8:09 am

thx chegawara. I think i didnt explain the situation correctly. But in the mean time, i found the following post
viewtopic.php?f=13&t=11228&p=45738&hili ... ify#p45738
which is the exact thing that i was looking for, where he wanted the notification to be sent out every second once created and notifications ON , and halted when OFF. I'll look into his solution, thx.

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

Re: Update the gatt response in intervals for gatt-server-service-table

Postby chegewara » Tue Aug 27, 2019 8:37 pm

stock86c wrote:
Mon Aug 26, 2019 7:45 am
However, for the Bluedroid stack, the gatt-server-service-table example does not seem to have such API functions. The only thing related to notify for the gatt api using bluedroid is
"esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,uint16_t value_len, uint8_t *value, bool need_confirm); " as can be seen here.
https://github.com/espressif/esp-idf/bl ... atts_api.h

So does that mean Bluedroid stack has no way to send notifications to the client ?
I was referring to this. So, this can be used to send indications and notifications depend on last parameter:

Code: Select all

esp_ble_gatts_send_indicate

Who is online

Users browsing this forum: No registered users and 192 guests