Open AbiotsLabs opened 1 year ago
Thanks for reporting.
@AbiotsLabs hi,Have your issues been resolved now?
Hi, It seems I had the same issue as OP. My mistake was that I assumed p_data->connect.remote_bda was defined when calling esp_ble_gattc_register_for_notify within ESP_GATTC_SEARCH_CMPL_EVT event.
Answers checklist.
General issue report
esp_ble_gattc_register_for_notify(gattc_if, p_data->connect.remote_bda, gl_profile_tab[PROFILE_A_APP_ID].char_handle);
if (param->reg_for_notify.status == ESP_GATT_OK) { ESP_LOGI(HUB_TAG, "Registered for notifications!"); esp_gattc_descr_elem_t *descr_elem_result = NULL; uint16_t count = 1; uint16_t notify_en = 2; esp_err_t ret_status; descr_elem_result = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count); if (!descr_elem_result) { ESP_LOGE(HUB_TAG, "malloc error, gattc no mem"); } else { ret_status = esp_ble_gattc_get_descr_by_char_handle( gattc_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id, gl_profile_tab[PROFILE_A_APP_ID].char_handle, notify_descr_uuid, descr_elem_result, &count); if (ret_status != ESP_GATT_OK) { ESP_LOGE(HUB_TAG, "esp_ble_gattc_get_descr_by_char_handle error"); } /* Every char has only one descriptor in our 'ESP_GATTS_DEMO' demo, so we used first 'descr_elem_result' */ if (count > 0 && descr_elem_result[0].uuid.len == ESP_UUID_LEN_16 && descr_elem_result[0].uuid.uuid.uuid16 == ESP_GATT_UUID_CHAR_CLIENT_CONFIG) { ESP_LOGD(HUB_TAG,"Enabling the notifications"); ret_status = esp_ble_gattc_write_char_descr(gattc_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id, descr_elem_result[0].handle, sizeof(notify_en), (uint8_t *)¬ify_en, ESP_GATT_WRITE_TYPE_RSP, ESP_GATT_AUTH_REQ_NONE); } if (ret_status != ESP_GATT_OK) { ESP_LOGE(HUB_TAG, "esp_ble_gattc_write_char_descr error"); } /* free descr_elem_result */ free(descr_elem_result);