Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 100a884

Browse files
committed
Merge branch 'ReducedLogging'
2 parents dcf312b + 16fd65a commit 100a884

13 files changed

+138
-138
lines changed

libraries/BLE/src/BLEAdvertising.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,25 @@ void BLEAdvertising::setScanResponse(bool set) {
120120
* @param [in] connectWhitelistOnly If true, only allow connections from those on the white list.
121121
*/
122122
void BLEAdvertising::setScanFilter(bool scanRequestWhitelistOnly, bool connectWhitelistOnly) {
123-
ESP_LOGD(LOG_TAG, ">> setScanFilter: scanRequestWhitelistOnly: %d, connectWhitelistOnly: %d", scanRequestWhitelistOnly, connectWhitelistOnly);
123+
ESP_LOGV(LOG_TAG, ">> setScanFilter: scanRequestWhitelistOnly: %d, connectWhitelistOnly: %d", scanRequestWhitelistOnly, connectWhitelistOnly);
124124
if (!scanRequestWhitelistOnly && !connectWhitelistOnly) {
125125
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY;
126-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
126+
ESP_LOGV(LOG_TAG, "<< setScanFilter");
127127
return;
128128
}
129129
if (scanRequestWhitelistOnly && !connectWhitelistOnly) {
130130
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY;
131-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
131+
ESP_LOGV(LOG_TAG, "<< setScanFilter");
132132
return;
133133
}
134134
if (!scanRequestWhitelistOnly && connectWhitelistOnly) {
135135
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST;
136-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
136+
ESP_LOGV(LOG_TAG, "<< setScanFilter");
137137
return;
138138
}
139139
if (scanRequestWhitelistOnly && connectWhitelistOnly) {
140140
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST;
141-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
141+
ESP_LOGV(LOG_TAG, "<< setScanFilter");
142142
return;
143143
}
144144
} // setScanFilter
@@ -149,15 +149,15 @@ void BLEAdvertising::setScanFilter(bool scanRequestWhitelistOnly, bool connectWh
149149
* @param [in] advertisementData The data to be advertised.
150150
*/
151151
void BLEAdvertising::setAdvertisementData(BLEAdvertisementData& advertisementData) {
152-
ESP_LOGD(LOG_TAG, ">> setAdvertisementData");
152+
ESP_LOGV(LOG_TAG, ">> setAdvertisementData");
153153
esp_err_t errRc = ::esp_ble_gap_config_adv_data_raw(
154154
(uint8_t*)advertisementData.getPayload().data(),
155155
advertisementData.getPayload().length());
156156
if (errRc != ESP_OK) {
157157
ESP_LOGE(LOG_TAG, "esp_ble_gap_config_adv_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
158158
}
159159
m_customAdvData = true; // Set the flag that indicates we are using custom advertising data.
160-
ESP_LOGD(LOG_TAG, "<< setAdvertisementData");
160+
ESP_LOGV(LOG_TAG, "<< setAdvertisementData");
161161
} // setAdvertisementData
162162

163163

@@ -166,15 +166,15 @@ void BLEAdvertising::setAdvertisementData(BLEAdvertisementData& advertisementDat
166166
* @param [in] advertisementData The data to be advertised.
167167
*/
168168
void BLEAdvertising::setScanResponseData(BLEAdvertisementData& advertisementData) {
169-
ESP_LOGD(LOG_TAG, ">> setScanResponseData");
169+
ESP_LOGV(LOG_TAG, ">> setScanResponseData");
170170
esp_err_t errRc = ::esp_ble_gap_config_scan_rsp_data_raw(
171171
(uint8_t*)advertisementData.getPayload().data(),
172172
advertisementData.getPayload().length());
173173
if (errRc != ESP_OK) {
174174
ESP_LOGE(LOG_TAG, "esp_ble_gap_config_scan_rsp_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
175175
}
176176
m_customScanResponseData = true; // Set the flag that indicates we are using custom scan response data.
177-
ESP_LOGD(LOG_TAG, "<< setScanResponseData");
177+
ESP_LOGV(LOG_TAG, "<< setScanResponseData");
178178
} // setScanResponseData
179179

180180
/**
@@ -183,7 +183,7 @@ void BLEAdvertising::setScanResponseData(BLEAdvertisementData& advertisementData
183183
* @return N/A.
184184
*/
185185
void BLEAdvertising::start() {
186-
ESP_LOGD(LOG_TAG, ">> start: customAdvData: %d, customScanResponseData: %d", m_customAdvData, m_customScanResponseData);
186+
ESP_LOGV(LOG_TAG, ">> start: customAdvData: %d, customScanResponseData: %d", m_customAdvData, m_customScanResponseData);
187187

188188
// We have a vector of service UUIDs that we wish to advertise. In order to use the
189189
// ESP-IDF framework, these must be supplied in a contiguous array of their 128bit (16 byte)
@@ -243,7 +243,7 @@ void BLEAdvertising::start() {
243243
ESP_LOGE(LOG_TAG, "<< esp_ble_gap_start_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
244244
return;
245245
}
246-
ESP_LOGD(LOG_TAG, "<< start");
246+
ESP_LOGV(LOG_TAG, "<< start");
247247
} // start
248248

249249

@@ -253,13 +253,13 @@ void BLEAdvertising::start() {
253253
* @return N/A.
254254
*/
255255
void BLEAdvertising::stop() {
256-
ESP_LOGD(LOG_TAG, ">> stop");
256+
ESP_LOGV(LOG_TAG, ">> stop");
257257
esp_err_t errRc = ::esp_ble_gap_stop_advertising();
258258
if (errRc != ESP_OK) {
259259
ESP_LOGE(LOG_TAG, "esp_ble_gap_stop_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
260260
return;
261261
}
262-
ESP_LOGD(LOG_TAG, "<< stop");
262+
ESP_LOGV(LOG_TAG, "<< stop");
263263
} // stop
264264

265265
/**

libraries/BLE/src/BLECharacteristic.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ BLECharacteristic::~BLECharacteristic() {
7070
* @return N/A.
7171
*/
7272
void BLECharacteristic::addDescriptor(BLEDescriptor* pDescriptor) {
73-
ESP_LOGD(LOG_TAG, ">> addDescriptor(): Adding %s to %s", pDescriptor->toString().c_str(), toString().c_str());
73+
ESP_LOGV(LOG_TAG, ">> addDescriptor(): Adding %s to %s", pDescriptor->toString().c_str(), toString().c_str());
7474
m_descriptorMap.setByUUID(pDescriptor->getUUID(), pDescriptor);
75-
ESP_LOGD(LOG_TAG, "<< addDescriptor()");
75+
ESP_LOGV(LOG_TAG, "<< addDescriptor()");
7676
} // addDescriptor
7777

7878

@@ -81,7 +81,7 @@ void BLECharacteristic::addDescriptor(BLEDescriptor* pDescriptor) {
8181
* @param [in] pService The service with which to associate this characteristic.
8282
*/
8383
void BLECharacteristic::executeCreate(BLEService* pService) {
84-
ESP_LOGD(LOG_TAG, ">> executeCreate()");
84+
ESP_LOGV(LOG_TAG, ">> executeCreate()");
8585

8686
if (m_handle != NULL_HANDLE) {
8787
ESP_LOGE(LOG_TAG, "Characteristic already has a handle.");
@@ -118,7 +118,7 @@ void BLECharacteristic::executeCreate(BLEService* pService) {
118118
pDescriptor = m_descriptorMap.getNext();
119119
} // End while
120120

121-
ESP_LOGD(LOG_TAG, "<< executeCreate");
121+
ESP_LOGV(LOG_TAG, "<< executeCreate");
122122
} // executeCreate
123123

124124

@@ -200,7 +200,7 @@ void BLECharacteristic::handleGATTServerEvent(
200200
esp_gatts_cb_event_t event,
201201
esp_gatt_if_t gatts_if,
202202
esp_ble_gatts_cb_param_t* param) {
203-
ESP_LOGD(LOG_TAG, ">> handleGATTServerEvent: %s", BLEUtils::gattServerEventTypeToString(event).c_str());
203+
ESP_LOGV(LOG_TAG, ">> handleGATTServerEvent: %s", BLEUtils::gattServerEventTypeToString(event).c_str());
204204

205205
switch(event) {
206206
// Events handled:
@@ -456,7 +456,7 @@ void BLECharacteristic::handleGATTServerEvent(
456456
// event.
457457

458458
m_descriptorMap.handleGATTServerEvent(event, gatts_if, param);
459-
ESP_LOGD(LOG_TAG, "<< handleGATTServerEvent");
459+
ESP_LOGV(LOG_TAG, "<< handleGATTServerEvent");
460460
} // handleGATTServerEvent
461461

462462

@@ -468,9 +468,9 @@ void BLECharacteristic::handleGATTServerEvent(
468468
*/
469469
void BLECharacteristic::indicate() {
470470

471-
ESP_LOGD(LOG_TAG, ">> indicate: length: %d", m_value.getValue().length());
471+
ESP_LOGV(LOG_TAG, ">> indicate: length: %d", m_value.getValue().length());
472472
notify(false);
473-
ESP_LOGD(LOG_TAG, "<< indicate");
473+
ESP_LOGV(LOG_TAG, "<< indicate");
474474
} // indicate
475475

476476

@@ -481,15 +481,15 @@ void BLECharacteristic::indicate() {
481481
* @return N/A.
482482
*/
483483
void BLECharacteristic::notify(bool is_notification) {
484-
ESP_LOGD(LOG_TAG, ">> notify: length: %d", m_value.getValue().length());
484+
ESP_LOGV(LOG_TAG, ">> notify: length: %d", m_value.getValue().length());
485485

486486
assert(getService() != nullptr);
487487
assert(getService()->getServer() != nullptr);
488488

489489
GeneralUtils::hexDump((uint8_t*)m_value.getValue().data(), m_value.getValue().length());
490490

491491
if (getService()->getServer()->getConnectedCount() == 0) {
492-
ESP_LOGD(LOG_TAG, "<< notify: No connected clients.");
492+
ESP_LOGV(LOG_TAG, "<< notify: No connected clients.");
493493
return;
494494
}
495495

@@ -499,13 +499,13 @@ void BLECharacteristic::notify(bool is_notification) {
499499
BLE2902 *p2902 = (BLE2902*)getDescriptorByUUID((uint16_t)0x2902);
500500
if(is_notification) {
501501
if (p2902 != nullptr && !p2902->getNotifications()) {
502-
ESP_LOGD(LOG_TAG, "<< notifications disabled; ignoring");
502+
ESP_LOGV(LOG_TAG, "<< notifications disabled; ignoring");
503503
return;
504504
}
505505
}
506506
else{
507507
if (p2902 != nullptr && !p2902->getIndications()) {
508-
ESP_LOGD(LOG_TAG, "<< indications disabled; ignoring");
508+
ESP_LOGV(LOG_TAG, "<< indications disabled; ignoring");
509509
return;
510510
}
511511
}
@@ -530,7 +530,7 @@ void BLECharacteristic::notify(bool is_notification) {
530530
if(!is_notification)
531531
m_semaphoreConfEvt.wait("indicate");
532532
}
533-
ESP_LOGD(LOG_TAG, "<< notify");
533+
ESP_LOGV(LOG_TAG, "<< notify");
534534
} // Notify
535535

536536

@@ -556,9 +556,9 @@ void BLECharacteristic::setBroadcastProperty(bool value) {
556556
* @param [in] pCallbacks An instance of a callbacks structure used to define any callbacks for the characteristic.
557557
*/
558558
void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
559-
ESP_LOGD(LOG_TAG, ">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
559+
ESP_LOGV(LOG_TAG, ">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
560560
m_pCallbacks = pCallbacks;
561-
ESP_LOGD(LOG_TAG, "<< setCallbacks");
561+
ESP_LOGV(LOG_TAG, "<< setCallbacks");
562562
} // setCallbacks
563563

564564

@@ -573,9 +573,9 @@ void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
573573
* @param [in] handle The handle associated with this characteristic.
574574
*/
575575
void BLECharacteristic::setHandle(uint16_t handle) {
576-
ESP_LOGD(LOG_TAG, ">> setHandle: handle=0x%.2x, characteristic uuid=%s", handle, getUUID().toString().c_str());
576+
ESP_LOGV(LOG_TAG, ">> setHandle: handle=0x%.2x, characteristic uuid=%s", handle, getUUID().toString().c_str());
577577
m_handle = handle;
578-
ESP_LOGD(LOG_TAG, "<< setHandle");
578+
ESP_LOGV(LOG_TAG, "<< setHandle");
579579
} // setHandle
580580

581581

@@ -628,14 +628,14 @@ void BLECharacteristic::setReadProperty(bool value) {
628628
*/
629629
void BLECharacteristic::setValue(uint8_t* data, size_t length) {
630630
char* pHex = BLEUtils::buildHexData(nullptr, data, length);
631-
ESP_LOGD(LOG_TAG, ">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str());
631+
ESP_LOGV(LOG_TAG, ">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str());
632632
free(pHex);
633633
if (length > ESP_GATT_MAX_ATTR_LEN) {
634634
ESP_LOGE(LOG_TAG, "Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
635635
return;
636636
}
637637
m_value.setValue(data, length);
638-
ESP_LOGD(LOG_TAG, "<< setValue");
638+
ESP_LOGV(LOG_TAG, "<< setValue");
639639
} // setValue
640640

641641

libraries/BLE/src/BLEClient.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ BLEClient::~BLEClient() {
7575
*
7676
*/
7777
void BLEClient::clearServices() {
78-
ESP_LOGD(LOG_TAG, ">> clearServices");
78+
ESP_LOGV(LOG_TAG, ">> clearServices");
7979
// Delete all the services.
8080
for (auto &myPair : m_servicesMap) {
8181
delete myPair.second;
8282
}
8383
m_servicesMap.clear();
8484
m_haveServices = false;
85-
ESP_LOGD(LOG_TAG, "<< clearServices");
85+
ESP_LOGV(LOG_TAG, "<< clearServices");
8686
} // clearServices
8787

8888
/**
@@ -100,7 +100,7 @@ bool BLEClient::connect(BLEAdvertisedDevice* device) {
100100
* @return True on success.
101101
*/
102102
bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
103-
ESP_LOGD(LOG_TAG, ">> connect(%s)", address.toString().c_str());
103+
ESP_LOGV(LOG_TAG, ">> connect(%s)", address.toString().c_str());
104104

105105
// We need the connection handle that we get from registering the application. We register the app
106106
// and then block on its completion. When the event has arrived, we will have the handle.
@@ -133,7 +133,7 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
133133
}
134134

135135
uint32_t rc = m_semaphoreOpenEvt.wait("connect"); // Wait for the connection to complete.
136-
ESP_LOGD(LOG_TAG, "<< connect(), rc=%d", rc==ESP_GATT_OK);
136+
ESP_LOGV(LOG_TAG, "<< connect(), rc=%d", rc==ESP_GATT_OK);
137137
return rc == ESP_GATT_OK;
138138
} // connect
139139

@@ -143,13 +143,13 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
143143
* @return N/A.
144144
*/
145145
void BLEClient::disconnect() {
146-
ESP_LOGD(LOG_TAG, ">> disconnect()");
146+
ESP_LOGV(LOG_TAG, ">> disconnect()");
147147
esp_err_t errRc = ::esp_ble_gattc_close(getGattcIf(), getConnId());
148148
if (errRc != ESP_OK) {
149149
ESP_LOGE(LOG_TAG, "esp_ble_gattc_close: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
150150
return;
151151
}
152-
ESP_LOGD(LOG_TAG, "<< disconnect()");
152+
ESP_LOGV(LOG_TAG, "<< disconnect()");
153153
} // disconnect
154154

155155

@@ -343,9 +343,9 @@ BLEAddress BLEClient::getPeerAddress() {
343343
* @return The RSSI value.
344344
*/
345345
int BLEClient::getRssi() {
346-
ESP_LOGD(LOG_TAG, ">> getRssi()");
346+
ESP_LOGV(LOG_TAG, ">> getRssi()");
347347
if (!isConnected()) {
348-
ESP_LOGD(LOG_TAG, "<< getRssi(): Not connected");
348+
ESP_LOGV(LOG_TAG, "<< getRssi(): Not connected");
349349
return 0;
350350
}
351351
// We make the API call to read the RSSI value which is an asynchronous operation. We expect to receive
@@ -358,7 +358,7 @@ int BLEClient::getRssi() {
358358
return 0;
359359
}
360360
int rssiValue = m_semaphoreRssiCmplEvt.wait("getRssi");
361-
ESP_LOGD(LOG_TAG, "<< getRssi(): %d", rssiValue);
361+
ESP_LOGV(LOG_TAG, "<< getRssi(): %d", rssiValue);
362362
return rssiValue;
363363
} // getRssi
364364

@@ -380,7 +380,7 @@ BLERemoteService* BLEClient::getService(const char* uuid) {
380380
* @throws BLEUuidNotFound
381381
*/
382382
BLERemoteService* BLEClient::getService(BLEUUID uuid) {
383-
ESP_LOGD(LOG_TAG, ">> getService: uuid: %s", uuid.toString().c_str());
383+
ESP_LOGV(LOG_TAG, ">> getService: uuid: %s", uuid.toString().c_str());
384384
// Design
385385
// ------
386386
// We wish to retrieve the service given its UUID. It is possible that we have not yet asked the
@@ -393,11 +393,11 @@ BLERemoteService* BLEClient::getService(BLEUUID uuid) {
393393
std::string uuidStr = uuid.toString();
394394
for (auto &myPair : m_servicesMap) {
395395
if (myPair.first == uuidStr) {
396-
ESP_LOGD(LOG_TAG, "<< getService: found the service with uuid: %s", uuid.toString().c_str());
396+
ESP_LOGV(LOG_TAG, "<< getService: found the service with uuid: %s", uuid.toString().c_str());
397397
return myPair.second;
398398
}
399399
} // End of each of the services.
400-
ESP_LOGD(LOG_TAG, "<< getService: not found");
400+
ESP_LOGV(LOG_TAG, "<< getService: not found");
401401
return nullptr;
402402
} // getService
403403

@@ -416,7 +416,7 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
416416
* peer BLE partner to be returned as events. Each event will be an an instance of ESP_GATTC_SEARCH_RES_EVT
417417
* and will culminate with an ESP_GATTC_SEARCH_CMPL_EVT when all have been received.
418418
*/
419-
ESP_LOGD(LOG_TAG, ">> getServices");
419+
ESP_LOGV(LOG_TAG, ">> getServices");
420420
// TODO implement retrieving services from cache
421421
clearServices(); // Clear any services that may exist.
422422

@@ -433,7 +433,7 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
433433
}
434434
// If sucessfull, remember that we now have services.
435435
m_haveServices = (m_semaphoreSearchCmplEvt.wait("getServices") == 0);
436-
ESP_LOGD(LOG_TAG, "<< getServices");
436+
ESP_LOGV(LOG_TAG, "<< getServices");
437437
return &m_servicesMap;
438438
} // getServices
439439

@@ -445,9 +445,9 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
445445
* @throws BLEUuidNotFound
446446
*/
447447
std::string BLEClient::getValue(BLEUUID serviceUUID, BLEUUID characteristicUUID) {
448-
ESP_LOGD(LOG_TAG, ">> getValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
448+
ESP_LOGV(LOG_TAG, ">> getValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
449449
std::string ret = getService(serviceUUID)->getCharacteristic(characteristicUUID)->readValue();
450-
ESP_LOGD(LOG_TAG, "<<getValue");
450+
ESP_LOGV(LOG_TAG, "<<getValue");
451451
return ret;
452452
} // getValue
453453

@@ -508,9 +508,9 @@ void BLEClient::setClientCallbacks(BLEClientCallbacks* pClientCallbacks) {
508508
* @throws BLEUuidNotFound
509509
*/
510510
void BLEClient::setValue(BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value) {
511-
ESP_LOGD(LOG_TAG, ">> setValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
511+
ESP_LOGV(LOG_TAG, ">> setValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
512512
getService(serviceUUID)->getCharacteristic(characteristicUUID)->writeValue(value);
513-
ESP_LOGD(LOG_TAG, "<< setValue");
513+
ESP_LOGV(LOG_TAG, "<< setValue");
514514
} // setValue
515515

516516
uint16_t BLEClient::getMTU() {

0 commit comments

Comments
 (0)