File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,26 @@ BLEUUID BLERemoteDescriptor::getUUID() {
51
51
52
52
void BLERemoteDescriptor::gattClientEventHandler (esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t * evtParam) {
53
53
switch (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
54
63
case 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.
57
74
m_semaphoreReadDescrEvt.give ();
58
75
break ;
59
76
You can’t perform that action at this time.
0 commit comments