My BLE GATT server shows a fault for (ESP_GATTS_CONF_EVT)

User avatar
Micrified
Posts: 11
Joined: Thu Aug 29, 2019 1:26 pm

My BLE GATT server shows a fault for (ESP_GATTS_CONF_EVT)

Postby Micrified » Fri Nov 22, 2019 3:25 pm

I'm currently trying to figure out why two different Android Applications using the Bluedroid API are not able to receive notifications from my BLE GATT server. I've based it on the given GATT Server example supplied in the ESP-IDF repository.

I notice the following when the Application connects to the GATT server:

Code: Select all

I (992) BLE-Driver: GATTS Event: ESP_GATTS_REG_EVT
I (992) BLE-Driver: GATTS Profile: Device name is: EKG-ESP32
I (992) BLE-Driver: GATTS Profile Event : Service ID: 255
I (1002) BLE-Driver: Ready
I (1012) BLE-Driver: GATTS Event: ESP_GATTS_CREATE_EVT
I (1012) MAIN: Startup Completed
I (1022) BLE-Driver: GAP advertising started
I (1022) BLE-Driver: GATTS Event: ESP_GATTS_START_EVT
I (1022) BLE-Driver: GATTS Profile: Service started
I (1032) BLE-Driver: GATTS Event: ESP_GATTS_ADD_CHAR_EVT
I (1032) BLE-Driver: GATTS Event: ESP_GATTS_ADD_CHAR_DESCR_EVT
I (13092) BLE-Driver: GATTS Event: ESP_GATTS_CONNECT_EVT
I (13092) BLE-Driver: GATTS Profile: Connect event
I (13582) BLE-Driver: Connection parameters updated
I (13862) BLE-Driver: Connection parameters updated
I (14012) BLE-Driver: GATTS Event: ESP_GATTS_WRITE_EVT
W (14012) BLE-Driver: GATTS Profile: WRITE_EVT to Characteristic Descriptor
I (14012) BLE-Driver: GATTS Profile: Notify Enabled!
W (14022) BLE-Driver: 01 00 
I (14042) BLE-Driver: GATTS Event: ESP_GATTS_RESPONSE_EVT
I (14042) BLE-Driver: GATTS Profile: ESP_GATTS_RESPONSE_EVT okay!
I (14052) BLE-Driver: GATTS Event: ESP_GATTS_CONF_EVT
E (14052) BLE-Driver: GATTS Profile: ESP_GATTS_CONF_EVT error (87)!
I (14062) BLE-Driver: e4 47 0f 40 04 a2 fb 3f a5 aa fb 3f b0 aa fb 3f 
I (14072) BLE-Driver: 09 00 00 00 	
Basically, in summary
  • 1. The characteristic descriptor is written to. The applications wants to receive Notifications. This is received OK (0x01, 0x00)
    2. A GATTS response event is fired, and the status is OK.
    3. A GATTS confirm event is fired, but there is an error!
The error code for the ESP_GATTS_CONF_EVT is 0x87, which corresponds to "ESP_GATT_ILLEGAL_PARAMETER" when I tried to look it up. I don't know what to make of the buffer value though, or why this event is occurring at all. Searching didn't reveal much at all. FYI, the code for the handler is:

Code: Select all

        // According to the documentation: "When receive confirm, the event comes" 
        case ESP_GATTS_CONF_EVT: {

        	if (param->conf.status == ESP_GATT_OK) {
        		ESP_LOGI("BLE-Driver", 
        			"GATTS Profile: ESP_GATTS_CONF_EVT okay!");
        	} else {
        		ESP_LOGE("BLE-Driver", 
        			"GATTS Profile: ESP_GATTS_CONF_EVT error (%X)!", 
        			param->conf.status);
        		esp_log_buffer_hex("BLE-Driver", param->conf.value, param->conf.len);
        	}
        }
        break;
      
Might this have something to do with why my Applications cannot receive notifications? Strangely enough, all subsequent events in this handler succeed. Even though when they do succeed, I still do not receive notifications.
Micrified (Netherlands)

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

Re: My BLE GATT server shows a fault for (ESP_GATTS_CONF_EVT)

Postby chegewara » Fri Nov 22, 2019 10:24 pm

Try to check all parameters when it fails, maybe conn_id or characteristic handle has wrong value:
https://docs.espressif.com/projects/esp ... evt_paramE

User avatar
Micrified
Posts: 11
Joined: Thu Aug 29, 2019 1:26 pm

Re: My BLE GATT server shows a fault for (ESP_GATTS_CONF_EVT)

Postby Micrified » Sun Nov 24, 2019 3:42 pm

@chegewara

I'm able to output everything. But I'm not sure what is supposed to be there, or how to fix it. The documentation only says it is a confirm event, and that 'value' of the param argument is valid on error. But it doesn't explain anything else. I have only an error code and there is nothing I can find to let me pinpoint the origin. How am I supposed to infer the problem from this without any context?

This is all I get on output in the event.

Code: Select all

E (97781) BLE-Driver: GATTS Profile: ESP_GATTS_CONF_EVT (conn_id = 0, handle = 0)
E (97791) BLE-Driver: GATTS Profile: ESP_GATTS_CONF_EVT error (87)!
I (97801) BLE-Driver: a9 ac fb 3f d8 ac fb 3f dc ac fb 3f a9 ac fb 3f 
I (97801) BLE-Driver: 10 ad fb 3f 
This is the entire BLE handler, adapted from the GATT Server example: https://raw.githubusercontent.com/Micri ... /src/ble.c
Micrified (Netherlands)

User avatar
Micrified
Posts: 11
Joined: Thu Aug 29, 2019 1:26 pm

Re: My BLE GATT server shows a fault for (ESP_GATTS_CONF_EVT)

Postby Micrified » Sun Nov 24, 2019 6:38 pm

I found and resolved the issue. I had forgotten to set something in the ESP_GATTS_ADD_CHAR_EVT event, and was writing to the characteristic descriptor instead of the characteristic with my indicate call.
Micrified (Netherlands)

Who is online

Users browsing this forum: Majestic-12 [Bot] and 143 guests