8000 Changes for #319 · James-sjec/esp32-snippets@dd08e7f · GitHub
[go: up one dir, main page]

Skip to content

Commit dd08e7f

Browse files
committed
Changes for nkolban#319
1 parent e330a4a commit dd08e7f

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

cpp_utils/BLECharacteristic.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,25 +199,35 @@ std::string BLECharacteristic::getValue() {
199199
} // getValue
200200

201201

202+
/**
203+
* Handle a GATT server event.
204+
*/
202205
void BLECharacteristic::handleGATTServerEvent(
203206
esp_gatts_cb_event_t event,
204207
esp_gatt_if_t gatts_if,
205208
esp_ble_gatts_cb_param_t* param) {
209+
ESP_LOGD(LOG_TAG, ">> handleGATTServerEvent: %s", BLEUtils::gattServerEventTypeToString(event).c_str());
210+
206211
switch(event) {
207212
// Events handled:
213+
//
208214
// ESP_GATTS_ADD_CHAR_EVT
209-
// ESP_GATTS_WRITE_EVT
215+
// ESP_GATTS_CONF_EVT
216+
// ESP_GATTS_CONNECT_EVT
217+
// ESP_GATTS_DISCONNECT_EVT
218+
// ESP_GATTS_EXEC_WRITE_EVT
210219
// ESP_GATTS_READ_EVT
211-
//
220+
// ESP_GATTS_WRITE_EVT
212221

222+
//
213223
// ESP_GATTS_EXEC_WRITE_EVT
214224
// When we receive this event it is an indication that a previous write long needs to be committed.
215225
//
216226
// exec_write:
217227
// - uint16_t conn_id
218228
// - uint32_t trans_id
219229
// - esp_bd_addr_t bda
220-
// - uint8_t exec_write_flag
230+
// - uint8_t exec_write_flag - Either ESP_GATT_PREP_WRITE_EXEC or ESP_GATT_PREP_WRITE_CANCEL
221231
//
222232
case ESP_GATTS_EXEC_WRITE_EVT: {
223233
if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) {
@@ -428,13 +438,15 @@ void BLECharacteristic::handleGATTServerEvent(
428438
break;
429439
}
430440

431-
case ESP_GATTS_CONNECT_EVT:
441+
case ESP_GATTS_CONNECT_EVT: {
432442
m_semaphoreConfEvt.give();
433443
break;
444+
}
434445

435-
case ESP_GATTS_DISCONNECT_EVT:
446+
case ESP_GATTS_DISCONNECT_EVT: {
436447
m_semaphoreConfEvt.give();
437448
break;
449+
}
438450

439451
default: {
440452
break;
@@ -446,7 +458,7 @@ void BLECharacteristic::handleGATTServerEvent(
446458
// event.
447459

448460
m_descriptorMap.handleGATTServerEvent(event, gatts_if, param);
449-
461+
ESP_LOGD(LOG_TAG, "<< handleGATTServerEvent");
450462
} // handleGATTServerEvent
451463

452464

@@ -699,6 +711,7 @@ void BLECharacteristic::setWriteProperty(bool value) {
699711
}
700712
} // setWriteProperty
701713

714+
702715
/**
703716
* @brief Return a string representation of the characteristic.
704717
* @return A string representation of the characteristic.
@@ -717,8 +730,10 @@ std::string BLECharacteristic::toString() {
717730
return stringstream.str();
718731
} // toString
719732

733+
720734
BLECharacteristicCallbacks::~BLECharacteristicCallbacks() {}
721735

736+
722737
/**
723738
* @brief Callback function to support a read request.
724739
* @param [in] pCharacteristic The characteristic that is the source of the event.

cpp_utils/BLECharacteristic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class BLECharacteristic {
102102
BLECharacteristicCallbacks* m_pCallbacks;
103103
BLEService* m_pService;
104104
BLEValue m_value;
105-
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
105+
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
106106

107107
void handleGATTServerEvent(
108108
esp_gatts_cb_event_t event,

cpp_utils/BLEServer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ void BLEServerCallbacks::onConnect(BLEServer* pServer) {
342342
ESP_LOGD("BLEServerCallbacks", "<< onConnect()");
343343
} // onConnect
344344

345+
345346
void BLEServerCallbacks::onDisconnect(BLEServer* pServer) {
346347
ESP_LOGD("BLEServerCallbacks", ">> onDisconnect(): Default");
347348
ESP_LOGD("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());

0 commit comments

Comments
 (0)
0