gatts_add_char_descr_evt_param missing info?

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

gatts_add_char_descr_evt_param missing info?

Postby vonnieda » Thu Jan 11, 2018 6:53 pm

Hi all,

I am struggling to find a way to correctly handle ESP_GATTS_ADD_CHAR_DESCR_EVT in a gatt server. The struct passed to this event is:

Code: Select all

    struct gatts_add_char_descr_evt_param {
        esp_gatt_status_t status;       /*!< Operation status */
        uint16_t attr_handle;           /*!< Descriptor attribute handle */
        uint16_t service_handle;        /*!< Service attribute handle */
        esp_bt_uuid_t char_uuid;        /*!< Characteristic uuid */
    } add_char_descr;                   /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
From the header, it says that char_uuid is "Characteristic uuid", but in reality it appears to be the descriptor uuid. My characteristics each include the same descriptor (ESP_GATT_UUID_CHAR_CLIENT_CONFIG) so I cannot figure out a way to unique identify which characteristic / descriptor pair the event is targeting.

It seems like the event parameter should also include the characteristic uuid, or the handle of the characteristic.

My code is proprietary, so I cannot post it, but in psuedocode the situation looks like this:

1. Call esp_ble_gatts_add_char with characteristic uuid 1111.
2. Receive ESP_GATTS_ADD_CHAR_EVT with characteristic uuid 1111.
3. Call esp_ble_gatts_add_char_descr with descriptor uuid ESP_GATT_UUID_CHAR_CLIENT_CONFIG (0x2902)
4. Call esp_ble_gatts_add_char with characteristic uuid 2222.
5. Receive ESP_GATTS_ADD_CHAR_EVT with characteristic uuid 2222.
6. Call esp_ble_gatts_add_char_descr with descriptor uuid ESP_GATT_UUID_CHAR_CLIENT_CONFIG (0x2902)
7. Receive ESP_GATTS_ADD_CHAR_DESCR_EVT with characteristic uuid ESP_GATT_UUID_CHAR_CLIENT_CONFIG (0x2902)
8. Receive ESP_GATTS_ADD_CHAR_DESCR_EVT with characteristic uuid ESP_GATT_UUID_CHAR_CLIENT_CONFIG (0x2902)

So, I register two characteristics and each one has one descriptor, which is ESP_GATT_UUID_CHAR_CLIENT_CONFIG. But when I get the ESP_GATTS_ADD_CHAR_DESCR_EVT event, so that I can store the handle, I have no way of knowing which characteristic the event is for.

Can someone tell me if I am missing something, or if this is a bug in the API?

Thanks,
Jason

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: gatts_add_char_descr_evt_param missing info?

Postby WiFive » Fri Jan 12, 2018 2:55 am

You should create one characteristic at a time and not make additional calls until you receive the events indicating the previous call has completed. Or just use the service table api.

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

Re: gatts_add_char_descr_evt_param missing info?

Postby chegewara » Fri Jan 12, 2018 3:28 am

Or you can wait when characteristic handle will be added to this structure
https://github.com/espressif/esp-idf/issues/1484

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: gatts_add_char_descr_evt_param missing info?

Postby vonnieda » Fri Jan 12, 2018 3:07 pm

Thank you @WiFive and @chegewara for your replies. They are both very helpful! I didn't realize I should add my descriptors one at a time. I'll make that change and I think it will suit me fine. I also appreciate the pointer to the service table API. I was not aware of this before, and it looks like it would handle a lot of my code for me.

Thanks,
Jason

Who is online

Users browsing this forum: No registered users and 109 guests