Hi,
Starting from bluetooth/gatt_server example I have make some modifications to achieve a 'propietary' service that is composed of a characteristic and its client characteristic configuration descriptor (cccd).
From the client side I am able to read/write values into CCCD to enable notifications or indications correctly.
Using "esp_ble_gatts_send_indicate" function I can send notifications or indications depending on the "bool need_confirm" parameter value. Regardless of cccd value I can send notifications or indications. There is no control between cccd value and the ability to use or send notifications or indications.
1 . -This control must be done at application level? I am not 100% sure if CCCD are optional or not so that is one of my doubts. The stack has to control if a client is subscribed to a characteristic or is the app the one who has to do this kind of work?
I have also tried to set the characteristic with and without the notify and/or indicate properties set. And If I set the characteristic without any of those properties (ESP_GATT_CHAR_PROP_BIT_NOTIFY | ESP_GATT_CHAR_PROP_BIT_INDICATE props are not set) but I try to send a notification or indication with "esp_ble_gatts_send_indicate" there is no problem and the data arrives at the client. It has no sense that if that characteristic does not have notify or indicate properties set the "esp_ble_gatts_send_indicate" function still sends data, it must return a state or status error.
2.- This functionality is not implemented, is a bug or the application must control also this situation?
Can you clarify these doubts about notification/indication? Thanks in advance.
BLE notification & Indications
Re: BLE notification & Indications
we all have or trying the Notification or Indication API from esp32 in our main() but we able to see the data on the client side.. so i got the solution for that.. i did it for notify..
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if,gl_profile_tab[PROFILE_A_APP_ID].conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(notify_data), notify_data, false);
if add the ablove API directly in your main code in a while loop it will not work..
the idea of notify is to send data when there is some change is the values...
the the change in values can be done by
esp_ble_gatts_set_attr_value(gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(send_data), send_data);
even if you are loading the same values the stack recognizes it change in values and after that the indicate api will work..
try to add the following code at the end of your main();
while(1)
{
esp_ble_gatts_set_attr_value(gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(send_data), send_data);
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if,gl_profile_tab[PROFILE_A_APP_ID].conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,
sizeof(send_data), send_data, false);
}
false is for notify and true is for Indicate.
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if,gl_profile_tab[PROFILE_A_APP_ID].conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(notify_data), notify_data, false);
if add the ablove API directly in your main code in a while loop it will not work..
the idea of notify is to send data when there is some change is the values...
the the change in values can be done by
esp_ble_gatts_set_attr_value(gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(send_data), send_data);
even if you are loading the same values the stack recognizes it change in values and after that the indicate api will work..
try to add the following code at the end of your main();
while(1)
{
esp_ble_gatts_set_attr_value(gl_profile_tab[PROFILE_A_APP_ID].char_handle,sizeof(send_data), send_data);
esp_ble_gatts_send_indicate(gl_profile_tab[PROFILE_A_APP_ID].gatts_if,gl_profile_tab[PROFILE_A_APP_ID].conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle,
sizeof(send_data), send_data, false);
}
false is for notify and true is for Indicate.
Who is online
Users browsing this forum: No registered users and 195 guests