Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 01d7ea7

Browse files
Bascyme-no-dev
authored andcommittedApr 15, 2019
Refactored use of LOG_X(LOG_TAG, ...) to log_x(...) (#2672)
* Replaced ARDUINO_VARIANT with const char * Fixed missing return value * Added quotes around defined value in macro (Issue #2193) * Change logging from Error to Verbose when not found and default available * Move Enter and Exit logging to Verbose Level * Refactored LOG_X() into log_x()
1 parent af23d0b commit 01d7ea7

21 files changed

+399
-530
lines changed
 

‎libraries/BLE/src/BLEAdvertisedDevice.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616
#include <sstream>
1717
#include "BLEAdvertisedDevice.h"
1818
#include "BLEUtils.h"
19-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2019
#include "esp32-hal-log.h"
21-
#define LOG_TAG ""
22-
#else
23-
#include "esp_log.h"
24-
static const char* LOG_TAG="BLEAdvertisedDevice";
25-
#endif
2620

2721
BLEAdvertisedDevice::BLEAdvertisedDevice() {
2822
m_adFlag = 0;
@@ -249,7 +243,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
249243
length--;
250244

251245
char* pHex = BLEUtils::buildHexData(nullptr, payload, length);
252-
ESP_LOGD(LOG_TAG, "Type: 0x%.2x (%s), length: %d, data: %s",
246+
log_d("Type: 0x%.2x (%s), length: %d, data: %s",
253247
ad_type, BLEUtils::advTypeToString(ad_type), length, pHex);
254248
free(pHex);
255249

@@ -308,7 +302,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
308302

309303
case ESP_BLE_AD_TYPE_SERVICE_DATA: { // Adv Data Type: 0x16 (Service Data) - 2 byte UUID
310304
if (length < 2) {
311-
ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_SERVICE_DATA");
305+
log_e("Length too small for ESP_BLE_AD_TYPE_SERVICE_DATA");
312306
break;
313307
}
314308
uint16_t uuid = *(uint16_t*)payload;
@@ -321,7 +315,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
321315

322316
case ESP_BLE_AD_TYPE_32SERVICE_DATA: { // Adv Data Type: 0x20 (Service Data) - 4 byte UUID
323317
if (length < 4) {
324-
ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_32SERVICE_DATA");
318+
log_e("Length too small for ESP_BLE_AD_TYPE_32SERVICE_DATA");
325319
break;
326320
}
327321
uint32_t uuid = *(uint32_t*) payload;
@@ -334,7 +328,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
334328

335329
case ESP_BLE_AD_TYPE_128SERVICE_DATA: { // Adv Data Type: 0x21 (Service Data) - 16 byte UUID
336330
if (length < 16) {
337-
ESP_LOGE(LOG_TAG, "Length too small for ESP_BLE_AD_TYPE_128SERVICE_DATA");
331+
log_e("Length too small for ESP_BLE_AD_TYPE_128SERVICE_DATA");
338332
break;
339333
}
340334

@@ -346,7 +340,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
346340
} //ESP_BLE_AD_TYPE_32SERVICE_DATA
347341

348342
default: {
349-
ESP_LOGD(LOG_TAG, "Unhandled type: adType: %d - 0x%.2x", ad_type, ad_type);
343+
log_d("Unhandled type: adType: %d - 0x%.2x", ad_type, ad_type);
350344
break;
351345
}
352346
} // switch
@@ -386,7 +380,7 @@ void BLEAdvertisedDevice::setAdFlag(uint8_t adFlag) {
386380
void BLEAdvertisedDevice::setAppearance(uint16_t appearance) {
387381
m_appearance = appearance;
388382
m_haveAppearance = true;
389-
ESP_LOGD(LOG_TAG, "- appearance: %d", m_appearance);
383+
log_d("- appearance: %d", m_appearance);
390384
} // setAppearance
391385

392386

@@ -398,7 +392,7 @@ void BLEAdvertisedDevice::setManufacturerData(std::string manufacturerData) {
398392
m_manufacturerData = manufacturerData;
399393
m_haveManufacturerData = true;
400394
char* pHex = BLEUtils::buildHexData(nullptr, (uint8_t*) m_manufacturerData.data(), (uint8_t) m_manufacturerData.length());
401-
ESP_LOGD(LOG_TAG, "- manufacturer data: %s", pHex);
395+
log_d("- manufacturer data: %s", pHex);
402396
free(pHex);
403397
} // setManufacturerData
404398

@@ -410,7 +404,7 @@ void BLEAdvertisedDevice::setManufacturerData(std::string manufacturerData) {
410404
void BLEAdvertisedDevice::setName(std::string name) {
411405
m_name = name;
412406
m_haveName = true;
413-
ESP_LOGD(LOG_TAG, "- setName(): name: %s", m_name.c_str());
407+
log_d("- setName(): name: %s", m_name.c_str());
414408
} // setName
415409

416410

@@ -421,7 +415,7 @@ void BLEAdvertisedDevice::setName(std::string name) {
421415
void BLEAdvertisedDevice::setRSSI(int rssi) {
422416
m_rssi = rssi;
423417
m_haveRSSI = true;
424-
ESP_LOGD(LOG_TAG, "- setRSSI(): rssi: %d", m_rssi);
418+
log_d("- setRSSI(): rssi: %d", m_rssi);
425419
} // setRSSI
426420

427421

@@ -450,7 +444,7 @@ void BLEAdvertisedDevice::setServiceUUID(const char* serviceUUID) {
450444
void BLEAdvertisedDevice::setServiceUUID(BLEUUID serviceUUID) {
451445
m_serviceUUIDs.push_back(serviceUUID);
452446
m_haveServiceUUID = true;
453-
ESP_LOGD(LOG_TAG, "- addServiceUUID(): serviceUUID: %s", serviceUUID.toString().c_str());
447+
log_d("- addServiceUUID(): serviceUUID: %s", serviceUUID.toString().c_str());
454448
} // setServiceUUID
455449

456450

@@ -481,7 +475,7 @@ void BLEAdvertisedDevice::setServiceDataUUID(BLEUUID uuid) {
481475
void BLEAdvertisedDevice::setTXPower(int8_t txPower) {
482476
m_txPower = txPower;
483477
m_haveTXPower = true;
484-
ESP_LOGD(LOG_TAG, "- txPower: %d", m_txPower);
478+
log_d("- txPower: %d", m_txPower);
485479
} // setTXPower
486480

487481

‎libraries/BLE/src/BLEAdvertising.cpp

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,7 @@
2222
#include <esp_err.h>
2323
#include "BLEUtils.h"
2424
#include "GeneralUtils.h"
25-
26-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2725
#include "esp32-hal-log.h"
28-
#define LOG_TAG ""
29-
#else
30-
#include "esp_log.h"
31-
static const char* LOG_TAG = "BLEAdvertising";
32-
#endif
33-
34-
3526

3627
/**
3728
* @brief Construct a default advertising object.
@@ -120,25 +111,25 @@ void BLEAdvertising::setScanResponse(bool set) {
120111
* @param [in] connectWhitelistOnly If true, only allow connections from those on the white list.
121112
*/
122113
void BLEAdvertising::setScanFilter(bool scanRequestWhitelistOnly, bool connectWhitelistOnly) {
123-
ESP_LOGD(LOG_TAG, ">> setScanFilter: scanRequestWhitelistOnly: %d, connectWhitelistOnly: %d", scanRequestWhitelistOnly, connectWhitelistOnly);
114+
log_v(">> setScanFilter: scanRequestWhitelistOnly: %d, connectWhitelistOnly: %d", scanRequestWhitelistOnly, connectWhitelistOnly);
124115
if (!scanRequestWhitelistOnly && !connectWhitelistOnly) {
125116
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY;
126-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
117+
log_v("<< setScanFilter");
127118
return;
128119
}
129120
if (scanRequestWhitelistOnly && !connectWhitelistOnly) {
130121
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY;
131-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
122+
log_v("<< setScanFilter");
132123
return;
133124
}
134125
if (!scanRequestWhitelistOnly && connectWhitelistOnly) {
135126
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_WLST;
136-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
127+
log_v("<< setScanFilter");
137128
return;
138129
}
139130
if (scanRequestWhitelistOnly && connectWhitelistOnly) {
140131
m_advParams.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST;
141-
ESP_LOGD(LOG_TAG, "<< setScanFilter");
132+
log_v("<< setScanFilter");
142133
return;
143134
}
144135
} // setScanFilter
@@ -149,15 +140,15 @@ void BLEAdvertising::setScanFilter(bool scanRequestWhitelistOnly, bool connectWh
149140
* @param [in] advertisementData The data to be advertised.
150141
*/
151142
void BLEAdvertising::setAdvertisementData(BLEAdvertisementData& advertisementData) {
152-
ESP_LOGD(LOG_TAG, ">> setAdvertisementData");
143+
log_v(">> setAdvertisementData");
153144
esp_err_t errRc = ::esp_ble_gap_config_adv_data_raw(
154145
(uint8_t*)advertisementData.getPayload().data(),
155146
advertisementData.getPayload().length());
156147
if (errRc != ESP_OK) {
157-
ESP_LOGE(LOG_TAG, "esp_ble_gap_config_adv_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
148+
log_e("esp_ble_gap_config_adv_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
158149
}
159150
m_customAdvData = true; // Set the flag that indicates we are using custom advertising data.
160-
ESP_LOGD(LOG_TAG, "<< setAdvertisementData");
151+
log_v("<< setAdvertisementData");
161152
} // setAdvertisementData
162153

163154

@@ -166,15 +157,15 @@ void BLEAdvertising::setAdvertisementData(BLEAdvertisementData& advertisementDat
166157
* @param [in] advertisementData The data to be advertised.
167158
*/
168159
void BLEAdvertising::setScanResponseData(BLEAdvertisementData& advertisementData) {
169-
ESP_LOGD(LOG_TAG, ">> setScanResponseData");
160+
log_v(">> setScanResponseData");
170161
esp_err_t errRc = ::esp_ble_gap_config_scan_rsp_data_raw(
171162
(uint8_t*)advertisementData.getPayload().data(),
172163
advertisementData.getPayload().length());
173164
if (errRc != ESP_OK) {
174-
ESP_LOGE(LOG_TAG, "esp_ble_gap_config_scan_rsp_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
165+
log_e("esp_ble_gap_config_scan_rsp_data_raw: %d %s", errRc, GeneralUtils::errorToString(errRc));
175166
}
176167
m_customScanResponseData = true; // Set the flag that indicates we are using custom scan response data.
177-
ESP_LOGD(LOG_TAG, "<< setScanResponseData");
168+
log_v("<< setScanResponseData");
178169
} // setScanResponseData
179170

180171
/**
@@ -183,7 +174,7 @@ void BLEAdvertising::setScanResponseData(BLEAdvertisementData& advertisementData
183174
* @return N/A.
184175
*/
185176
void BLEAdvertising::start() {
186-
ESP_LOGD(LOG_TAG, ">> start: customAdvData: %d, customScanResponseData: %d", m_customAdvData, m_customScanResponseData);
177+
log_v(">> start: customAdvData: %d, customScanResponseData: %d", m_customAdvData, m_customScanResponseData);
187178

188179
// We have a vector of service UUIDs that we wish to advertise. In order to use the
189180
// ESP-IDF framework, these must be supplied in a contiguous array of their 128bit (16 byte)
@@ -195,14 +186,14 @@ void BLEAdvertising::start() {
195186
m_advData.p_service_uuid = new uint8_t[m_advData.service_uuid_len];
196187
uint8_t* p = m_advData.p_service_uuid;
197188
for (int i = 0; i < numServices; i++) {
198-
ESP_LOGD(LOG_TAG, "- advertising service: %s", m_serviceUUIDs[i].toString().c_str());
189+
log_d("- advertising service: %s", m_serviceUUIDs[i].toString().c_str());
199190
BLEUUID serviceUUID128 = m_serviceUUIDs[i].to128();
200191
memcpy(p, serviceUUID128.getNative()->uuid.uuid128, 16);
201192
p += 16;
202193
}
203194
} else {
204195
m_advData.service_uuid_len = 0;
205-
ESP_LOGD(LOG_TAG, "- no services advertised");
196+
log_d("- no services advertised");
206197
}
207198

208199
esp_err_t errRc;
@@ -214,7 +205,7 @@ void BLEAdvertising::start() {
214205
m_advData.include_txpower = !m_scanResp;
215206
errRc = ::esp_ble_gap_config_adv_data(&m_advData);
216207
if (errRc != ESP_OK) {
217-
ESP_LOGE(LOG_TAG, "<< esp_ble_gap_config_adv_data: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
208+
log_e("<< esp_ble_gap_config_adv_data: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
218209
return;
219210
}
220211
}
@@ -225,7 +216,7 @@ void BLEAdvertising::start() {
225216
m_advData.include_txpower = m_scanResp;
226217
errRc = ::esp_ble_gap_config_adv_data(&m_advData);
227218
if (errRc != ESP_OK) {
228-
ESP_LOGE(LOG_TAG, "<< esp_ble_gap_config_adv_data (Scan response): rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
219+
log_e("<< esp_ble_gap_config_adv_data (Scan response): rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
229220
return;
230221
}
231222
}
@@ -240,10 +231,10 @@ void BLEAdvertising::start() {
240231
// Start advertising.
241232
errRc = ::esp_ble_gap_start_advertising(&m_advParams);
242233
if (errRc != ESP_OK) {
243-
ESP_LOGE(LOG_TAG, "<< esp_ble_gap_start_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
234+
log_e("<< esp_ble_gap_start_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
244235
return;
245236
}
246-
ESP_LOGD(LOG_TAG, "<< start");
237+
log_v("<< start");
247238
} // start
248239

249240

@@ -253,13 +244,13 @@ void BLEAdvertising::start() {
253244
* @return N/A.
254245
*/
255246
void BLEAdvertising::stop() {
256-
ESP_LOGD(LOG_TAG, ">> stop");
247+
log_v(">> stop");
257248
esp_err_t errRc = ::esp_ble_gap_stop_advertising();
258249
if (errRc != ESP_OK) {
259-
ESP_LOGE(LOG_TAG, "esp_ble_gap_stop_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
250+
log_e("esp_ble_gap_stop_advertising: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
260251
return;
261252
}
262-
ESP_LOGD(LOG_TAG, "<< stop");
253+
log_v("<< stop");
263254
} // stop
264255

265256
/**
@@ -352,12 +343,12 @@ void BLEAdvertisementData::setFlags(uint8_t flag) {
352343
* @param [in] data Manufacturer data.
353344
*/
354345
void BLEAdvertisementData::setManufacturerData(std::string data) {
355-
ESP_LOGD("BLEAdvertisementData", ">> setManufacturerData");
346+
log_d("BLEAdvertisementData", ">> setManufacturerData");
356347
char cdata[2];
357348
cdata[0] = data.length() + 1;
358349
cdata[1] = ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE; // 0xff
359350
addData(std::string(cdata, 2) + data);
360-
ESP_LOGD("BLEAdvertisementData", "<< setManufacturerData");
351+
log_d("BLEAdvertisementData", "<< setManufacturerData");
361352
} // setManufacturerData
362353

363354

@@ -366,12 +357,12 @@ void BLEAdvertisementData::setManufacturerData(std::string data) {
366357
* @param [in] The complete name of the device.
367358
*/
368359
void BLEAdvertisementData::setName(std::string name) {
369-
ESP_LOGD("BLEAdvertisementData", ">> setName: %s", name.c_str());
360+
log_d("BLEAdvertisementData", ">> setName: %s", name.c_str());
370361
char cdata[2];
371362
cdata[0] = name.length() + 1;
372363
cdata[1] = ESP_BLE_AD_TYPE_NAME_CMPL; // 0x09
373364
addData(std::string(cdata, 2) + name);
374-
ESP_LOGD("BLEAdvertisementData", "<< setName");
365+
log_d("BLEAdvertisementData", "<< setName");
375366
} // setName
376367

377368

@@ -455,12 +446,12 @@ void BLEAdvertisementData::setServiceData(BLEUUID uuid, std::string data) {
455446
* @param [in] The short name of the device.
456447
*/
457448
void BLEAdvertisementData::setShortName(std::string name) {
458-
ESP_LOGD("BLEAdvertisementData", ">> setShortName: %s", name.c_str());
449+
log_d("BLEAdvertisementData", ">> setShortName: %s", name.c_str());
459450
char cdata[2];
460451
cdata[0] = name.length() + 1;
461452
cdata[1] = ESP_BLE_AD_TYPE_NAME_SHORT; // 0x08
462453
addData(std::string(cdata, 2) + name);
463-
ESP_LOGD("BLEAdvertisementData", "<< setShortName");
454+
log_d("BLEAdvertisementData", "<< setShortName");
464455
} // setShortName
465456

466457

@@ -476,7 +467,7 @@ void BLEAdvertising::handleGAPEvent(
476467
esp_gap_ble_cb_event_t event,
477468
esp_ble_gap_cb_param_t* param) {
478469

479-
ESP_LOGD(LOG_TAG, "handleGAPEvent [event no: %d]", (int)event);
470+
log_d("handleGAPEvent [event no: %d]", (int)event);
480471

481472
switch(event) {
482473
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT: {
@@ -492,7 +483,7 @@ void BLEAdvertising::handleGAPEvent(
492483
break;
493484
}
494485
case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: {
495-
ESP_LOGI(LOG_TAG, "STOP advertising");
486+
log_i("STOP advertising");
496487
start();
497488
break;
498489
}

‎libraries/BLE/src/BLEBeacon.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
#if defined(CONFIG_BT_ENABLED)
99
#include <string.h>
1010
#include "BLEBeacon.h"
11-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1211
#include "esp32-hal-log.h"
13-
#define LOG_TAG ""
14-
#else
15-
#include "esp_log.h"
16-
static const char* LOG_TAG = "BLEBeacon";
17-
#endif
1812

1913
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00)>>8) + (((x)&0xFF)<<8))
2014

@@ -58,7 +52,7 @@ int8_t BLEBeacon::getSignalPower() {
5852
*/
5953
void BLEBeacon::setData(std::string data) {
6054
if (data.length() != sizeof(m_beaconData)) {
61-
ESP_LOGE(LOG_TAG, "Unable to set the data ... length passed in was %d and expected %d", data.length(), sizeof(m_beaconData));
55+
log_e("Unable to set the data ... length passed in was %d and expected %d", data.length(), sizeof(m_beaconData));
6256
return;
6357
}
6458
memcpy(&m_beaconData, data.data(), sizeof(m_beaconData));

‎libraries/BLE/src/BLECharacteristic.cpp

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@
1818
#include "BLEUtils.h"
1919
#include "BLE2902.h"
2020
#include "GeneralUtils.h"
21-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2221
#include "esp32-hal-log.h"
23-
#define LOG_TAG ""
24-
#else
25-
#include "esp_log.h"
26-
static const char* LOG_TAG = "BLECharacteristic";
27-
#endif
2822

2923
#define NULL_HANDLE (0xffff)
3024

@@ -70,9 +64,9 @@ BLECharacteristic::~BLECharacteristic() {
7064
* @return N/A.
7165
*/
7266
void BLECharacteristic::addDescriptor(BLEDescriptor* pDescriptor) {
73-
ESP_LOGD(LOG_TAG, ">> addDescriptor(): Adding %s to %s", pDescriptor->toString().c_str(), toString().c_str());
67+
log_v(">> addDescriptor(): Adding %s to %s", pDescriptor->toString().c_str(), toString().c_str());
7468
m_descriptorMap.setByUUID(pDescriptor->getUUID(), pDescriptor);
75-
ESP_LOGD(LOG_TAG, "<< addDescriptor()");
69+
log_v("<< addDescriptor()");
7670
} // addDescriptor
7771

7872

@@ -81,16 +75,16 @@ void BLECharacteristic::addDescriptor(BLEDescriptor* pDescriptor) {
8175
* @param [in] pService The service with which to associate this characteristic.
8276
*/
8377
void BLECharacteristic::executeCreate(BLEService* pService) {
84-
ESP_LOGD(LOG_TAG, ">> executeCreate()");
78+
log_v(">> executeCreate()");
8579

8680
if (m_handle != NULL_HANDLE) {
87-
ESP_LOGE(LOG_TAG, "Characteristic already has a handle.");
81+
log_e("Characteristic already has a handle.");
8882
return;
8983
}
9084

9185
m_pService = pService; // Save the service to which this characteristic belongs.
9286

93-
ESP_LOGD(LOG_TAG, "Registering characteristic (esp_ble_gatts_add_char): uuid: %s, service: %s",
87+
log_d("Registering characteristic (esp_ble_gatts_add_char): uuid: %s, service: %s",
9488
getUUID().toString().c_str(),
9589
m_pService->toString().c_str());
9690

@@ -107,7 +101,7 @@ void BLECharacteristic::executeCreate(BLEService* pService) {
107101
&control); // Whether to auto respond or not.
108102

109103
if (errRc != ESP_OK) {
110-
ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_add_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
104+
log_e("<< esp_ble_gatts_add_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
111105
return;
112106
}
113107
m_semaphoreCreateEvt.wait("executeCreate");
@@ -118,7 +112,7 @@ void BLECharacteristic::executeCreate(BLEService* pService) {
118112
pDescriptor = m_descriptorMap.getNext();
119113
} // End while
120114

121-
ESP_LOGD(LOG_TAG, "<< executeCreate");
115+
log_v("<< executeCreate");
122116
} // executeCreate
123117

124118

@@ -200,7 +194,7 @@ void BLECharacteristic::handleGATTServerEvent(
200194
esp_gatts_cb_event_t event,
201195
esp_gatt_if_t gatts_if,
202196
esp_ble_gatts_cb_param_t* param) {
203-
ESP_LOGD(LOG_TAG, ">> handleGATTServerEvent: %s", BLEUtils::gattServerEventTypeToString(event).c_str());
197+
log_v(">> handleGATTServerEvent: %s", BLEUtils::gattServerEventTypeToString(event).c_str());
204198

205199
switch(event) {
206200
// Events handled:
@@ -238,7 +232,7 @@ void BLECharacteristic::handleGATTServerEvent(
238232
param->write.conn_id,
239233
param->write.trans_id, ESP_GATT_OK, nullptr);
240234
if (errRc != ESP_OK) {
241-
ESP_LOGE(LOG_TAG, "esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
235+
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
242236
}
243237
break;
244238
} // ESP_GATTS_EXEC_WRITE_EVT
@@ -288,11 +282,11 @@ void BLECharacteristic::handleGATTServerEvent(
288282
setValue(param->write.value, param->write.len);
289283
}
290284

291-
ESP_LOGD(LOG_TAG, " - Response to write event: New value: handle: %.2x, uuid: %s",
285+
log_d(" - Response to write event: New value: handle: %.2x, uuid: %s",
292286
getHandle(), getUUID().toString().c_str());
293287

294288
char* pHexData = BLEUtils::buildHexData(nullptr, param->write.value, param->write.len);
295-
ESP_LOGD(LOG_TAG, " - Data: length: %d, data: %s", param->write.len, pHexData);
289+
log_d(" - Data: length: %d, data: %s", param->write.len, pHexData);
296290
free(pHexData);
297291

298292
if (param->write.need_rsp) {
@@ -309,7 +303,7 @@ void BLECharacteristic::handleGATTServerEvent(
309303
param->write.conn_id,
310304
param->write.trans_id, ESP_GATT_OK, &rsp);
311305
if (errRc != ESP_OK) {
312-
ESP_LOGE(LOG_TAG, "esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
306+
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
313307
}
314308
} // Response needed
315309

@@ -361,9 +355,9 @@ void BLECharacteristic::handleGATTServerEvent(
361355

362356
// get mtu for peer device that we are sending read request to
363357
uint16_t maxOffset = getService()->getServer()->getPeerMTU(param->read.conn_id) - 1;
364-
ESP_LOGD(LOG_TAG, "mtu value: %d", maxOffset);
358+
log_d("mtu value: %d", maxOffset);
365359
if (param->read.need_rsp) {
366-
ESP_LOGD(LOG_TAG, "Sending a response (esp_ble_gatts_send_response)");
360+
log_d("Sending a response (esp_ble_gatts_send_response)");
367361
esp_gatt_rsp_t rsp;
368362

369363
if (param->read.is_long) {
@@ -407,7 +401,7 @@ void BLECharacteristic::handleGATTServerEvent(
407401
rsp.attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE;
408402

409403
char *pHexData = BLEUtils::buildHexData(nullptr, rsp.attr_value.value, rsp.attr_value.len);
410-
ESP_LOGD(LOG_TAG, " - Data: length=%d, data=%s, offset=%d", rsp.attr_value.len, pHexData, rsp.attr_value.offset);
404+
log_d(" - Data: length=%d, data=%s, offset=%d", rsp.attr_value.len, pHexData, rsp.attr_value.offset);
411405
free(pHexData);
412406

413407
esp_err_t errRc = ::esp_ble_gatts_send_response(
@@ -416,7 +410,7 @@ void BLECharacteristic::handleGATTServerEvent(
416410
ESP_GATT_OK,
417411
&rsp);
418412
if (errRc != ESP_OK) {
419-
ESP_LOGE(LOG_TAG, "esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
413+
log_e("esp_ble_gatts_send_response: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
420414
}
421415
} // Response needed
422416
} // Handle matches this characteristic.
@@ -431,7 +425,7 @@ void BLECharacteristic::handleGATTServerEvent(
431425
// - uint16_t conn_id – The connection used.
432426
//
433427
case ESP_GATTS_CONF_EVT: {
434-
// ESP_LOGD(LOG_TAG, "m_handle = %d, conf->handle = %d", m_handle, param->conf.handle);
428+
// log_d("m_handle = %d, conf->handle = %d", m_handle, param->conf.handle);
435429
if(param->conf.conn_id == getService()->getServer()->getConnId()) // && param->conf.handle == m_handle) // bug in esp-idf and not implemented in arduino yet
436430
m_semaphoreConfEvt.give(param->conf.status);
437431
break;
@@ -456,7 +450,7 @@ void BLECharacteristic::handleGATTServerEvent(
456450
// event.
457451

458452
m_descriptorMap.handleGATTServerEvent(event, gatts_if, param);
459-
ESP_LOGD(LOG_TAG, "<< handleGATTServerEvent");
453+
log_v("<< handleGATTServerEvent");
460454
} // handleGATTServerEvent
461455

462456

@@ -468,9 +462,9 @@ void BLECharacteristic::handleGATTServerEvent(
468462
*/
469463
void BLECharacteristic::indicate() {
470464

471-
ESP_LOGD(LOG_TAG, ">> indicate: length: %d", m_value.getValue().length());
465+
log_v(">> indicate: length: %d", m_value.getValue().length());
472466
notify(false);
473-
ESP_LOGD(LOG_TAG, "<< indicate");
467+
log_v("<< indicate");
474468
} // indicate
475469

476470

@@ -481,15 +475,15 @@ void BLECharacteristic::indicate() {
481475
* @return N/A.
482476
*/
483477
void BLECharacteristic::notify(bool is_notification) {
484-
ESP_LOGD(LOG_TAG, ">> notify: length: %d", m_value.getValue().length());
478+
log_v(">> notify: length: %d", m_value.getValue().length());
485479

486480
assert(getService() != nullptr);
487481
assert(getService()->getServer() != nullptr);
488482

489483
GeneralUtils::hexDump((uint8_t*)m_value.getValue().data(), m_value.getValue().length());
490484

491485
if (getService()->getServer()->getConnectedCount() == 0) {
492-
ESP_LOGD(LOG_TAG, "<< notify: No connected clients.");
486+
log_v("<< notify: No connected clients.");
493487
return;
494488
}
495489

@@ -499,20 +493,20 @@ void BLECharacteristic::notify(bool is_notification) {
499493
BLE2902 *p2902 = (BLE2902*)getDescriptorByUUID((uint16_t)0x2902);
500494
if(is_notification) {
501495
if (p2902 != nullptr && !p2902->getNotifications()) {
502-
ESP_LOGD(LOG_TAG, "<< notifications disabled; ignoring");
496+
log_v("<< notifications disabled; ignoring");
503497
return;
504498
}
505499
}
506500
else{
507501
if (p2902 != nullptr && !p2902->getIndications()) {
508-
ESP_LOGD(LOG_TAG, "<< indications disabled; ignoring");
502+
log_v("<< indications disabled; ignoring");
509503
return;
510504
}
511505
}
512506
for (auto &myPair : getService()->getServer()->getPeerDevices(false)) {
513507
uint16_t _mtu = (myPair.second.mtu);
514508
if (m_value.getValue().length() > _mtu - 3) {
515-
ESP_LOGW(LOG_TAG, "- Truncating to %d bytes (maximum notify size)", _mtu - 3);
509+
log_w("- Truncating to %d bytes (maximum notify size)", _mtu - 3);
516510
}
517511

518512
size_t length = m_value.getValue().length();
@@ -523,14 +517,14 @@ void BLECharacteristic::notify(bool is_notification) {
523517
myPair.first,
524518
getHandle(), length, (uint8_t*)m_value.getValue().data(), !is_notification); // The need_confirm = false makes this a notify.
525519
if (errRc != ESP_OK) {
526-
ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_send_ %s: rc=%d %s",is_notification?"notify":"indicate", errRc, GeneralUtils::errorToString(errRc));
520+
log_e("<< esp_ble_gatts_send_ %s: rc=%d %s",is_notification?"notify":"indicate", errRc, GeneralUtils::errorToString(errRc));
527521
m_semaphoreConfEvt.give();
528522
return;
529523
}
530524
if(!is_notification)
531525
m_semaphoreConfEvt.wait("indicate");
532526
}
533-
ESP_LOGD(LOG_TAG, "<< notify");
527+
log_v("<< notify");
534528
} // Notify
535529

536530

@@ -542,7 +536,7 @@ void BLECharacteristic::notify(bool is_notification) {
542536
* @return N/A
543537
*/
544538
void BLECharacteristic::setBroadcastProperty(bool value) {
545-
//ESP_LOGD(LOG_TAG, "setBroadcastProperty(%d)", value);
539+
//log_d("setBroadcastProperty(%d)", value);
546540
if (value) {
547541
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_BROADCAST);
548542
} else {
@@ -556,9 +550,9 @@ void BLECharacteristic::setBroadcastProperty(bool value) {
556550
* @param [in] pCallbacks An instance of a callbacks structure used to define any callbacks for the characteristic.
557551
*/
558552
void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
559-
ESP_LOGD(LOG_TAG, ">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
553+
log_v(">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
560554
m_pCallbacks = pCallbacks;
561-
ESP_LOGD(LOG_TAG, "<< setCallbacks");
555+
log_v("<< setCallbacks");
562556
} // setCallbacks
563557

564558

@@ -573,9 +567,9 @@ void BLECharacteristic::setCallbacks(BLECharacteristicCallbacks* pCallbacks) {
573567
* @param [in] handle The handle associated with this characteristic.
574568
*/
575569
void BLECharacteristic::setHandle(uint16_t handle) {
576-
ESP_LOGD(LOG_TAG, ">> setHandle: handle=0x%.2x, characteristic uuid=%s", handle, getUUID().toString().c_str());
570+
log_v(">> setHandle: handle=0x%.2x, characteristic uuid=%s", handle, getUUID().toString().c_str());
577571
m_handle = handle;
578-
ESP_LOGD(LOG_TAG, "<< setHandle");
572+
log_v("<< setHandle");
579573
} // setHandle
580574

581575

@@ -584,7 +578,7 @@ void BLECharacteristic::setHandle(uint16_t handle) {
584578
* @param [in] value Set to true if we are to allow indicate messages.
585579
*/
586580
void BLECharacteristic::setIndicateProperty(bool value) {
587-
//ESP_LOGD(LOG_TAG, "setIndicateProperty(%d)", value);
581+
//log_d("setIndicateProperty(%d)", value);
588582
if (value) {
589583
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_INDICATE);
590584
} else {
@@ -598,7 +592,7 @@ void BLECharacteristic::setIndicateProperty(bool value) {
598592
* @param [in] value Set to true if we are to allow notification messages.
599593
*/
600594
void BLECharacteristic::setNotifyProperty(bool value) {
601-
//ESP_LOGD(LOG_TAG, "setNotifyProperty(%d)", value);
595+
//log_d("setNotifyProperty(%d)", value);
602596
if (value) {
603597
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_NOTIFY);
604598
} else {
@@ -612,7 +606,7 @@ void BLECharacteristic::setNotifyProperty(bool value) {
612606
* @param [in] value Set to true if we are to allow reads.
613607
*/
614608
void BLECharacteristic::setReadProperty(bool value) {
615-
//ESP_LOGD(LOG_TAG, "setReadProperty(%d)", value);
609+
//log_d("setReadProperty(%d)", value);
616610
if (value) {
617611
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_READ);
618612
} else {
@@ -628,14 +622,14 @@ void BLECharacteristic::setReadProperty(bool value) {
628622
*/
629623
void BLECharacteristic::setValue(uint8_t* data, size_t length) {
630624
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());
625+
log_v(">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str());
632626
free(pHex);
633627
if (length > ESP_GATT_MAX_ATTR_LEN) {
634-
ESP_LOGE(LOG_TAG, "Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
628+
log_e("Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
635629
return;
636630
}
637631
m_value.setValue(data, length);
638-
ESP_LOGD(LOG_TAG, "<< setValue");
632+
log_v("<< setValue");
639633
} // setValue
640634

641635

@@ -693,7 +687,7 @@ void BLECharacteristic::setValue(double& data64) {
693687
* @param [in] value Set to true if we are to allow writes with no response.
694688
*/
695689
void BLECharacteristic::setWriteNoResponseProperty(bool value) {
696-
//ESP_LOGD(LOG_TAG, "setWriteNoResponseProperty(%d)", value);
690+
//log_d("setWriteNoResponseProperty(%d)", value);
697691
if (value) {
698692
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_WRITE_NR);
699693
} else {
@@ -707,7 +701,7 @@ void BLECharacteristic::setWriteNoResponseProperty(bool value) {
707701
* @param [in] value Set to true if we are to allow writes.
708702
*/
709703
void BLECharacteristic::setWriteProperty(bool value) {
710-
//ESP_LOGD(LOG_TAG, "setWriteProperty(%d)", value);
704+
//log_d("setWriteProperty(%d)", value);
711705
if (value) {
712706
m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_WRITE);
713707
} else {
@@ -743,8 +737,8 @@ BLECharacteristicCallbacks::~BLECharacteristicCallbacks() {}
743737
* @param [in] pCharacteristic The characteristic that is the source of the event.
744738
*/
745739
void BLECharacteristicCallbacks::onRead(BLECharacteristic* pCharacteristic) {
746-
ESP_LOGD("BLECharacteristicCallbacks", ">> onRead: default");
747-
ESP_LOGD("BLECharacteristicCallbacks", "<< onRead");
740+
log_d("BLECharacteristicCallbacks", ">> onRead: default");
741+
log_d("BLECharacteristicCallbacks", "<< onRead");
748742
} // onRead
749743

750744

@@ -753,8 +747,8 @@ void BLECharacteristicCallbacks::onRead(BLECharacteristic* pCharacteristic) {
753747
* @param [in] pCharacteristic The characteristic that is the source of the event.
754748
*/
755749
void BLECharacteristicCallbacks::onWrite(BLECharacteristic* pCharacteristic) {
756-
ESP_LOGD("BLECharacteristicCallbacks", ">> onWrite: default");
757-
ESP_LOGD("BLECharacteristicCallbacks", "<< onWrite");
750+
log_d("BLECharacteristicCallbacks", ">> onWrite: default");
751+
log_d("BLECharacteristicCallbacks", "<< onWrite");
758752
} // onWrite
759753

760754
#endif /* CONFIG_BT_ENABLED */

‎libraries/BLE/src/BLEClient.cpp

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
#include <sstream>
1919
#include <unordered_set>
2020
#include "BLEDevice.h"
21-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2221
#include "esp32-hal-log.h"
23-
#define LOG_TAG ""
24-
#else
25-
#include "esp_log.h"
26-
static const char* LOG_TAG = "BLEClient";
27-
#endif
28-
2922

3023
/*
3124
* Design
@@ -75,14 +68,14 @@ BLEClient::~BLEClient() {
7568
*
7669
*/
7770
void BLEClient::clearServices() {
78-
ESP_LOGD(LOG_TAG, ">> clearServices");
71+
log_v(">> clearServices");
7972
// Delete all the services.
8073
for (auto &myPair : m_servicesMap) {
8174
delete myPair.second;
8275
}
8376
m_servicesMap.clear();
8477
m_haveServices = false;
85-
ESP_LOGD(LOG_TAG, "<< clearServices");
78+
log_v("<< clearServices");
8679
} // clearServices
8780

8881
/**
@@ -100,7 +93,7 @@ bool BLEClient::connect(BLEAdvertisedDevice* device) {
10093
* @return True on success.
10194
*/
10295
bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
103-
ESP_LOGD(LOG_TAG, ">> connect(%s)", address.toString().c_str());
96+
log_v(">> connect(%s)", address.toString().c_str());
10497

10598
// We need the connection handle that we get from registering the application. We register the app
10699
// and then block on its completion. When the event has arrived, we will have the handle.
@@ -111,7 +104,7 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
111104
// clearServices(); // we dont need to delete services since every client is unique?
112105
esp_err_t errRc = ::esp_ble_gattc_app_register(m_appId);
113106
if (errRc != ESP_OK) {
114-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_app_register: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
107+
log_e("esp_ble_gattc_app_register: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
115108
return false;
116109
}
117110

@@ -128,12 +121,12 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
128121
1 // direct connection <-- maybe needs to be changed in case of direct indirect connection???
129122
);
130123
if (errRc != ESP_OK) {
131-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
124+
log_e("esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
132125
return false;
133126
}
134127

135128
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);
129+
log_v("<< connect(), rc=%d", rc==ESP_GATT_OK);
137130
return rc == ESP_GATT_OK;
138131
} // connect
139132

@@ -143,13 +136,13 @@ bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
143136
* @return N/A.
144137
*/
145138
void BLEClient::disconnect() {
146-
ESP_LOGD(LOG_TAG, ">> disconnect()");
139+
log_v(">> disconnect()");
147140
esp_err_t errRc = ::esp_ble_gattc_close(getGattcIf(), getConnId());
148141
if (errRc != ESP_OK) {
149-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_close: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
142+
log_e("esp_ble_gattc_close: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
150143
return;
151144
}
152-
ESP_LOGD(LOG_TAG, "<< disconnect()");
145+
log_v("<< disconnect()");
153146
} // disconnect
154147

155148

@@ -161,14 +154,14 @@ void BLEClient::gattClientEventHandler(
161154
esp_gatt_if_t gattc_if,
162155
esp_ble_gattc_cb_param_t* evtParam) {
163156

164-
ESP_LOGD(LOG_TAG, "gattClientEventHandler [esp_gatt_if: %d] ... %s",
157+
log_d("gattClientEventHandler [esp_gatt_if: %d] ... %s",
165158
gattc_if, BLEUtils::gattClientEventTypeToString(event).c_str());
166159

167160
// Execute handler code based on the type of event received.
168161
switch(event) {
169162

170163
case ESP_GATTC_SRVC_CHG_EVT:
171-
ESP_LOGI(LOG_TAG, "SERVICE CHANGED");
164+
log_i("SERVICE CHANGED");
172165
break;
173166

174167
case ESP_GATTC_CLOSE_EVT: {
@@ -234,7 +227,7 @@ void BLEClient::gattClientEventHandler(
234227

235228
case ESP_GATTC_CFG_MTU_EVT:
236229
if(evtParam->cfg_mtu.status != ESP_GATT_OK) {
237-
ESP_LOGE(LOG_TAG,"Config mtu failed");
230+
log_e("Config mtu failed");
238231
}
239232
m_mtu = evtParam->cfg_mtu.mtu;
240233
break;
@@ -243,7 +236,7 @@ void BLEClient::gattClientEventHandler(
243236
BLEDevice::updatePeerDevice(this, true, m_gattc_if);
244237
esp_err_t errRc = esp_ble_gattc_send_mtu_req(gattc_if, evtParam->connect.conn_id);
245238
if (errRc != ESP_OK) {
246-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_send_mtu_req: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
239+
log_e("esp_ble_gattc_send_mtu_req: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
247240
}
248241
#ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
249242
if(BLEDevice::m_securityLevel){
@@ -263,17 +256,17 @@ void BLEClient::gattClientEventHandler(
263256
case ESP_GATTC_SEARCH_CMPL_EVT: {
264257
esp_ble_gattc_cb_param_t* p_data = (esp_ble_gattc_cb_param_t*)evtParam;
265258
if (p_data->search_cmpl.status != ESP_GATT_OK){
266-
ESP_LOGE(LOG_TAG, "search service failed, error status = %x", p_data->search_cmpl.status);
259+
log_e("search service failed, error status = %x", p_data->search_cmpl.status);
267260
break;
268261
}
269262
#ifndef ARDUINO_ARCH_ESP32
270263
// commented out just for now to keep backward compatibility
271264
// if(p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_REMOTE_DEVICE) {
272-
// ESP_LOGI(LOG_TAG, "Get service information from remote device");
265+
// log_i("Get service information from remote device");
273266
// } else if (p_data->search_cmpl.searched_service_source == ESP_GATT_SERVICE_FROM_NVS_FLASH) {
274-
// ESP_LOGI(LOG_TAG, "Get service information from flash");
267+
// log_i("Get service information from flash");
275268
// } else {
276-
// ESP_LOGI(LOG_TAG, "unknown service source");
269+
// log_i("unknown service source");
277270
// }
278271
#endif
279272
m_semaphoreSearchCmplEvt.give(0);
@@ -343,9 +336,9 @@ BLEAddress BLEClient::getPeerAddress() {
343336
* @return The RSSI value.
344337
*/
345338
int BLEClient::getRssi() {
346-
ESP_LOGD(LOG_TAG, ">> getRssi()");
339+
log_v(">> getRssi()");
347340
if (!isConnected()) {
348-
ESP_LOGD(LOG_TAG, "<< getRssi(): Not connected");
341+
log_v("<< getRssi(): Not connected");
349342
return 0;
350343
}
351344
// We make the API call to read the RSSI value which is an asynchronous operation. We expect to receive
@@ -354,11 +347,11 @@ int BLEClient::getRssi() {
354347
m_semaphoreRssiCmplEvt.take("getRssi");
355348
esp_err_t rc = ::esp_ble_gap_read_rssi(*getPeerAddress().getNative());
356349
if (rc != ESP_OK) {
357-
ESP_LOGE(LOG_TAG, "<< getRssi: esp_ble_gap_read_rssi: rc=%d %s", rc, GeneralUtils::errorToString(rc));
350+
log_e("<< getRssi: esp_ble_gap_read_rssi: rc=%d %s", rc, GeneralUtils::errorToString(rc));
358351
return 0;
359352
}
360353
int rssiValue = m_semaphoreRssiCmplEvt.wait("getRssi");
361-
ESP_LOGD(LOG_TAG, "<< getRssi(): %d", rssiValue);
354+
log_v("<< getRssi(): %d", rssiValue);
362355
return rssiValue;
363356
} // getRssi
364357

@@ -380,7 +373,7 @@ BLERemoteService* BLEClient::getService(const char* uuid) {
380373
* @throws BLEUuidNotFound
381374
*/
382375
BLERemoteService* BLEClient::getService(BLEUUID uuid) {
383-
ESP_LOGD(LOG_TAG, ">> getService: uuid: %s", uuid.toString().c_str());
376+
log_v(">> getService: uuid: %s", uuid.toString().c_str());
384377
// Design
385378
// ------
386379
// We wish to retrieve the service given its UUID. It is possible that we have not yet asked the
@@ -393,11 +386,11 @@ BLERemoteService* BLEClient::getService(BLEUUID uuid) {
393386
std::string uuidStr = uuid.toString();
394387
for (auto &myPair : m_servicesMap) {
395388
if (myPair.first == uuidStr) {
396-
ESP_LOGD(LOG_TAG, "<< getService: found the service with uuid: %s", uuid.toString().c_str());
389+
log_v("<< getService: found the service with uuid: %s", uuid.toString().c_str());
397390
return myPair.second;
398391
}
399392
} // End of each of the services.
400-
ESP_LOGD(LOG_TAG, "<< getService: not found");
393+
log_v("<< getService: not found");
401394
return nullptr;
402395
} // getService
403396

@@ -416,7 +409,7 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
416409
* peer BLE partner to be returned as events. Each event will be an an instance of ESP_GATTC_SEARCH_RES_EVT
417410
* and will culminate with an ESP_GATTC_SEARCH_CMPL_EVT when all have been received.
418411
*/
419-
ESP_LOGD(LOG_TAG, ">> getServices");
412+
log_v(">> getServices");
420413
// TODO implement retrieving services from cache
421414
clearServices(); // Clear any services that may exist.
422415

@@ -428,12 +421,12 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
428421

429422
m_semaphoreSearchCmplEvt.take("getServices");
430423
if (errRc != ESP_OK) {
431-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_search_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
424+
log_e("esp_ble_gattc_search_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
432425
return &m_servicesMap;
433426
}
434427
// If sucessfull, remember that we now have services.
435428
m_haveServices = (m_semaphoreSearchCmplEvt.wait("getServices") == 0);
436-
ESP_LOGD(LOG_TAG, "<< getServices");
429+
log_v("<< getServices");
437430
return &m_servicesMap;
438431
} // getServices
439432

@@ -445,9 +438,9 @@ std::map<std::string, BLERemoteService*>* BLEClient::getServices() {
445438
* @throws BLEUuidNotFound
446439
*/
447440
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());
441+
log_v(">> getValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
449442
std::string ret = getService(serviceUUID)->getCharacteristic(characteristicUUID)->readValue();
450-
ESP_LOGD(LOG_TAG, "<<getValue");
443+
log_v("<<getValue");
451444
return ret;
452445
} // getValue
453446

@@ -461,7 +454,7 @@ std::string BLEClient::getValue(BLEUUID serviceUUID, BLEUUID characteristicUUID)
461454
void BLEClient::handleGAPEvent(
462455
esp_gap_ble_cb_event_t event,
463456
esp_ble_gap_cb_param_t* param) {
464-
ESP_LOGD(LOG_TAG, "BLEClient ... handling GAP event!");
457+
log_d("BLEClient ... handling GAP event!");
465458
switch (event) {
466459
//
467460
// ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT
@@ -508,9 +501,9 @@ void BLEClient::setClientCallbacks(BLEClientCallbacks* pClientCallbacks) {
508501
* @throws BLEUuidNotFound
509502
*/
510503
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());
504+
log_v(">> setValue: serviceUUID: %s, characteristicUUID: %s", serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
512505
getService(serviceUUID)->getCharacteristic(characteristicUUID)->writeValue(value);
513-
ESP_LOGD(LOG_TAG, "<< setValue");
506+
log_v("<< setValue");
514507
} // setValue
515508

516509
uint16_t BLEClient::getMTU() {

‎libraries/BLE/src/BLEDescriptor.cpp

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,7 @@
1515
#include "BLEService.h"
1616
#include "BLEDescriptor.h"
1717
#include "GeneralUtils.h"
18-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1918
#include "esp32-hal-log.h"
20-
#define LOG_TAG ""
21-
#else
22-
#include "esp_log.h"
23-
static const char* LOG_TAG = "BLEDescriptor";
24-
#endif
25-
26-
27-
2819

2920
#define NULL_HANDLE (0xffff)
3021

@@ -63,10 +54,10 @@ BLEDescriptor::~BLEDescriptor() {
6354
* @param [in] pCharacteristic The characteristic to which to register this descriptor.
6455
*/
6556
void BLEDescriptor::executeCreate(BLECharacteristic* pCharacteristic) {
66-
ESP_LOGD(LOG_TAG, ">> executeCreate(): %s", toString().c_str());
57+
log_v(">> executeCreate(): %s", toString().c_str());
6758

6859
if (m_handle != NULL_HANDLE) {
69-
ESP_LOGE(LOG_TAG, "Descriptor already has a handle.");
60+
log_e("Descriptor already has a handle.");
7061
return;
7162
}
7263

@@ -82,12 +73,12 @@ void BLEDescriptor::executeCreate(BLECharacteristic* pCharacteristic) {
8273
&m_value,
8374
&control);
8475
if (errRc != ESP_OK) {
85-
ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_add_char_descr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
76+
log_e("<< esp_ble_gatts_add_char_descr: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
8677
return;
8778
}
8879

8980
m_semaphoreCreateEvt.wait("executeCreate");
90-
ESP_LOGD(LOG_TAG, "<< executeCreate");
81+
log_v("<< executeCreate");
9182
} // executeCreate
9283

9384

@@ -213,9 +204,9 @@ void BLEDescriptor::handleGATTServerEvent(
213204
* @param [in] pCallbacks An instance of a callback structure used to define any callbacks for the descriptor.
214205
*/
215206
void BLEDescriptor::setCallbacks(BLEDescriptorCallbacks* pCallback) {
216-
ESP_LOGD(LOG_TAG, ">> setCallbacks: 0x%x", (uint32_t) pCallback);
207+
log_v(">> setCallbacks: 0x%x", (uint32_t) pCallback);
217208
m_pCallback = pCallback;
218-
ESP_LOGD(LOG_TAG, "<< setCallbacks");
209+
log_v("<< setCallbacks");
219210
} // setCallbacks
220211

221212

@@ -226,9 +217,9 @@ void BLEDescriptor::setCallbacks(BLEDescriptorCallbacks* pCallback) {
226217
* @return N/A.
227218
*/
228219
void BLEDescriptor::setHandle(uint16_t handle) {
229-
ESP_LOGD(LOG_TAG, ">> setHandle(0x%.2x): Setting descriptor handle to be 0x%.2x", handle, handle);
220+
log_v(">> setHandle(0x%.2x): Setting descriptor handle to be 0x%.2x", handle, handle);
230221
m_handle = handle;
231-
ESP_LOGD(LOG_TAG, "<< setHandle()");
222+
log_v("<< setHandle()");
232223
} // setHandle
233224

234225

@@ -239,7 +230,7 @@ void BLEDescriptor::setHandle(uint16_t handle) {
239230
*/
240231
void BLEDescriptor::setValue(uint8_t* data, size_t length) {
241232
if (length > ESP_GATT_MAX_ATTR_LEN) {
242-
ESP_LOGE(LOG_TAG, "Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
233+
log_e("Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
243234
return;
244235
}
245236
m_value.attr_len = length;
@@ -278,8 +269,8 @@ BLEDescriptorCallbacks::~BLEDescriptorCallbacks() {}
278269
* @param [in] pDescriptor The descriptor that is the source of the event.
279270
*/
280271
void BLEDescriptorCallbacks::onRead(BLEDescriptor* pDescriptor) {
281-
ESP_LOGD("BLEDescriptorCallbacks", ">> onRead: default");
282-
ESP_LOGD("BLEDescriptorCallbacks", "<< onRead");
272+
log_d("BLEDescriptorCallbacks", ">> onRead: default");
273+
log_d("BLEDescriptorCallbacks", "<< onRead");
283274
} // onRead
284275

285276

@@ -288,8 +279,8 @@ void BLEDescriptorCallbacks::onRead(BLEDescriptor* pDescriptor) {
288279
* @param [in] pDescriptor The descriptor that is the source of the event.
289280
*/
290281
void BLEDescriptorCallbacks::onWrite(BLEDescriptor* pDescriptor) {
291-
ESP_LOGD("BLEDescriptorCallbacks", ">> onWrite: default");
292-
ESP_LOGD("BLEDescriptorCallbacks", "<< onWrite");
282+
log_d("BLEDescriptorCallbacks", ">> onWrite: default");
283+
log_d("BLEDescriptorCallbacks", "<< onWrite");
293284
} // onWrite
294285

295286

‎libraries/BLE/src/BLEDevice.cpp

Lines changed: 57 additions & 57 deletions
Large diffs are not rendered by default.

‎libraries/BLE/src/BLEEddystoneTLM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if defined(CONFIG_BT_ENABLED)
99
#include <string.h>
1010
#include <sstream>
11-
#include <esp_log.h>
11+
#include "esp32-hal-log.h"
1212
#include "BLEEddystoneTLM.h"
1313

1414
static const char LOG_TAG[] = "BLEEddystoneTLM";
@@ -117,7 +117,7 @@ std::string BLEEddystoneTLM::toString() {
117117
*/
118118
void BLEEddystoneTLM::setData(std::string data) {
119119
if (data.length() != sizeof(m_eddystoneData)) {
120-
ESP_LOGE(LOG_TAG, "Unable to set the data ... length passed in was %d and expected %d", data.length(), sizeof(m_eddystoneData));
120+
log_e("Unable to set the data ... length passed in was %d and expected %d", data.length(), sizeof(m_eddystoneData));
121121
return;
122122
}
123123
memcpy(&m_eddystoneData, data.data(), data.length());

‎libraries/BLE/src/BLEEddystoneURL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "sdkconfig.h"
88
#if defined(CONFIG_BT_ENABLED)
99
#include <string.h>
10-
#include <esp_log.h>
10+
#include "esp32-hal-log.h"
1111
#include "BLEEddystoneURL.h"
1212

1313
static const char LOG_TAG[] = "BLEEddystoneURL";
@@ -118,7 +118,7 @@ std::string BLEEddystoneURL::getDecodedURL() {
118118
*/
119119
void BLEEddystoneURL::setData(std::string data) {
120120
if (data.length() > sizeof(m_eddystoneData)) {
121-
ESP_LOGE(LOG_TAG, "Unable to set the data ... length passed in was %d and max expected %d", data.length(), sizeof(m_eddystoneData));
121+
log_e("Unable to set the data ... length passed in was %d and max expected %d", data.length(), sizeof(m_eddystoneData));
122122
return;
123123
}
124124
memset(&m_eddystoneData, 0, sizeof(m_eddystoneData));
@@ -136,7 +136,7 @@ void BLEEddystoneURL::setPower(int8_t advertisedTxPower) {
136136

137137
void BLEEddystoneURL::setURL(std::string url) {
138138
if (url.length() > sizeof(m_eddystoneData.url)) {
139-
ESP_LOGE(LOG_TAG, "Unable to set the url ... length passed in was %d and max expected %d", url.length(), sizeof(m_eddystoneData.url));
139+
log_e("Unable to set the url ... length passed in was %d and max expected %d", url.length(), sizeof(m_eddystoneData.url));
140140
return;
141141
}
142142
memset(m_eddystoneData.url, 0, sizeof(m_eddystoneData.url));

‎libraries/BLE/src/BLERemoteCharacteristic.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
#include "BLEUtils.h"
1919
#include "GeneralUtils.h"
2020
#include "BLERemoteDescriptor.h"
21-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2221
#include "esp32-hal-log.h"
23-
#define LOG_TAG ""
24-
#else
25-
#include "esp_log.h"
26-
static const char* LOG_TAG = "BLERemoteCharacteristic"; // The logging tag for this class.
27-
#endif
28-
2922

3023

3124
/**
@@ -40,15 +33,15 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(
4033
BLEUUID uuid,
4134
esp_gatt_char_prop_t charProp,
4235
BLERemoteService* pRemoteService) {
43-
ESP_LOGD(LOG_TAG, ">> BLERemoteCharacteristic: handle: %d 0x%d, uuid: %s", handle, handle, uuid.toString().c_str());
36+
log_v(">> BLERemoteCharacteristic: handle: %d 0x%d, uuid: %s", handle, handle, uuid.toString().c_str());
4437
m_handle = handle;
4538
m_uuid = uuid;
4639
m_charProp = charProp;
4740
m_pRemoteService = pRemoteService;
4841
m_notifyCallback = nullptr;
4942

5043
retrieveDescriptors(); // Get the descriptors for this characteristic
51-
ESP_LOGD(LOG_TAG, "<< BLERemoteCharacteristic");
44+
log_v("<< BLERemoteCharacteristic");
5245
} // BLERemoteCharacteristic
5346

5447

@@ -166,7 +159,7 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
166159
case ESP_GATTC_NOTIFY_EVT: {
167160
if (evtParam->notify.handle != getHandle()) break;
168161
if (m_notifyCallback != nullptr) {
169-
ESP_LOGD(LOG_TAG, "Invoking callback for notification on characteristic %s", toString().c_str());
162+
log_d("Invoking callback for notification on characteristic %s", toString().c_str());
170163
m_notifyCallback(this, evtParam->notify.value, evtParam->notify.value_len, evtParam->notify.is_notify);
171164
} // End we have a callback function ...
172165
break;
@@ -253,7 +246,7 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
253246
* @brief Populate the descriptors (if any) for this characteristic.
254247
*/
255248
void BLERemoteCharacteristic::retrieveDescriptors() {
256-
ESP_LOGD(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());
249+
log_v(">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());
257250

258251
removeDescriptors(); // Remove any existing descriptors.
259252

@@ -277,13 +270,13 @@ void BLERemoteCharacteristic::retrieveDescriptors() {
277270
}
278271

279272
if (status != ESP_GATT_OK) {
280-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_get_all_descr: %s", BLEUtils::gattStatusToString(status).c_str());
273+
log_e("esp_ble_gattc_get_all_descr: %s", BLEUtils::gattStatusToString(status).c_str());
281274
break;
282275
}
283276

284277
if (count == 0) break;
285278

286-
ESP_LOGD(LOG_TAG, "Found a descriptor: Handle: %d, UUID: %s", result.handle, BLEUUID(result.uuid).toString().c_str());
279+
log_d("Found a descriptor: Handle: %d, UUID: %s", result.handle, BLEUUID(result.uuid).toString().c_str());
287280

288281
// We now have a new characteristic ... let us add that to our set of known characteristics
289282
BLERemoteDescriptor* pNewRemoteDescriptor = new BLERemoteDescriptor(
@@ -297,7 +290,7 @@ void BLERemoteCharacteristic::retrieveDescriptors() {
297290
offset++;
298291
} // while true
299292
//m_haveCharacteristics = true; // Remember that we have received the characteristics.
300-
ESP_LOGD(LOG_TAG, "<< retrieveDescriptors(): Found %d descriptors.", offset);
293+
log_v("<< retrieveDescriptors(): Found %d descriptors.", offset);
301294
} // getDescriptors
302295

303296

@@ -314,8 +307,8 @@ std::map<std::string, BLERemoteDescriptor*>* BLERemoteCharacteristic::getDescrip
314307
* @return The handle for this characteristic.
315308
*/
316309
uint16_t BLERemoteCharacteristic::getHandle() {
317-
//ESP_LOGD(LOG_TAG, ">> getHandle: Characteristic: %s", getUUID().toString().c_str());
318-
//ESP_LOGD(LOG_TAG, "<< getHandle: %d 0x%.2x", m_handle, m_handle);
310+
//log_v(">> getHandle: Characteristic: %s", getUUID().toString().c_str());
311+
//log_v("<< getHandle: %d 0x%.2x", m_handle, m_handle);
319312
return m_handle;
320313
} // getHandle
321314

@@ -326,15 +319,15 @@ uint16_t BLERemoteCharacteristic::getHandle() {
326319
* @return The Remote descriptor (if present) or null if not present.
327320
*/
328321
BLERemoteDescriptor* BLERemoteCharacteristic::getDescriptor(BLEUUID uuid) {
329-
ESP_LOGD(LOG_TAG, ">> getDescriptor: uuid: %s", uuid.toString().c_str());
322+
log_v(">> getDescriptor: uuid: %s", uuid.toString().c_str());
330323
std::string v = uuid.toString();
331324
for (auto &myPair : m_descriptorMap) {
332325
if (myPair.first == v) {
333-
ESP_LOGD(LOG_TAG, "<< getDescriptor: found");
326+
log_v("<< getDescriptor: found");
334327
return myPair.second;
335328
}
336329
}
337-
ESP_LOGD(LOG_TAG, "<< getDescriptor: Not found");
330+
log_v("<< getDescriptor: Not found");
338331
return nullptr;
339332
} // getDescriptor
340333

@@ -401,11 +394,11 @@ uint8_t BLERemoteCharacteristic::readUInt8() {
401394
* @return The value of the remote characteristic.
402395
*/
403396
std::string BLERemoteCharacteristic::readValue() {
404-
ESP_LOGD(LOG_TAG, ">> readValue(): uuid: %s, handle: %d 0x%.2x", getUUID().toString().c_str(), getHandle(), getHandle());
397+
log_v(">> readValue(): uuid: %s, handle: %d 0x%.2x", getUUID().toString().c_str(), getHandle(), getHandle());
405398

406399
// Check to see that we are connected.
407400
if (!getRemoteService()->getClient()->isConnected()) {
408-
ESP_LOGE(LOG_TAG, "Disconnected");
401+
log_e("Disconnected");
409402
throw BLEDisconnectedException();
410403
}
411404

@@ -421,15 +414,15 @@ std::string BLERemoteCharacteristic::readValue() {
421414
ESP_GATT_AUTH_REQ_NONE); // Security
422415

423416
if (errRc != ESP_OK) {
424-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
417+
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
425418
return "";
426419
}
427420

428421
// Block waiting for the event that indicates that the read has completed. When it has, the std::string found
429422
// in m_value will contain our data.
430423
m_semaphoreReadCharEvt.wait("readValue");
431424

432-
ESP_LOGD(LOG_TAG, "<< readValue(): length: %d", m_value.length());
425+
log_v("<< readValue(): length: %d", m_value.length());
433426
return m_value;
434427
} // readValue
435428

@@ -441,7 +434,7 @@ std::string BLERemoteCharacteristic::readValue() {
441434
* @return N/A.
442435
*/
443436
void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback, bool notifications) {
444-
ESP_LOGD(LOG_TAG, ">> registerForNotify(): %s", toString().c_str());
437+
log_v(">> registerForNotify(): %s", toString().c_str());
445438

446439
m_notifyCallback = notifyCallback; // Save the notification callback.
447440

@@ -455,7 +448,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
455448
);
456449

457450
if (errRc != ESP_OK) {
458-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_register_for_notify: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
451+
log_e("esp_ble_gattc_register_for_notify: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
459452
}
460453

461454
uint8_t val[] = {0x01, 0x00};
@@ -471,7 +464,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
471464
);
472465

473466
if (errRc != ESP_OK) {
474-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_unregister_for_notify: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
467+
log_e("esp_ble_gattc_unregister_for_notify: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
475468
}
476469

477470
uint8_t val[] = {0x00, 0x00};
@@ -481,7 +474,7 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
481474

482475
m_semaphoreRegForNotifyEvt.wait("registerForNotify");
483476

484-
ESP_LOGD(LOG_TAG, "<< registerForNotify()");
477+
log_v("<< registerForNotify()");
485478
} // registerForNotify
486479

487480

@@ -547,11 +540,11 @@ void BLERemoteCharacteristic::writeValue(uint8_t newValue, bool response) {
547540
*/
548541
void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool response) {
549542
// writeValue(std::string((char*)data, length), response);
550-
ESP_LOGD(LOG_TAG, ">> writeValue(), length: %d", length);
543+
log_v(">> writeValue(), length: %d", length);
551544

552545
// Check to see that we are connected.
553546
if (!getRemoteService()->getClient()->isConnected()) {
554-
ESP_LOGE(LOG_TAG, "Disconnected");
547+
log_e("Disconnected");
555548
throw BLEDisconnectedException();
556549
}
557550

@@ -568,13 +561,13 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
568561
);
569562

570563
if (errRc != ESP_OK) {
571-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_write_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
564+
log_e("esp_ble_gattc_write_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
572565
return;
573566
}
574567

575568
m_semaphoreWriteCharEvt.wait("writeValue");
576569

577-
ESP_LOGD(LOG_TAG, "<< writeValue");
570+
log_v("<< writeValue");
578571
} // writeValue
579572

580573
/**

‎libraries/BLE/src/BLERemoteDescriptor.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
#include <sstream>
1010
#include "BLERemoteDescriptor.h"
1111
#include "GeneralUtils.h"
12-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1312
#include "esp32-hal-log.h"
14-
#define LOG_TAG ""
15-
#else
16-
#include "esp_log.h"
17-
static const char* LOG_TAG = "BLERemoteDescriptor";
18-
#endif
19-
20-
21-
2213

2314
BLERemoteDescriptor::BLERemoteDescriptor(
2415
uint16_t handle,
@@ -59,11 +50,11 @@ BLEUUID BLERemoteDescriptor::getUUID() {
5950

6051

6152
std::string BLERemoteDescriptor::readValue() {
62-
ESP_LOGD(LOG_TAG, ">> readValue: %s", toString().c_str());
53+
log_v(">> readValue: %s", toString().c_str());
6354

6455
// Check to see that we are connected.
6556
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
66-
ESP_LOGE(LOG_TAG, "Disconnected");
57+
log_e("Disconnected");
6758
throw BLEDisconnectedException();
6859
}
6960

@@ -77,15 +68,15 @@ std::string BLERemoteDescriptor::readValue() {
7768
ESP_GATT_AUTH_REQ_NONE); // Security
7869

7970
if (errRc != ESP_OK) {
80-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
71+
log_e("esp_ble_gattc_read_char: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
8172
return "";
8273
}
8374

8475
// Block waiting for the event that indicates that the read has completed. When it has, the std::string found
8576
// in m_value will contain our data.
8677
m_semaphoreReadDescrEvt.wait("readValue");
8778

88-
ESP_LOGD(LOG_TAG, "<< readValue(): length: %d", m_value.length());
79+
log_v("<< readValue(): length: %d", m_value.length());
8980
return m_value;
9081
} // readValue
9182

@@ -135,10 +126,10 @@ std::string BLERemoteDescriptor::toString() {
135126
* @param [in] response True if we expect a response.
136127
*/
137128
void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response) {
138-
ESP_LOGD(LOG_TAG, ">> writeValue: %s", toString().c_str());
129+
log_v(">> writeValue: %s", toString().c_str());
139130
// Check to see that we are connected.
140131
if (!getRemoteCharacteristic()->getRemoteService()->getClient()->isConnected()) {
141-
ESP_LOGE(LOG_TAG, "Disconnected");
132+
log_e("Disconnected");
142133
throw BLEDisconnectedException();
143134
}
144135

@@ -152,9 +143,9 @@ void BLERemoteDescriptor::writeValue(uint8_t* data, size_t length, bool response
152143
ESP_GATT_AUTH_REQ_NONE
153144
);
154145
if (errRc != ESP_OK) {
155-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_write_char_descr: %d", errRc);
146+
log_e("esp_ble_gattc_write_char_descr: %d", errRc);
156147
}
157-
ESP_LOGD(LOG_TAG, "<< writeValue");
148+
log_v("<< writeValue");
158149
} // writeValue
159150

160151

‎libraries/BLE/src/BLERemoteService.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
#include "BLEUtils.h"
1313
#include "GeneralUtils.h"
1414
#include <esp_err.h>
15-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1615
#include "esp32-hal-log.h"
17-
#define LOG_TAG ""
18-
#else
19-
#include "esp_log.h"
20-
static const char* LOG_TAG = "BLERemoteService";
21-
#endif
22-
23-
2416

2517
BLERemoteService::BLERemoteService(
2618
esp_gatt_id_t srvcId,
@@ -29,15 +21,15 @@ BLERemoteService::BLERemoteService(
2921
uint16_t endHandle
3022
) {
3123

32-
ESP_LOGD(LOG_TAG, ">> BLERemoteService()");
24+
log_v(">> BLERemoteService()");
3325
m_srvcId = srvcId;
3426
m_pClient = pClient;
3527
m_uuid = BLEUUID(m_srvcId);
3628
m_haveCharacteristics = false;
3729
m_startHandle = startHandle;
3830
m_endHandle = endHandle;
3931

40-
ESP_LOGD(LOG_TAG, "<< BLERemoteService()");
32+
log_v("<< BLERemoteService()");
4133
}
4234

4335

@@ -103,7 +95,7 @@ void BLERemoteService::gattClientEventHandler(
10395
&m_srvcId,
10496
&evtParam->get_char.char_id);
10597
if (errRc != ESP_OK) {
106-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_get_characteristic: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
98+
log_e("esp_ble_gattc_get_characteristic: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
10799
break;
108100
}
109101
@@ -165,7 +157,7 @@ BLERemoteCharacteristic* BLERemoteService::getCharacteristic(BLEUUID uuid) {
165157
* @return N/A
166158
*/
167159
void BLERemoteService::retrieveCharacteristics() {
168-
ESP_LOGD(LOG_TAG, ">> getCharacteristics() for service: %s", getUUID().toString().c_str());
160+
log_v(">> getCharacteristics() for service: %s", getUUID().toString().c_str());
169161

170162
removeCharacteristics(); // Forget any previous characteristics.
171163

@@ -188,15 +180,15 @@ void BLERemoteService::retrieveCharacteristics() {
188180
}
189181

190182
if (status != ESP_GATT_OK) { // If we got an error, end.
191-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_get_all_char: %s", BLEUtils::gattStatusToString(status).c_str());
183+
log_e("esp_ble_gattc_get_all_char: %s", BLEUtils::gattStatusToString(status).c_str());
192184
break;
193185
}
194186

195187
if (count == 0) { // If we failed to get any new records, end.
196188
break;
197189
}
198190

199-
ESP_LOGD(LOG_TAG, "Found a characteristic: Handle: %d, UUID: %s", result.char_handle, BLEUUID(result.uuid).toString().c_str());
191+
log_d("Found a characteristic: Handle: %d, UUID: %s", result.char_handle, BLEUUID(result.uuid).toString().c_str());
200192

201193
// We now have a new characteristic ... let us add that to our set of known characteristics
202194
BLERemoteCharacteristic *pNewRemoteCharacteristic = new BLERemoteCharacteristic(
@@ -212,7 +204,7 @@ void BLERemoteService::retrieveCharacteristics() {
212204
} // Loop forever (until we break inside the loop).
213205

214206
m_haveCharacteristics = true; // Remember that we have received the characteristics.
215-
ESP_LOGD(LOG_TAG, "<< getCharacteristics()");
207+
log_v("<< getCharacteristics()");
216208
} // getCharacteristics
217209

218210

@@ -221,14 +213,14 @@ void BLERemoteService::retrieveCharacteristics() {
221213
* @return A map of all the characteristics of this service.
222214
*/
223215
std::map<std::string, BLERemoteCharacteristic*>* BLERemoteService::getCharacteristics() {
224-
ESP_LOGD(LOG_TAG, ">> getCharacteristics() for service: %s", getUUID().toString().c_str());
216+
log_v(">> getCharacteristics() for service: %s", getUUID().toString().c_str());
225217
// If is possible that we have not read the characteristics associated with the service so do that
226218
// now. The request to retrieve the characteristics by calling "retrieveCharacteristics" is a blocking
227219
// call and does not return until all the characteristics are available.
228220
if (!m_haveCharacteristics) {
229221
retrieveCharacteristics();
230222
}
231-
ESP_LOGD(LOG_TAG, "<< getCharacteristics() for service: %s", getUUID().toString().c_str());
223+
log_v("<< getCharacteristics() for service: %s", getUUID().toString().c_str());
232224
return &m_characteristicMap;
233225
} // getCharacteristics
234226

@@ -265,8 +257,8 @@ uint16_t BLERemoteService::getStartHandle() {
265257

266258

267259
uint16_t BLERemoteService::getHandle() {
268-
ESP_LOGD(LOG_TAG, ">> getHandle: service: %s", getUUID().toString().c_str());
269-
ESP_LOGD(LOG_TAG, "<< getHandle: %d 0x%.2x", getStartHandle(), getStartHandle());
260+
log_v(">> getHandle: service: %s", getUUID().toString().c_str());
261+
log_v("<< getHandle: %d 0x%.2x", getStartHandle(), getStartHandle());
270262
return getStartHandle();
271263
} // getHandle
272264

@@ -279,9 +271,9 @@ BLEUUID BLERemoteService::getUUID() {
279271
* @brief Read the value of a characteristic associated with this service.
280272
*/
281273
std::string BLERemoteService::getValue(BLEUUID characteristicUuid) {
282-
ESP_LOGD(LOG_TAG, ">> readValue: uuid: %s", characteristicUuid.toString().c_str());
274+
log_v(">> readValue: uuid: %s", characteristicUuid.toString().c_str());
283275
std::string ret = getCharacteristic(characteristicUuid)->readValue();
284-
ESP_LOGD(LOG_TAG, "<< readValue");
276+
log_v("<< readValue");
285277
return ret;
286278
} // readValue
287279

@@ -314,9 +306,9 @@ void BLERemoteService::removeCharacteristics() {
314306
* @throws BLEUuidNotFound
315307
*/
316308
void BLERemoteService::setValue(BLEUUID characteristicUuid, std::string value) {
317-
ESP_LOGD(LOG_TAG, ">> setValue: uuid: %s", characteristicUuid.toString().c_str());
309+
log_v(">> setValue: uuid: %s", characteristicUuid.toString().c_str());
318310
getCharacteristic(characteristicUuid)->writeValue(value);
319-
ESP_LOGD(LOG_TAG, "<< setValue");
311+
log_v("<< setValue");
320312
} // setValue
321313

322314

‎libraries/BLE/src/BLEScan.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,7 @@
1616
#include "BLEScan.h"
1717
#include "BLEUtils.h"
1818
#include "GeneralUtils.h"
19-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2019
#include "esp32-hal-log.h"
21-
#define LOG_TAG ""
22-
#else
23-
#include "esp_log.h"
24-
static const char* LOG_TAG = "BLEScan";
25-
#endif
26-
27-
28-
2920

3021
/**
3122
* Constructor
@@ -75,7 +66,7 @@ void BLEScan::handleGAPEvent(
7566
// Event that indicates that the duration allowed for the search has completed or that we have been
7667
// asked to stop.
7768
case ESP_GAP_SEARCH_INQ_CMPL_EVT: {
78-
ESP_LOGW(LOG_TAG, "ESP_GAP_SEARCH_INQ_CMPL_EVT");
69+
log_w("ESP_GAP_SEARCH_INQ_CMPL_EVT");
7970
m_stopped = true;
8071
m_semaphoreScanEnd.give();
8172
if (m_scanCompleteCB != nullptr) {
@@ -103,15 +94,15 @@ void BLEScan::handleGAPEvent(
10394
}
10495

10596
if (found && !m_wantDuplicates) { // If we found a previous entry AND we don't want duplicates, then we are done.
106-
ESP_LOGD(LOG_TAG, "Ignoring %s, already seen it.", advertisedAddress.toString().c_str());
97+
log_d("Ignoring %s, already seen it.", advertisedAddress.toString().c_str());
10798
vTaskDelay(1); // <--- allow to switch task in case we scan infinity and dont have new devices to report, or we are blocked here
10899
break;
109100
}
110101

111102
// We now construct a model of the advertised device that we have just found for the first
112103
// time.
113-
// ESP_LOG_BUFFER_HEXDUMP(LOG_TAG, (uint8_t*)param->scan_rst.ble_adv, param->scan_rst.adv_data_len + param->scan_rst.scan_rsp_len, ESP_LOG_DEBUG);
114-
// ESP_LOGW(LOG_TAG, "bytes length: %d + %d, addr type: %d", param->scan_rst.adv_data_len, param->scan_rst.scan_rsp_len, param->scan_rst.ble_addr_type);
104+
// ESP_LOG_BUFFER_HEXDUMP((uint8_t*)param->scan_rst.ble_adv, param->scan_rst.adv_data_len + param->scan_rst.scan_rsp_len, ESP_LOG_DEBUG);
105+
// log_w("bytes length: %d + %d, addr type: %d", param->scan_rst.adv_data_len, param->scan_rst.scan_rsp_len, param->scan_rst.ble_addr_type);
115106
BLEAdvertisedDevice *advertisedDevice = new BLEAdvertisedDevice();
116107
advertisedDevice->setAddress(advertisedAddress);
117108
advertisedDevice->setRSSI(param->scan_rst.rssi);
@@ -201,7 +192,7 @@ void BLEScan::setWindow(uint16_t windowMSecs) {
201192
* @return True if scan started or false if there was an error.
202193
*/
203194
bool BLEScan::start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), bool is_continue) {
204-
ESP_LOGD(LOG_TAG, ">> start(duration=%d)", duration);
195+
log_v(">> start(duration=%d)", duration);
205196

206197
m_semaphoreScanEnd.take(std::string("start"));
207198
m_scanCompleteCB = scanCompleteCB; // Save the callback to be invoked when the scan completes.
@@ -218,22 +209,22 @@ bool BLEScan::start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), b
218209
esp_err_t errRc = ::esp_ble_gap_set_scan_params(&m_scan_params);
219210

220211
if (errRc != ESP_OK) {
221-
ESP_LOGE(LOG_TAG, "esp_ble_gap_set_scan_params: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
212+
log_e("esp_ble_gap_set_scan_params: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
222213
m_semaphoreScanEnd.give();
223214
return false;
224215
}
225216

226217
errRc = ::esp_ble_gap_start_scanning(duration);
227218

228219
if (errRc != ESP_OK) {
229-
ESP_LOGE(LOG_TAG, "esp_ble_gap_start_scanning: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
220+
log_e("esp_ble_gap_start_scanning: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
230221
m_semaphoreScanEnd.give();
231222
return false;
232223
}
233224

234225
m_stopped = false;
235226

236-
ESP_LOGD(LOG_TAG, "<< start()");
227+
log_v("<< start()");
237228
return true;
238229
} // start
239230

@@ -256,24 +247,24 @@ BLEScanResults BLEScan::start(uint32_t duration, bool is_continue) {
256247
* @return N/A.
257248
*/
258249
void BLEScan::stop() {
259-
ESP_LOGD(LOG_TAG, ">> stop()");
250+
log_v(">> stop()");
260251

261252
esp_err_t errRc = ::esp_ble_gap_stop_scanning();
262253

263254
m_stopped = true;
264255
m_semaphoreScanEnd.give();
265256

266257
if (errRc != ESP_OK) {
267-
ESP_LOGE(LOG_TAG, "esp_ble_gap_stop_scanning: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
258+
log_e("esp_ble_gap_stop_scanning: err: %d, text: %s", errRc, GeneralUtils::errorToString(errRc));
268259
return;
269260
}
270261

271-
ESP_LOGD(LOG_TAG, "<< stop()");
262+
log_v("<< stop()");
272263
} // stop
273264

274265
// delete peer device from cache after disconnecting, it is required in case we are connecting to devices with not public address
275266
void BLEScan::erase(BLEAddress address) {
276-
ESP_LOGI(LOG_TAG, "erase device: %s", address.toString().c_str());
267+
log_i("erase device: %s", address.toString().c_str());
277268
BLEAdvertisedDevice *advertisedDevice = m_scanResults.m_vectorAdvertisedDevices.find(address.toString())->second;
278269
m_scanResults.m_vectorAdvertisedDevices.erase(address.toString());
279270
delete advertisedDevice;
@@ -284,9 +275,9 @@ void BLEScan::erase(BLEAddress address) {
284275
* @brief Dump the scan results to the log.
285276
*/
286277
void BLEScanResults::dump() {
287-
ESP_LOGD(LOG_TAG, ">> Dump scan results:");
278+
log_v(">> Dump scan results:");
288279
for (int i=0; i<getCount(); i++) {
289-
ESP_LOGD(LOG_TAG, "- %s", getDevice(i).toString().c_str());
280+
log_d("- %s", getDevice(i).toString().c_str());
290281
}
291282
} // dump
292283

‎libraries/BLE/src/BLEServer.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@
1717
#include <string.h>
1818
#include <string>
1919
#include <unordered_set>
20-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2120
#include "esp32-hal-log.h"
22-
#define LOG_TAG ""
23-
#else
24-
#include "esp_log.h"
25-
static const char* LOG_TAG = "BLEServer";
26-
#endif
27-
28-
29-
3021

3122
/**
3223
* @brief Construct a %BLE Server
@@ -73,12 +64,12 @@ BLEService* BLEServer::createService(const char* uuid) {
7364
* @return A reference to the new service object.
7465
*/
7566
BLEService* BLEServer::createService(BLEUUID uuid, uint32_t numHandles, uint8_t inst_id) {
76-
ESP_LOGD(LOG_TAG, ">> createService - %s", uuid.toString().c_str());
67+
log_v(">> createService - %s", uuid.toString().c_str());
7768
m_semaphoreCreateEvt.take("createService");
7869

7970
// Check that a service with the supplied UUID does not already exist.
8071
if (m_serviceMap.getByUUID(uuid) != nullptr) {
81-
ESP_LOGW(LOG_TAG, "<< Attempt to create a new service with uuid %s but a service with that UUID already exists.",
72+
log_w("<< Attempt to create a new service with uuid %s but a service with that UUID already exists.",
8273
uuid.toString().c_str());
8374
}
8475

@@ -89,7 +80,7 @@ BLEService* BLEServer::createService(BLEUUID uuid, uint32_t numHandles, uint8_t
8980

9081
m_semaphoreCreateEvt.wait("createService");
9182

92-
ESP_LOGD(LOG_TAG, "<< createService");
83+
log_v("<< createService");
9384
return pService;
9485
} // createService
9586

@@ -149,7 +140,7 @@ uint16_t BLEServer::getGattsIf() {
149140
*
150141
*/
151142
void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t* param) {
152-
ESP_LOGD(LOG_TAG, ">> handleGATTServerEvent: %s",
143+
log_v(">> handleGATTServerEvent: %s",
153144
BLEUtils::gattServerEventTypeToString(event).c_str());
154145

155146
switch(event) {
@@ -277,7 +268,7 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t
277268
// Invoke the handler for every Service we have.
278269
m_serviceMap.handleGATTServerEvent(event, gatts_if, param);
279270

280-
ESP_LOGD(LOG_TAG, "<< handleGATTServerEvent");
271+
log_v("<< handleGATTServerEvent");
281272
} // handleGATTServerEvent
282273

283274

@@ -287,11 +278,11 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t
287278
* @return N/A
288279
*/
289280
void BLEServer::registerApp(uint16_t m_appId) {
290-
ESP_LOGD(LOG_TAG, ">> registerApp - %d", m_appId);
281+
log_v(">> registerApp - %d", m_appId);
291282
m_semaphoreRegisterAppEvt.take("registerApp"); // Take the mutex, will be released by ESP_GATTS_REG_EVT event.
292283
::esp_ble_gatts_app_register(m_appId);
293284
m_semaphoreRegisterAppEvt.wait("registerApp");
294-
ESP_LOGD(LOG_TAG, "<< registerApp");
285+
log_v("<< registerApp");
295286
} // registerApp
296287

297288

@@ -324,9 +315,9 @@ void BLEServer::removeService(BLEService* service) {
324315
* retrieving the advertising object and invoking start upon it.
325316
*/
326317
void BLEServer::startAdvertising() {
327-
ESP_LOGD(LOG_TAG, ">> startAdvertising");
318+
log_v(">> startAdvertising");
328319
BLEDevice::startAdvertising();
329-
ESP_LOGD(LOG_TAG, "<< startAdvertising");
320+
log_v("<< startAdvertising");
330321
} // startAdvertising
331322

332323
/**
@@ -344,34 +335,34 @@ bool BLEServer::connect(BLEAddress address) {
344335
1 // direct connection
345336
);
346337
if (errRc != ESP_OK) {
347-
ESP_LOGE(LOG_TAG, "esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
338+
log_e("esp_ble_gattc_open: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
348339
return false;
349340
}
350341

351342
uint32_t rc = m_semaphoreOpenEvt.wait("connect"); // Wait for the connection to complete.
352-
ESP_LOGD(LOG_TAG, "<< connect(), rc=%d", rc==ESP_GATT_OK);
343+
log_v("<< connect(), rc=%d", rc==ESP_GATT_OK);
353344
return rc == ESP_GATT_OK;
354345
} // connect
355346

356347

357348

358349
void BLEServerCallbacks::onConnect(BLEServer* pServer) {
359-
ESP_LOGD("BLEServerCallbacks", ">> onConnect(): Default");
360-
ESP_LOGD("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
361-
ESP_LOGD("BLEServerCallbacks", "<< onConnect()");
350+
log_d("BLEServerCallbacks", ">> onConnect(): Default");
351+
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
352+
log_d("BLEServerCallbacks", "<< onConnect()");
362353
} // onConnect
363354

364355
void BLEServerCallbacks::onConnect(BLEServer* pServer, esp_ble_gatts_cb_param_t* param) {
365-
ESP_LOGD("BLEServerCallbacks", ">> onConnect(): Default");
366-
ESP_LOGD("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
367-
ESP_LOGD("BLEServerCallbacks", "<< onConnect()");
356+
log_d("BLEServerCallbacks", ">> onConnect(): Default");
357+
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
358+
log_d("BLEServerCallbacks", "<< onConnect()");
368359
} // onConnect
369360

370361

371362
void BLEServerCallbacks::onDisconnect(BLEServer* pServer) {
372-
ESP_LOGD("BLEServerCallbacks", ">> onDisconnect(): Default");
373-
ESP_LOGD("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
374-
ESP_LOGD("BLEServerCallbacks", "<< onDisconnect()");
363+
log_d("BLEServerCallbacks", ">> onDisconnect(): Default");
364+
log_d("BLEServerCallbacks", "Device: %s", BLEDevice::toString().c_str());
365+
log_d("BLEServerCallbacks", "<< onDisconnect()");
375366
} // onDisconnect
376367

377368
/* multi connect support */

‎libraries/BLE/src/BLEService.cpp

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
#include "BLEService.h"
2121
#include "BLEUtils.h"
2222
#include "GeneralUtils.h"
23-
24-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2523
#include "esp32-hal-log.h"
26-
#define LOG_TAG ""
27-
#else
28-
#include "esp_log.h"
29-
static const char* LOG_TAG = "BLEService"; // Tag for logging.
30-
#endif
3124

3225
#define NULL_HANDLE (0xffff)
3326

@@ -64,7 +57,7 @@ BLEService::BLEService(BLEUUID uuid, uint16_t numHandles) {
6457
*/
6558

6659
void BLEService::executeCreate(BLEServer* pServer) {
67-
ESP_LOGD(LOG_TAG, ">> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: %s", getUUID().toString().c_str());
60+
log_v(">> executeCreate() - Creating service (esp_ble_gatts_create_service) service uuid: %s", getUUID().toString().c_str());
6861
m_pServer = pServer;
6962
m_semaphoreCreateEvt.take("executeCreate"); // Take the mutex and release at event ESP_GATTS_CREATE_EVT
7063

@@ -75,12 +68,12 @@ void BLEService::executeCreate(BLEServer* pServer) {
7568
esp_err_t errRc = ::esp_ble_gatts_create_service(getServer()->getGattsIf(), &srvc_id, m_numHandles); // The maximum number of handles associated with the service.
7669

7770
if (errRc != ESP_OK) {
78-
ESP_LOGE(LOG_TAG, "esp_ble_gatts_create_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
71+
log_e("esp_ble_gatts_create_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
7972
return;
8073
}
8174

8275
m_semaphoreCreateEvt.wait("executeCreate");
83-
ESP_LOGD(LOG_TAG, "<< executeCreate");
76+
log_v("<< executeCreate");
8477
} // executeCreate
8578

8679

@@ -91,18 +84,18 @@ void BLEService::executeCreate(BLEServer* pServer) {
9184
*/
9285

9386
void BLEService::executeDelete() {
94-
ESP_LOGD(LOG_TAG, ">> executeDelete()");
87+
log_v(">> executeDelete()");
9588
m_semaphoreDeleteEvt.take("executeDelete"); // Take the mutex and release at event ESP_GATTS_DELETE_EVT
9689

9790
esp_err_t errRc = ::esp_ble_gatts_delete_service(getHandle());
9891

9992
if (errRc != ESP_OK) {
100-
ESP_LOGE(LOG_TAG, "esp_ble_gatts_delete_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
93+
log_e("esp_ble_gatts_delete_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
10194
return;
10295
}
10396

10497
m_semaphoreDeleteEvt.wait("executeDelete");
105-
ESP_LOGD(LOG_TAG, "<< executeDelete");
98+
log_v("<< executeDelete");
10699
} // executeDelete
107100

108101

@@ -111,10 +104,10 @@ void BLEService::executeDelete() {
111104
* @return N/A.
112105
*/
113106
void BLEService::dump() {
114-
ESP_LOGD(LOG_TAG, "Service: uuid:%s, handle: 0x%.2x",
107+
log_d("Service: uuid:%s, handle: 0x%.2x",
115108
m_uuid.toString().c_str(),
116109
m_handle);
117-
ESP_LOGD(LOG_TAG, "Characteristics:\n%s", m_characteristicMap.toString().c_str());
110+
log_d("Characteristics:\n%s", m_characteristicMap.toString().c_str());
118111
} // dump
119112

120113

@@ -138,9 +131,9 @@ void BLEService::start() {
138131
// We start the service through its local handle which was returned in the ESP_GATTS_CREATE_EVT event
139132
// obtained as a result of calling esp_ble_gatts_create_service().
140133
//
141-
ESP_LOGD(LOG_TAG, ">> start(): Starting service (esp_ble_gatts_start_service): %s", toString().c_str());
134+
log_v(">> start(): Starting service (esp_ble_gatts_start_service): %s", toString().c_str());
142135
if (m_handle == NULL_HANDLE) {
143-
ESP_LOGE(LOG_TAG, "<< !!! We attempted to start a service but don't know its handle!");
136+
log_e("<< !!! We attempted to start a service but don't know its handle!");
144137
return;
145138
}
146139

@@ -158,12 +151,12 @@ void BLEService::start() {
158151
esp_err_t errRc = ::esp_ble_gatts_start_service(m_handle);
159152

160153
if (errRc != ESP_OK) {
161-
ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_start_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
154+
log_e("<< esp_ble_gatts_start_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
162155
return;
163156
}
164157
m_semaphoreStartEvt.wait("start");
165158

166-
ESP_LOGD(LOG_TAG, "<< start()");
159+
log_v("<< start()");
167160
} // start
168161

169162

@@ -174,22 +167,22 @@ void BLEService::stop() {
174167
// We ask the BLE runtime to start the service and then create each of the characteristics.
175168
// We start the service through its local handle which was returned in the ESP_GATTS_CREATE_EVT event
176169
// obtained as a result of calling esp_ble_gatts_create_service().
177-
ESP_LOGD(LOG_TAG, ">> stop(): Stopping service (esp_ble_gatts_stop_service): %s", toString().c_str());
170+
log_v(">> stop(): Stopping service (esp_ble_gatts_stop_service): %s", toString().c_str());
178171
if (m_handle == NULL_HANDLE) {
179-
ESP_LOGE(LOG_TAG, "<< !!! We attempted to stop a service but don't know its handle!");
172+
log_e("<< !!! We attempted to stop a service but don't know its handle!");
180173
return;
181174
}
182175

183176
m_semaphoreStopEvt.take("stop");
184177
esp_err_t errRc = ::esp_ble_gatts_stop_service(m_handle);
185178

186179
if (errRc != ESP_OK) {
187-
ESP_LOGE(LOG_TAG, "<< esp_ble_gatts_stop_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
180+
log_e("<< esp_ble_gatts_stop_service: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
188181
return;
189182
}
190183
m_semaphoreStopEvt.wait("stop");
191184

192-
ESP_LOGD(LOG_TAG, "<< stop()");
185+
log_v("<< stop()");
193186
} // start
194187

195188

@@ -198,13 +191,13 @@ void BLEService::stop() {
198191
* @param [in] handle The handle associated with the service.
199192
*/
200193
void BLEService::setHandle(uint16_t handle) {
201-
ESP_LOGD(LOG_TAG, ">> setHandle - Handle=0x%.2x, service UUID=%s)", handle, getUUID().toString().c_str());
194+
log_v(">> setHandle - Handle=0x%.2x, service UUID=%s)", handle, getUUID().toString().c_str());
202195
if (m_handle != NULL_HANDLE) {
203-
ESP_LOGE(LOG_TAG, "!!! Handle is already set %.2x", m_handle);
196+
log_e("!!! Handle is already set %.2x", m_handle);
204197
return;
205198
}
206199
m_handle = handle;
207-
ESP_LOGD(LOG_TAG, "<< setHandle");
200+
log_v("<< setHandle");
208201
} // setHandle
209202

210203

@@ -226,22 +219,22 @@ void BLEService::addCharacteristic(BLECharacteristic* pCharacteristic) {
226219
// BLECharacteristicMap class instance found in m_characteristicMap. We add the characteristic
227220
// to the map and then ask the service to add the characteristic at the BLE level (ESP-IDF).
228221

229-
ESP_LOGD(LOG_TAG, ">> addCharacteristic()");
230-
ESP_LOGD(LOG_TAG, "Adding characteristic: uuid=%s to service: %s",
222+
log_v(">> addCharacteristic()");
223+
log_d("Adding characteristic: uuid=%s to service: %s",
231224
pCharacteristic->getUUID().toString().c_str(),
232225
toString().c_str());
233226

234227
// Check that we don't add the same characteristic twice.
235228
if (m_characteristicMap.getByUUID(pCharacteristic->getUUID()) != nullptr) {
236-
ESP_LOGW(LOG_TAG, "<< Adding a new characteristic with the same UUID as a previous one");
229+
log_w("<< Adding a new characteristic with the same UUID as a previous one");
237230
//return;
238231
}
239232

240233
// Remember this characteristic in our map of characteristics. At this point, we can lookup by UUID
241234
// but not by handle. The handle is allocated to us on the ESP_GATTS_ADD_CHAR_EVT.
242235
m_characteristicMap.setByUUID(pCharacteristic, pCharacteristic->getUUID());
243236

244-
ESP_LOGD(LOG_TAG, "<< addCharacteristic()");
237+
log_v("<< addCharacteristic()");
245238
} // addCharacteristic
246239

247240

@@ -287,7 +280,7 @@ void BLEService::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t
287280
if (m_handle == param->add_char.service_handle) {
288281
BLECharacteristic *pCharacteristic = getLastCreatedCharacteristic();
289282
if (pCharacteristic == nullptr) {
290-
ESP_LOGE(LOG_TAG, "Expected to find characteristic with UUID: %s, but didnt!",
283+
log_e("Expected to find characteristic with UUID: %s, but didnt!",
291284
BLEUUID(param->add_char.char_uuid).toString().c_str());
292285
dump();
293286
break;

‎libraries/BLE/src/BLEUUID.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@
1313
#include <assert.h>
1414
#include <stdlib.h>
1515
#include "BLEUUID.h"
16-
17-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1816
#include "esp32-hal-log.h"
19-
#define LOG_TAG ""
20-
#else
21-
#include "esp_log.h"
22-
static const char* LOG_TAG = "BLEUUID";
23-
#endif
24-
2517

2618
/**
2719
* @brief Copy memory from source to target but in reverse order.
@@ -121,7 +113,7 @@ BLEUUID::BLEUUID(std::string value) {
121113
}
122114
}
123115
else {
124-
ESP_LOGE(LOG_TAG, "ERROR: UUID value not 2, 4, 16 or 36 bytes");
116+
log_e("ERROR: UUID value not 2, 4, 16 or 36 bytes");
125117
m_valueSet = false;
126118
}
127119
} //BLEUUID(std::string)
@@ -136,7 +128,7 @@ BLEUUID::BLEUUID(std::string value) {
136128
*/
137129
BLEUUID::BLEUUID(uint8_t* pData, size_t size, bool msbFirst) {
138130
if (size != 16) {
139-
ESP_LOGE(LOG_TAG, "ERROR: UUID length not 16 bytes");
131+
log_e("ERROR: UUID length not 16 bytes");
140132
return;
141133
}
142134
m_uuid.len = ESP_UUID_LEN_128;
@@ -212,7 +204,7 @@ uint8_t BLEUUID::bitSize() {
212204
case ESP_UUID_LEN_128:
213205
return 128;
214206
default:
215-
ESP_LOGE(LOG_TAG, "Unknown UUID length: %d", m_uuid.len);
207+
log_e("Unknown UUID length: %d", m_uuid.len);
216208
return 0;
217209
} // End of switch
218210
} // bitSize
@@ -225,7 +217,7 @@ uint8_t BLEUUID::bitSize() {
225217
* @return True if the UUIDs are equal and false otherwise.
226218
*/
227219
bool BLEUUID::equals(BLEUUID uuid) {
228-
//ESP_LOGD(TAG, "Comparing: %s to %s", toString().c_str(), uuid.toString().c_str());
220+
//log_d("Comparing: %s to %s", toString().c_str(), uuid.toString().c_str());
229221
if (!m_valueSet || !uuid.m_valueSet) return false;
230222

231223
if (uuid.m_uuid.len != m_uuid.len) {
@@ -279,12 +271,12 @@ BLEUUID BLEUUID::fromString(std::string _uuid) {
279271
* @return The native UUID value or NULL if not set.
280272
*/
281273
esp_bt_uuid_t* BLEUUID::getNative() {
282-
//ESP_LOGD(TAG, ">> getNative()")
274+
//log_d(">> getNative()")
283275
if (m_valueSet == false) {
284-
ESP_LOGD(LOG_TAG, "<< Return of un-initialized UUID!");
276+
log_v("<< Return of un-initialized UUID!");
285277
return nullptr;
286278
}
287-
//ESP_LOGD(TAG, "<< getNative()");
279+
//log_d("<< getNative()");
288280
return &m_uuid;
289281
} // getNative
290282

@@ -296,7 +288,7 @@ esp_bt_uuid_t* BLEUUID::getNative() {
296288
* will convert 16 or 32 bit representations to the full 128bit.
297289
*/
298290
BLEUUID BLEUUID::to128() {
299-
//ESP_LOGD(LOG_TAG, ">> toFull() - %s", toString().c_str());
291+
//log_v(">> toFull() - %s", toString().c_str());
300292

301293
// If we either don't have a value or are already a 128 bit UUID, nothing further to do.
302294
if (!m_valueSet || m_uuid.len == ESP_UUID_LEN_128) {
@@ -338,7 +330,7 @@ BLEUUID BLEUUID::to128() {
338330
m_uuid.uuid.uuid128[0] = 0xfb;
339331

340332
m_uuid.len = ESP_UUID_LEN_128;
341-
//ESP_LOGD(TAG, "<< toFull <- %s", toString().c_str());
333+
//log_d("<< toFull <- %s", toString().c_str());
342334
return *this;
343335
} // to128
344336

‎libraries/BLE/src/BLEUtils.cpp

Lines changed: 58 additions & 65 deletions
Large diffs are not rendered by default.

‎libraries/BLE/src/BLEValue.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77
#include "sdkconfig.h"
88
#if defined(CONFIG_BT_ENABLED)
99
#include "BLEValue.h"
10-
11-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1210
#include "esp32-hal-log.h"
13-
#define LOG_TAG ""
14-
#else
15-
#include "esp_log.h"
16-
static const char* LOG_TAG="BLEValue";
17-
#endif
18-
19-
2011

2112
BLEValue::BLEValue() {
2213
m_accumulation = "";
@@ -31,7 +22,7 @@ BLEValue::BLEValue() {
3122
* @param [in] part A message part being added.
3223
*/
3324
void BLEValue::addPart(std::string part) {
34-
ESP_LOGD(LOG_TAG, ">> addPart: length=%d", part.length());
25+
log_v(">> addPart: length=%d", part.length());
3526
m_accumulation += part;
3627
} // addPart
3728

@@ -43,7 +34,7 @@ void BLEValue::addPart(std::string part) {
4334
* @param [in] length The number of bytes being added.
4435
*/
4536
void BLEValue::addPart(uint8_t* pData, size_t length) {
46-
ESP_LOGD(LOG_TAG, ">> addPart: length=%d", length);
37+
log_v(">> addPart: length=%d", length);
4738
m_accumulation += std::string((char*) pData, length);
4839
} // addPart
4940

@@ -52,7 +43,7 @@ void BLEValue::addPart(uint8_t* pData, size_t length) {
5243
* @brief Cancel the current accumulation.
5344
*/
5445
void BLEValue::cancel() {
55-
ESP_LOGD(LOG_TAG, ">> cancel");
46+
log_v(">> cancel");
5647
m_accumulation = "";
5748
m_readOffset = 0;
5849
} // cancel
@@ -65,7 +56,7 @@ void BLEValue::cancel() {
6556
* we now have the complete message and commit the change as a unit.
6657
*/
6758
void BLEValue::commit() {
68-
ESP_LOGD(LOG_TAG, ">> commit");
59+
log_v(">> commit");
6960
// If there is nothing to commit, do nothing.
7061
if (m_accumulation.length() == 0) return;
7162
setValue(m_accumulation);

‎libraries/BLE/src/FreeRTOS.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@
1212
#include <iomanip>
1313
#include "FreeRTOS.h"
1414
#include "sdkconfig.h"
15-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
1615
#include "esp32-hal-log.h"
17-
#define LOG_TAG ""
18-
#else
19-
#include "esp_log.h"
20-
static const char* LOG_TAG = "FreeRTOS";
21-
#endif
22-
2316

2417
/**
2518
* Sleep for the specified number of milliseconds.
@@ -67,7 +60,7 @@ uint32_t FreeRTOS::getTimeSinceStart() {
6760
* @return The value associated with the semaphore.
6861
*/
6962
uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
70-
ESP_LOGV(LOG_TAG, ">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
63+
log_v(">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
7164

7265
if (m_usePthreads) {
7366
pthread_mutex_lock(&m_pthread_mutex);
@@ -83,7 +76,7 @@ uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
8376
xSemaphoreGive(m_semaphore);
8477
}
8578

86-
ESP_LOGV(LOG_TAG, "<< wait: Semaphore released: %s", toString().c_str());
79+
log_v("<< wait: Semaphore released: %s", toString().c_str());
8780
m_owner = std::string("<N/A>");
8881
return m_value;
8982
} // wait
@@ -117,7 +110,7 @@ FreeRTOS::Semaphore::~Semaphore() {
117110
* The Semaphore is given.
118111
*/
119112
void FreeRTOS::Semaphore::give() {
120-
ESP_LOGV(LOG_TAG, "Semaphore giving: %s", toString().c_str());
113+
log_v("Semaphore giving: %s", toString().c_str());
121114
if (m_usePthreads) {
122115
pthread_mutex_unlock(&m_pthread_mutex);
123116
} else {
@@ -162,7 +155,7 @@ void FreeRTOS::Semaphore::giveFromISR() {
162155
* @return True if we took the semaphore.
163156
*/
164157
bool FreeRTOS::Semaphore::take(std::string owner) {
165-
ESP_LOGD(LOG_TAG, "Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
158+
log_d("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
166159
bool rc = false;
167160
if (m_usePthreads) {
168161
pthread_mutex_lock(&m_pthread_mutex);
@@ -171,9 +164,9 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
171164
}
172165
m_owner = owner;
173166
if (rc) {
174-
ESP_LOGD(LOG_TAG, "Semaphore taken: %s", toString().c_str());
167+
log_d("Semaphore taken: %s", toString().c_str());
175168
} else {
176-
ESP_LOGE(LOG_TAG, "Semaphore NOT taken: %s", toString().c_str());
169+
log_e("Semaphore NOT taken: %s", toString().c_str());
177170
}
178171
return rc;
179172
} // Semaphore::take
@@ -187,7 +180,7 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
187180
* @return True if we took the semaphore.
188181
*/
189182
bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
190-
ESP_LOGV(LOG_TAG, "Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
183+
log_v("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
191184
bool rc = false;
192185
if (m_usePthreads) {
193186
assert(false); // We apparently don't have a timed wait for pthreads.
@@ -196,9 +189,9 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
196189
}
197190
m_owner = owner;
198191
if (rc) {
199-
ESP_LOGV(LOG_TAG, "Semaphore taken: %s", toString().c_str());
192+
log_v("Semaphore taken: %s", toString().c_str());
200193
} else {
201-
ESP_LOGE(LOG_TAG, "Semaphore NOT taken: %s", toString().c_str());
194+
log_e("Semaphore NOT taken: %s", toString().c_str());
202195
}
203196
return rc;
204197
} // Semaphore::take

‎libraries/BLE/src/GeneralUtils.cpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@
1818
#include <esp_wifi.h>
1919
#include <esp_heap_caps.h>
2020
#include <esp_system.h>
21-
22-
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
2321
#include "esp32-hal-log.h"
24-
#define LOG_TAG ""
25-
#else
26-
#include "esp_log.h"
27-
static const char* LOG_TAG = "GeneralUtils";
28-
#endif
29-
3022

3123
static const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3224
"abcdefghijklmnopqrstuvwxyz"
@@ -115,11 +107,11 @@ void GeneralUtils::dumpInfo() {
115107
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_8BIT);
116108
esp_chip_info_t chipInfo;
117109
esp_chip_info(&chipInfo);
118-
ESP_LOGV(LOG_TAG, "--- dumpInfo ---");
119-
ESP_LOGV(LOG_TAG, "Free heap: %d", freeHeap);
120-
ESP_LOGV(LOG_TAG, "Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
121-
ESP_LOGV(LOG_TAG, "ESP-IDF version: %s", esp_get_idf_version());
122-
ESP_LOGV(LOG_TAG, "---");
110+
log_v("--- dumpInfo ---");
111+
log_v("Free heap: %d", freeHeap);
112+
log_v("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
113+
log_v("ESP-IDF version: %s", esp_get_idf_version());
114+
log_v("---");
123115
} // dumpInfo
124116

125117

@@ -237,7 +229,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
237229
if (index % 16 == 0) {
238230
strcpy(hexBuf, hex.str().c_str());
239231
strcpy(asciiBuf, ascii.str().c_str());
240-
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
232+
log_v("%s %s", hexBuf, asciiBuf);
241233
hex.str("");
242234
ascii.str("");
243235
}
@@ -249,8 +241,8 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
249241
}
250242
strcpy(hexBuf, hex.str().c_str());
251243
strcpy(asciiBuf, ascii.str().c_str());
252-
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
253-
//ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
244+
log_v("%s %s", hexBuf, asciiBuf);
245+
//log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
254246
}
255247
FreeRTOS::sleep(1000);
256248
}
@@ -272,7 +264,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
272264
}
273265
index++;
274266
if (index % 16 == 0) {
275-
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
267+
log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
276268
hex.str("");
277269
ascii.str("");
278270
}
@@ -282,7 +274,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
282274
hex << " ";
283275
index++;
284276
}
285-
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
277+
log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
286278
}
287279
FreeRTOS::sleep(1000);
288280
}
@@ -302,8 +294,8 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
302294
char tempBuf[80];
303295
uint32_t lineNumber = 0;
304296

305-
ESP_LOGV(LOG_TAG, " 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
306-
ESP_LOGV(LOG_TAG, " -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
297+
log_v(" 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
298+
log_v(" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
307299
strcpy(ascii, "");
308300
strcpy(hex, "");
309301
uint32_t index = 0;
@@ -318,7 +310,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
318310
strcat(ascii, tempBuf);
319311
index++;
320312
if (index % 16 == 0) {
321-
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber * 16, hex, ascii);
313+
log_v("%.4x %s %s", lineNumber * 16, hex, ascii);
322314
strcpy(ascii, "");
323315
strcpy(hex, "");
324316
lineNumber++;
@@ -329,7 +321,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
329321
strcat(hex, " ");
330322
index++;
331323
}
332-
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber * 16, hex, ascii);
324+
log_v("%.4x %s %s", lineNumber * 16, hex, ascii);
333325
}
334326
} // hexDump
335327

‎libraries/Preferences/src/Preferences.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ int8_t Preferences::getChar(const char* key, const int8_t defaultValue){
291291
}
292292
esp_err_t err = nvs_get_i8(_handle, key, &value);
293293
if(err){
294-
log_e("nvs_get_i8 fail: %s %s", key, nvs_error(err));
294+
log_v("nvs_get_i8 fail: %s %s", key, nvs_error(err));
295295
}
296296
return value;
297297
}
@@ -303,7 +303,7 @@ uint8_t Preferences::getUChar(const char* key, const uint8_t defaultValue){
303303
}
304304
esp_err_t err = nvs_get_u8(_handle, key, &value);
305305
if(err){
306-
log_e("nvs_get_u8 fail: %s %s", key, nvs_error(err));
306+
log_v("nvs_get_u8 fail: %s %s", key, nvs_error(err));
307307
}
308308
return value;
309309
}
@@ -315,7 +315,7 @@ int16_t Preferences::getShort(const char* key, const int16_t defaultValue){
315315
}
316316
esp_err_t err = nvs_get_i16(_handle, key, &value);
317317
if(err){
318-
log_e("nvs_get_i16 fail: %s %s", key, nvs_error(err));
318+
log_v("nvs_get_i16 fail: %s %s", key, nvs_error(err));
319319
}
320320
return value;
321321
}
@@ -327,7 +327,7 @@ uint16_t Preferences::getUShort(const char* key, const uint16_t defaultValue){
327327
}
328328
esp_err_t err = nvs_get_u16(_handle, key, &value);
329329
if(err){
330-
log_e("nvs_get_u16 fail: %s %s", key, nvs_error(err));
330+
log_v("nvs_get_u16 fail: %s %s", key, nvs_error(err));
331331
}
332332
return value;
333333
}
@@ -339,7 +339,7 @@ int32_t Preferences::getInt(const char* key, const int32_t defaultValue){
339339
}
340340
esp_err_t err = nvs_get_i32(_handle, key, &value);
341341
if(err){
342-
log_e("nvs_get_i32 fail: %s %s", key, nvs_error(err));
342+
log_v("nvs_get_i32 fail: %s %s", key, nvs_error(err));
343343
}
344344
return value;
345345
}
@@ -351,7 +351,7 @@ uint32_t Preferences::getUInt(const char* key, const uint32_t defaultValue){
351351
}
352352
esp_err_t err = nvs_get_u32(_handle, key, &value);
353353
if(err){
354-
log_e("nvs_get_u32 fail: %s %s", key, nvs_error(err));
354+
log_v("nvs_get_u32 fail: %s %s", key, nvs_error(err));
355355
}
356356
return value;
357357
}
@@ -371,7 +371,7 @@ int64_t Preferences::getLong64(const char* key, const int64_t defaultValue){
371371
}
372372
esp_err_t err = nvs_get_i64(_handle, key, &value);
373373
if(err){
374-
log_e("nvs_get_i64 fail: %s %s", key, nvs_error(err));
374+
log_v("nvs_get_i64 fail: %s %s", key, nvs_error(err));
375375
}
376376
return value;
377377
}
@@ -383,7 +383,7 @@ uint64_t Preferences::getULong64(const char* key, const uint64_t defaultValue){
383383
}
384384
esp_err_t err = nvs_get_u64(_handle, key, &value);
385385
if(err){
386-
log_e("nvs_get_u64 fail: %s %s", key, nvs_error(err));
386+
log_v("nvs_get_u64 fail: %s %s", key, nvs_error(err));
387387
}
388388
return value;
389389
}

0 commit comments

Comments
 (0)
Please sign in to comment.