ble_spp_server read event error

tatsutaigu
Posts: 2
Joined: Tue Jan 28, 2020 9:06 am

ble_spp_server read event error

Postby tatsutaigu » Tue Jan 28, 2020 9:23 am

Hi,

I would like to modify below sample source.
https://github.com/espressif/esp-idf/tr ... spp_server

I would like to read data.
So, I add code as below.

Code: Select all

static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
{
...
    	case ESP_GATTS_READ_EVT:
            ESP_LOGI(GATTS_TABLE_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle);
            res = find_char_and_desr_index(p_data->read.handle);
            if(res == SPP_IDX_SPP_STATUS_VAL){
                //TODO:client read the status characteristic
                esp_gatt_rsp_t rsp;
                memset(&rsp, 0, sizeof(esp_gatt_rsp_t));
                rsp.attr_value.handle = param->read.handle;
        
                rsp.attr_value.len = 4;
                rsp.attr_value.value[0] = 0xde;
                rsp.attr_value.value[1] = 0xed;
                rsp.attr_value.value[2] = 0xbe;
                rsp.attr_value.value[3] = 0xef;
        		esp_ble_gatts_send_response(spp_gatts_if, param->read.conn_id, param->read.trans_id, ESP_GATT_OK, &rsp);
            }
            break;
However, I got error as below.

I (32350) GATTS_SPP_DEMO: EVT 1, gatts if 3

I (32350) GATTS_SPP_DEMO: event = 1

I (32350) GATTS_SPP_DEMO: GATT_READ_EVT, conn_id 0, trans_id 6, handle 49

E (32360) BT_GATT: GATTS_SendRsp conn_id: 3 waiting for op_code = 00

E (32360) BT_APPL: Sending response failed

I (32370) GATTS_SPP_DEMO: EVT 21, gatts if 3

I (32370) GATTS_SPP_DEMO: event = 15
How do I modify it for read event?

Who is online

Users browsing this forum: No registered users and 119 guests