Send BLE notifications Automatically with BLE create table method

Matthew Evers
Posts: 1
Joined: Wed May 22, 2019 5:18 pm

Send BLE notifications Automatically with BLE create table method

Postby Matthew Evers » Wed May 22, 2019 5:30 pm

Hello,

I am using the

Code: Select all

esp_ble_gatts_create_attr_tab
method of create a Bluetooth service.

I have two characteristics, and one of those characteristics has the notifications descriptor (0x2902) snippet below.

Code: Select all

static uint16_t sCharValueNotifications = 0b01;
...
    // Client Characteristic Configuration Descriptor - Enable notifications
    [BLE_HANDLE_CHAR_DESCR_NOTIFICATIONS] = {
        {ESP_GATT_AUTO_RSP}, 
        {
            ESP_UUID_LEN_16,
            (uint8_t *)&sUUIDReservedClientConfig, 
            ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
            sizeof(sCharValueNotifications), 
            sizeof(sCharValueNotifications), 
            (uint8_t*)&sCharValueNotifications
        }
    }
How do I notify subscribers of a characteristic that the characteristic has changed (i.e. has been written to)? Is there an API call, e.g. esp_ble_gatts_set_attr_value(), that will automatically send the notification to the connected devices?
I have seen examples using

Code: Select all

esp_ble_gatts_send_indicate
, but that would mean that I have to handle sending the notification in my event handler? Wouldn't that defeat the purpose of ESP_GATT_AUTO_RSP?

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

Re: Send BLE notifications Automatically with BLE create table method

Postby chegewara » Mon May 27, 2019 1:12 pm

`ESP_GATT_AUTO_RSP` its different purpose. Its up to you if you want to send or not notifications or indications.

`ESP_GATT_AUTO_RSP` is to respond on requests from peer device, like read or write request to inform peer device that request has been accepted or rejected.

Who is online

Users browsing this forum: No registered users and 145 guests