What I don't understand is esp_ble_gatt_get_characteristic is called after search is commplete(ESP_GATTC_SEARCH_CMPL_EVT) thats fine. But onces its called for Charateristics Search in that event again its called in ESP_GATTC_GET_CHAR_EVENT event I dont understand why again? when I comment that line only one characteristic is detected. I don't understand this function.
Is there any where all explained about how and when to call this functions or sequences?
Code: Select all
case ESP_GATTC_SEARCH_CMPL_EVT:
conn_id = p_data->search_cmpl.conn_id;
ESP_LOGI(GATTC_TAG, "SEARCH_CMPL: conn_id = %x, status %d", conn_id, p_data->search_cmpl.status);
esp_ble_gattc_get_characteristic(gattc_if, conn_id, &alert_service_id, NULL);
break;
case ESP_GATTC_GET_CHAR_EVT:
if (p_data->get_char.status != ESP_GATT_OK) {
break;
}
ESP_LOGI(GATTC_TAG, "GET CHAR: conn_id = %x, status %d", p_data->get_char.conn_id, p_data->get_char.status);
ESP_LOGI(GATTC_TAG, "GET CHAR: srvc_id = %04x, char_id = %04x", p_data->get_char.srvc_id.id.uuid.uuid.uuid16, p_data->get_char.char_id.uuid.uuid.uuid16);
ESP_LOGI(GATTC_TAG, "Char UUID128: %x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x",p_data->get_char.char_id.uuid.uuid.uuid128[0],
p_data->get_char.char_id.uuid.uuid.uuid128[1], p_data->get_char.char_id.uuid.uuid.uuid128[2], p_data->get_char.char_id.uuid.uuid.uuid128[3],
p_data->get_char.char_id.uuid.uuid.uuid128[4], p_data->get_char.char_id.uuid.uuid.uuid128[5], p_data->get_char.char_id.uuid.uuid.uuid128[6],
p_data->get_char.char_id.uuid.uuid.uuid128[7], p_data->get_char.char_id.uuid.uuid.uuid128[8], p_data->get_char.char_id.uuid.uuid.uuid128[9],
p_data->get_char.char_id.uuid.uuid.uuid128[10], p_data->get_char.char_id.uuid.uuid.uuid128[11], p_data->get_char.char_id.uuid.uuid.uuid128[12],
p_data->get_char.char_id.uuid.uuid.uuid128[13], p_data->get_char.char_id.uuid.uuid.uuid128[14], p_data->get_char.char_id.uuid.uuid.uuid128[15]);
if (p_data->get_char.char_id.uuid.uuid.uuid16 ==0x941D){// 0x2a46) {
ESP_LOGI(GATTC_TAG, "register notify");
esp_ble_gattc_register_for_notify(gattc_if, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, &alert_service_id, &p_data->get_char.char_id);
}
esp_ble_gattc_get_characteristic(gattc_if, conn_id, &alert_service_id, &p_data->get_char.char_id);
break;