Help with GATT Server Table Demo - Finding gatts_if

jonking
Posts: 8
Joined: Wed Dec 04, 2019 1:36 pm

Help with GATT Server Table Demo - Finding gatts_if

Postby jonking » Wed Dec 04, 2019 1:43 pm

Hello all,

I have recently started learning BLE for esp32. I am looking through the GATT Server Table Demo and I have slightly modified it such that I can adjust the value characteristic. I have successfully done this and confirmed that the value of the service has changed using a BLE interrogator. However I want to be able to notify the phone if the value changes. I am changing the attribute by calling esp_ble_gatts_set_attr_value().

I know to send a notification I need to use esp_ble_gatts_send_indicate() but I do not know how to find esp_gatt_if_t gatts_if and uint16_t conn_id to do so. They are used in the event handler but I do not understand how to get them in main.

Here is the code I have added to the main loop to change characteristics:

Code: Select all

    while (true){
        ets_delay_us(100000);
        ret = esp_ble_gatts_set_attr_value(heart_rate_handle_table[IDX_CHAR_VAL_A],sizeof(data),data);
        if (ret){
            ESP_LOGE(GATTS_TABLE_TAG, "set attr value failed, error code = %x", ret);
            return;
        }

        ret = esp_ble_gatts_send_indicate(/*What do to here*/);
        if (ret){
            ESP_LOGE(GATTS_TABLE_TAG, "set attr value failed, error code = %x", ret);
            return;
        }

    
    }
Thanks to anyone who can help! Please see the ESP_IDF example GATTS_SERVER_TABLE_DEMO

Who is online

Users browsing this forum: Bing [Bot] and 50 guests