gatt server service table example
gatt server service table example
Anyone know what is the difference betweengatt server service table example and another "gatt server" example?
My problem is I can send use "esp_ble_gatts_send_response" & "esp_ble_gatts_send_indication" in the gatt server example,
but I can't use esp_ble_gatts_send_response in the service table example, it will show "E (14681) BT: Sending response failed
"
My problem is I can send use "esp_ble_gatts_send_response" & "esp_ble_gatts_send_indication" in the gatt server example,
but I can't use esp_ble_gatts_send_response in the service table example, it will show "E (14681) BT: Sending response failed
"
Re: gatt server service table example
Below is the only code I added on top of the service table example code, it shows the error when I read the sensor location.
E (104789) BT: GATTS_SendRsp conn_id: 4 waiting for op_code = 00
E (104789) BT: Sending response failed
E (104789) BT: GATTS_SendRsp conn_id: 4 waiting for op_code = 00
E (104789) BT: Sending response failed
Code: Select all
case ESP_GATTS_READ_EVT:
memset(&rsp, 0, sizeof(esp_gatt_rsp_t));
rsp.attr_value.handle = heart_rate_handle_table[HRS_IDX_BOBY_SENSOR_LOC_VAL];
rsp.attr_value.len = sizeof(body_sensor_loc_val);
rsp.attr_value.value[0] = 0x01;
esp_ble_gatts_send_response(gatts_if, param->read.conn_id, param->read.trans_id,
ESP_GATT_OK, &rsp);
Re: gatt server service table example
@dhs2017
Did you find the solution? I am also facing the same issue with the same example. Any help will be appreciated.
Did you find the solution? I am also facing the same issue with the same example. Any help will be appreciated.
Re: gatt server service table example
No, I give up, i turn out used another gatt server example and completed my task.
Re: gatt server service table example
At a guess ... I think the distinction is as follows ...
When we are being a GATT server, we receive requests from data from clients. The data our server manages is contained in a unit called a "characteristic". In the ESP-IDF APIs, we have the ability to receive events and process those events when they arrive. For example, one event is a request to return a value for a characteristic read. In one design/implementation, it is your responsibility to receive the event and handle it in any way you see fit ... which might include describing the response to send back to the client.
In another design, the ESP-IDF provides that handling code for you in the form of a mapping table where the value of the characteristic is stored in the table and when a client request arrives, the ESP-IDF responds automatically to the caller with the current value in the table. I think both of these APIs are available to you and which one you decide to choose is a matter of taste and style.
For me, I like working in C++ and use a wrapper set of classes built around the ESP-IDF to try and hide the majority of the lower level complexities.
When we are being a GATT server, we receive requests from data from clients. The data our server manages is contained in a unit called a "characteristic". In the ESP-IDF APIs, we have the ability to receive events and process those events when they arrive. For example, one event is a request to return a value for a characteristic read. In one design/implementation, it is your responsibility to receive the event and handle it in any way you see fit ... which might include describing the response to send back to the client.
In another design, the ESP-IDF provides that handling code for you in the form of a mapping table where the value of the characteristic is stored in the table and when a client request arrives, the ESP-IDF responds automatically to the caller with the current value in the table. I think both of these APIs are available to you and which one you decide to choose is a matter of taste and style.
For me, I like working in C++ and use a wrapper set of classes built around the ESP-IDF to try and hide the majority of the lower level complexities.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: gatt server service table example
PROBLEM_1dhs2017 wrote:Below is the only code I added on top of the service table example code, it shows the error when I read the sensor location.
E (104789) BT: GATTS_SendRsp conn_id: 4 waiting for op_code = 00
E (104789) BT: Sending response failed
Code: Select all
case ESP_GATTS_READ_EVT: memset(&rsp, 0, sizeof(esp_gatt_rsp_t)); rsp.attr_value.handle = heart_rate_handle_table[HRS_IDX_BOBY_SENSOR_LOC_VAL]; rsp.attr_value.len = sizeof(body_sensor_loc_val); rsp.attr_value.value[0] = 0x01; esp_ble_gatts_send_response(gatts_if, param->read.conn_id, param->read.trans_id, ESP_GATT_OK, &rsp);
Check the response type of the characteristic in your attribute table if it is response by app or auto reaponse:
Code: Select all
heart_rate_db[HRS_IDX_BODY_SENSOR_LOC_VAL].attr_control.auto_rsp = ESP_GATT_AUTO_RSP;
Code: Select all
heart_rate_db[HRS_IDX_BODY_SENSOR_LOC_VAL].attr_control.auto_rsp = ESP_GATT_RSP_BY_APP;
PROBLEM_2
Also why are you hardcoding the handle? It is not necessary that this is the handle being read because for any gatt server read event it will read this handle irregardless if the user wants to read another characteristic or descriptor.
Try:
Code: Select all
rsp.attr_value.handle = param->read.handle;
PROBLEM_3
Code: Select all
rsp.attr_value.len = sizeof(body_sensor_loc_val);
Correction:
Code: Select all
rsp.attr_value.len = sizeof(HEART_RATE_DB[body_sensor_loc_val]);
-
- Posts: 1
- Joined: Sun Dec 24, 2017 8:14 am
Re: gatt server service table example
Thanks for the hints !
Also, when in mode ESP_GATT_AUTO_RSP, you can use esp_ble_gatts_set_attr_value to change the characteristic values you declared at init.
You can also use esp_ble_gatts_send_indicate with the conn_id handle you get on ESP_GATTS_CONNECT_EVT until a ESP_GATTS_DISCONNECT_EVT, you will then have realtime update on your connected device.
Also, when in mode ESP_GATT_AUTO_RSP, you can use esp_ble_gatts_set_attr_value to change the characteristic values you declared at init.
You can also use esp_ble_gatts_send_indicate with the conn_id handle you get on ESP_GATTS_CONNECT_EVT until a ESP_GATTS_DISCONNECT_EVT, you will then have realtime update on your connected device.
Who is online
Users browsing this forum: No registered users and 88 guests