File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,26 @@ BLEUUID BLERemoteDescriptor::getUUID() {
5151
5252void BLERemoteDescriptor::gattClientEventHandler (esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t * evtParam) {
5353switch (event) {
54+ // ESP_GATTC_READ_DESCR_EVT
55+ // This event indicates that the server has responded to the read request.
56+ //
57+ // read:
58+ // - esp_gatt_status_t status
59+ // - uint16_t conn_id
60+ // - uint16_t handle
61+ // - uint8_t* value
62+ // - uint16_t value_len
5463case ESP_GATTC_READ_DESCR_EVT:
55- if (evtParam->read .handle != getHandle ())
56- break ;
64+ // If this event is not for us, then nothing further to do.
65+ if (evtParam->read .handle != getHandle ()) break ;
66+ // At this point, we have determined that the event is for us, so now we save the value
67+ if (evtParam->read .status == ESP_GATT_OK) {
68+ // it will read the cached value of the descriptor
69+ m_value = std::string ((char *) evtParam->read .value , evtParam->read .value_len );
70+ } else {
71+ m_value = " " ;
72+ }
73+ // Unlock the semaphore to ensure that the requestor of the data can continue.
5774m_semaphoreReadDescrEvt.give ();
5875break ;
5976
You can’t perform that action at this time.
0 commit comments