Can't get esp_ble_gattc_read_char to trigger ESP_GATTC_READ_CHAR_EVT
Posted: Sat Feb 22, 2020 7:05 am
I think I'm using the latest released version of ESP-IDF (I must admit that it is very hard to find exactly which version I have installed - all I see is references to the GIT repository but which version actually is 'stable' I have no idea: I think there should be a version number is at least one clearly marked file somewhere).
In the beta version, the 'gattc_client' demo used the 'esp_ble_gattc_read_char' function but this seems to have been replaced by setting up a notify system. Therefore I don't know if what I want to do is still possible.
Ideally what I want to do is to scan for all devices; select the ones I am interested in; connect to them and scan for the services and characteristics it has and read the values (a string and 2 16-bit integers); and then repeat.
My basic problem is that I call esp_ble_gattc_read_char but I never see the ESP_GATTC_READ_CHAR_EVT event called.
In the main loop I set up the ble stack and start a scan.
In the ESP_GAP_BLE_SCAN_RESULT_EVT event and specifically the ESP_GAP_SEARCH_INQ_RES_EVT search event, I see if the device is one of the devices I am interested in and, if so, I stop the scan, see if I've seen the device recently, remember the BDA if I have not and then connect to the device.
When I get the ESP_GATTC_DIS_SRVC_CMPL_EVT event, I call esp_ble_gattc_search_service.
For each ESP_GATTC_SEARCH_RES_EVT event I get, I call esp_ble_gattc_get_all_char and, as I know I only have 1 characteristic of interest, I then call esp_ble_gattc_read_char.
I then wait on a semaphore that I trigger in the ESP_GATTC_READ_CHAR_EVT event code but this is never called.
Can someone please tell how this is supposed to work with V4?
Susan
In the beta version, the 'gattc_client' demo used the 'esp_ble_gattc_read_char' function but this seems to have been replaced by setting up a notify system. Therefore I don't know if what I want to do is still possible.
Ideally what I want to do is to scan for all devices; select the ones I am interested in; connect to them and scan for the services and characteristics it has and read the values (a string and 2 16-bit integers); and then repeat.
My basic problem is that I call esp_ble_gattc_read_char but I never see the ESP_GATTC_READ_CHAR_EVT event called.
In the main loop I set up the ble stack and start a scan.
In the ESP_GAP_BLE_SCAN_RESULT_EVT event and specifically the ESP_GAP_SEARCH_INQ_RES_EVT search event, I see if the device is one of the devices I am interested in and, if so, I stop the scan, see if I've seen the device recently, remember the BDA if I have not and then connect to the device.
When I get the ESP_GATTC_DIS_SRVC_CMPL_EVT event, I call esp_ble_gattc_search_service.
For each ESP_GATTC_SEARCH_RES_EVT event I get, I call esp_ble_gattc_get_all_char and, as I know I only have 1 characteristic of interest, I then call esp_ble_gattc_read_char.
I then wait on a semaphore that I trigger in the ESP_GATTC_READ_CHAR_EVT event code but this is never called.
Can someone please tell how this is supposed to work with V4?
Susan