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.
how to TRIGGER BLE notification to client using Bluedroid stack
how to TRIGGER BLE notification to client using Bluedroid stack
Last edited by stock86c on Mon Aug 26, 2019 7:54 am, edited 1 time in total.
Re: Update the gatt response in intervals for gatt-server-service-table
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 ?
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 ?
Re: how to TRIGGER BLE notification to client using Bluedroid stack
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
Re: how to TRIGGER BLE notification to client using Bluedroid stack
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.
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.
Re: Update the gatt response in intervals for gatt-server-service-table
I was referring to this. So, this can be used to send indications and notifications depend on last parameter:stock86c wrote: ↑Mon Aug 26, 2019 7:45 amHowever, 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 ?
Code: Select all
esp_ble_gatts_send_indicate
Who is online
Users browsing this forum: Majestic-12 [Bot] and 131 guests