esp_ble_gatts_send_indicate causes attr value not to change, no notification sent

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

esp_ble_gatts_send_indicate causes attr value not to change, no notification sent

Postby jonking » Wed Dec 04, 2019 4:38 pm

Hello,

I am currently trying to change the characteristic value of a service then notify a BLE interrogator (BLE Scanner) when there is a change to the attribute.

I am adjusting the ESP_IDF example GATTS Server Service Table example with the following code:

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(heart_rate_profile_tab[IDX_CHAR_VAL_A].gatts_if, heart_rate_profile_tab[IDX_CHAR_VAL_A].conn_id, heart_rate_handle_table[IDX_CHAR_VAL_A], sizeof(data),data, false);
        if (ret){
            ESP_LOGE(GATTS_TABLE_TAG, "Send indication, error code = %x", ret);
            return;
        }

        data[0] = data[0] + 1;
    
    }
If I do a read event prompted from the phone and just use the set attribute function that works. When I add the send indicate function not only does the value of data not change when I do a read event from the phone but I am never prompted about the change on the app.

rosenrot
Posts: 25
Joined: Wed Jan 01, 2020 9:28 pm

Re: esp_ble_gatts_send_indicate causes attr value not to change, no notification sent

Postby rosenrot » Sun Jan 19, 2020 4:46 pm

For me this doesn't work. Do I get something wrong?
heart_rate_profile_tab has only one element because the HEART_PROFILE_APP_IDX is 1. In your example you give it a highler value from the attribute table.

Code: Select all

if (event == ESP_GATTS_REG_EVT) {
        if (param->reg.status == ESP_GATT_OK) {
            heart_rate_profile_tab[HEART_PROFILE_APP_IDX].gatts_if = gatts_if;
        } else {
            ESP_LOGI(GATTS_TABLE_TAG, "Reg app failed, app_id %04x, status %d\n",
                    param->reg.app_id,
                    param->reg.status);
            return;
        }
    }

Who is online

Users browsing this forum: Google [Bot] and 294 guests