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 3a778c7

Browse files
committedJan 31, 2025
Use standard logging
1 parent d7d996d commit 3a778c7

21 files changed

+280
-447
lines changed
 

‎libraries/NimBLE/src/BLEAddress.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#if defined(CONFIG_BT_ENABLED)
2020

2121
#include "BLEAddress.h"
22-
#include "BLELog.h"
2322

2423
#include <algorithm>
2524

@@ -78,7 +77,7 @@ BLEAddress::BLEAddress(const std::string &addr, uint8_t type) {
7877
}
7978

8079
*this = BLEAddress{};
81-
NIMBLE_LOGE(LOG_TAG, "Invalid address '%s'", addr.c_str());
80+
log_e(LOG_TAG, "Invalid address '%s'", addr.c_str());
8281
} // BLEAddress
8382

8483
/**

‎libraries/NimBLE/src/BLEAdvertisedDevice.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "BLEDevice.h"
2222
#include "BLEAdvertisedDevice.h"
2323
#include "BLEUtils.h"
24-
#include "BLELog.h"
2524

2625
#include <climits>
2726

@@ -321,7 +320,7 @@ std::string BLEAdvertisedDevice::getServiceData(const BLEUUID &uuid) const {
321320
data_loc = findServiceData(index, &bytes);
322321
}
323322

324-
NIMBLE_LOGI(LOG_TAG, "No service data found");
323+
log_i(LOG_TAG, "No service data found");
325324
return "";
326325
} // getServiceData
327326

‎libraries/NimBLE/src/BLEAdvertisementData.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "BLEDevice.h"
2323
#include "BLEUtils.h"
2424
#include "BLEUUID.h"
25-
#include "BLELog.h"
2625

2726
#include "host/ble_hs_adv.h"
2827

@@ -35,7 +34,7 @@ static const char *LOG_TAG = "BLEAdvertisementData";
3534
*/
3635
bool BLEAdvertisementData::addData(const uint8_t *data, size_t length) {
3736
if (m_payload.size() + length > BLE_HS_ADV_MAX_SZ) {
38-
NIMBLE_LOGE(LOG_TAG, "Data length exceeded");
37+
log_e(LOG_TAG, "Data length exceeded");
3938
return false;
4039
}
4140

@@ -147,7 +146,7 @@ bool BLEAdvertisementData::addServiceUUID(const BLEUUID &serviceUUID) {
147146
case 2: type = BLE_HS_ADV_TYPE_COMP_UUIDS16; break;
148147
case 4: type = BLE_HS_ADV_TYPE_COMP_UUIDS32; break;
149148
case 16: type = BLE_HS_ADV_TYPE_COMP_UUIDS128; break;
150-
default: NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, invalid size!"); return false;
149+
default: log_e(LOG_TAG, "Cannot add UUID, invalid size!"); return false;
151150
}
152151

153152
int dataLoc = getDataLocation(type);
@@ -157,7 +156,7 @@ bool BLEAdvertisementData::addServiceUUID(const BLEUUID &serviceUUID) {
157156
}
158157

159158
if (length + getPayload().size() > BLE_HS_ADV_MAX_SZ) {
160-
NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, data length exceeded!");
159+
log_e(LOG_TAG, "Cannot add UUID, data length exceeded!");
161160
return false;
162161
}
163162

@@ -196,7 +195,7 @@ bool BLEAdvertisementData::removeServiceUUID(const BLEUUID &serviceUUID) {
196195
case 2: type = BLE_HS_ADV_TYPE_COMP_UUIDS16; break;
197196
case 4: type = BLE_HS_ADV_TYPE_COMP_UUIDS32; break;
198197
case 16: type = BLE_HS_ADV_TYPE_COMP_UUIDS128; break;
199-
default: NIMBLE_LOGE(LOG_TAG, "Cannot remove UUID, invalid size!"); return false;
198+
default: log_e(LOG_TAG, "Cannot remove UUID, invalid size!"); return false;
200199
}
201200

202201
int dataLoc = getDataLocation(type);
@@ -249,7 +248,7 @@ bool BLEAdvertisementData::removeServices() {
249248
*/
250249
bool BLEAdvertisementData::setManufacturerData(const uint8_t *data, size_t length) {
251250
if (length > BLE_HS_ADV_MAX_FIELD_SZ) {
252-
NIMBLE_LOGE(LOG_TAG, "MFG data too long");
251+
log_e(LOG_TAG, "MFG data too long");
253252
return false;
254253
}
255254

@@ -285,7 +284,7 @@ bool BLEAdvertisementData::setManufacturerData(const std::vector<uint8_t> &data)
285284
*/
286285
bool BLEAdvertisementData::setURI(const std::string &uri) {
287286
if (uri.length() > BLE_HS_ADV_MAX_FIELD_SZ) {
288-
NIMBLE_LOGE(LOG_TAG, "URI too long");
287+
log_e(LOG_TAG, "URI too long");
289288
return false;
290289
}
291290

@@ -307,7 +306,7 @@ bool BLEAdvertisementData::setURI(const std::string &uri) {
307306
*/
308307
bool BLEAdvertisementData::setName(const std::string &name, bool isComplete) {
309308
if (name.length() > BLE_HS_ADV_MAX_FIELD_SZ) {
310-
NIMBLE_LOGE(LOG_TAG, "Name too long - truncating");
309+
log_e(LOG_TAG, "Name too long - truncating");
311310
isComplete = false;
312311
}
313312

@@ -397,11 +396,11 @@ bool BLEAdvertisementData::setServices(bool complete, uint8_t size, const std::v
397396

398397
for (const auto &uuid : uuids) {
399398
if (uuid.bitSize() != size) {
400-
NIMBLE_LOGE(LOG_TAG, "Service UUID(%d) invalid", size);
399+
log_e(LOG_TAG, "Service UUID(%d) invalid", size);
401400
continue;
402401
} else {
403402
if (length + bytes >= BLE_HS_ADV_MAX_SZ) {
404-
NIMBLE_LOGW(LOG_TAG, "Too many services - truncating");
403+
log_w(LOG_TAG, "Too many services - truncating");
405404
complete = false;
406405
break;
407406
}
@@ -416,7 +415,7 @@ bool BLEAdvertisementData::setServices(bool complete, uint8_t size, const std::v
416415
case 16: data[1] = (complete ? BLE_HS_ADV_TYPE_COMP_UUIDS16 : BLE_HS_ADV_TYPE_INCOMP_UUIDS16); break;
417416
case 32: data[1] = (complete ? BLE_HS_ADV_TYPE_COMP_UUIDS32 : BLE_HS_ADV_TYPE_INCOMP_UUIDS32); break;
418417
case 128: data[1] = (complete ? BLE_HS_ADV_TYPE_COMP_UUIDS128 : BLE_HS_ADV_TYPE_INCOMP_UUIDS128); break;
419-
default: NIMBLE_LOGE(LOG_TAG, "Cannot set services, invalid size!"); return false;
418+
default: log_e(LOG_TAG, "Cannot set services, invalid size!"); return false;
420419
}
421420

422421
return addData(data, length);
@@ -434,7 +433,7 @@ bool BLEAdvertisementData::setServiceData(const BLEUUID &uuid, const uint8_t *da
434433
uint8_t uuidBytes = uuid.bitSize() / 8;
435434
uint8_t sDataLen = 2 + uuidBytes + length;
436435
if (sDataLen > BLE_HS_ADV_MAX_SZ) {
437-
NIMBLE_LOGE(LOG_TAG, "Service Data too long");
436+
log_e(LOG_TAG, "Service Data too long");
438437
return false;
439438
}
440439

@@ -443,7 +442,7 @@ bool BLEAdvertisementData::setServiceData(const BLEUUID &uuid, const uint8_t *da
443442
case 2: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID16; break;
444443
case 4: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID32; break;
445444
case 16: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID128; break;
446-
default: NIMBLE_LOGE(LOG_TAG, "Cannot set service data, invalid size!"); return false;
445+
default: log_e(LOG_TAG, "Cannot set service data, invalid size!"); return false;
447446
}
448447

449448
if (length == 0) {

‎libraries/NimBLE/src/BLEAdvertising.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "BLEDevice.h"
2525
#include "BLEServer.h"
2626
#include "BLEUtils.h"
27-
#include "BLELog.h"
2827

2928
static const char *LOG_TAG = "BLEAdvertising";
3029

@@ -65,7 +64,7 @@ bool BLEAdvertising::reset() {
6564
*/
6665
bool BLEAdvertising::setConnectableMode(uint8_t mode) {
6766
if (mode > BLE_GAP_CONN_MODE_UND) {
68-
NIMBLE_LOGE(LOG_TAG, "Invalid connectable mode: %u", mode);
67+
log_e(LOG_TAG, "Invalid connectable mode: %u", mode);
6968
return false;
7069
}
7170

@@ -90,7 +89,7 @@ bool BLEAdvertising::setDiscoverableMode(uint8_t mode) {
9089
case BLE_GAP_DISC_MODE_NON: m_advData.setFlags(BLE_HS_ADV_F_BREDR_UNSUP); break;
9190
case BLE_GAP_DISC_MODE_LTD: m_advData.setFlags(BLE_HS_ADV_F_DISC_LTD); break;
9291
case BLE_GAP_DISC_MODE_GEN: m_advData.setFlags(BLE_HS_ADV_F_DISC_GEN); break;
93-
default: NIMBLE_LOGE(LOG_TAG, "Invalid discoverable mode: %u", mode); return false;
92+
default: log_e(LOG_TAG, "Invalid discoverable mode: %u", mode); return false;
9493
}
9594

9695
m_advParams.disc_mode = mode;
@@ -163,15 +162,15 @@ void BLEAdvertising::setScanFilter(bool scanRequestWhitelistOnly, bool connectWh
163162
* @return True if advertising started successfully.
164163
*/
165164
bool BLEAdvertising::start(uint32_t duration, const BLEAddress *dirAddr) {
166-
NIMBLE_LOGD(LOG_TAG, ">> Advertising start: duration=%" PRIu32 ", dirAddr=%s", duration, dirAddr ? dirAddr->toString().c_str() : "NULL");
165+
log_d(LOG_TAG, ">> Advertising start: duration=%" PRIu32 ", dirAddr=%s", duration, dirAddr ? dirAddr->toString().c_str() : "NULL");
167166

168167
if (!BLEDevice::m_synced) {
169-
NIMBLE_LOGE(LOG_TAG, "Host not synced!");
168+
log_e(LOG_TAG, "Host not synced!");
170169
return false;
171170
}
172171

173172
if (ble_gap_adv_active()) {
174-
NIMBLE_LOGW(LOG_TAG, "Advertising already active");
173+
log_w(LOG_TAG, "Advertising already active");
175174
return true;
176175
}
177176

@@ -209,11 +208,11 @@ bool BLEAdvertising::start(uint32_t duration, const BLEAddress *dirAddr) {
209208
int rc = ble_gap_adv_start(BLEDevice::m_ownAddrType, NULL, duration, &m_advParams, BLEAdvertising::handleGapEvent, this);
210209
#endif
211210
if (rc != 0 && rc != BLE_HS_EALREADY) {
212-
NIMBLE_LOGE(LOG_TAG, "Error enabling advertising; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
211+
log_e(LOG_TAG, "Error enabling advertising; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
213212
return false;
214213
}
215214

216-
NIMBLE_LOGD(LOG_TAG, "<< Advertising start");
215+
log_d(LOG_TAG, "<< Advertising start");
217216
return true;
218217
} // start
219218

@@ -224,7 +223,7 @@ bool BLEAdvertising::start(uint32_t duration, const BLEAddress *dirAddr) {
224223
bool BLEAdvertising::stop() {
225224
int rc = ble_gap_adv_stop();
226225
if (rc != 0 && rc != BLE_HS_EALREADY) {
227-
NIMBLE_LOGE(LOG_TAG, "ble_gap_adv_stop rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
226+
log_e(LOG_TAG, "ble_gap_adv_stop rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
228227
return false;
229228
}
230229

@@ -280,7 +279,7 @@ int BLEAdvertising::handleGapEvent(struct ble_gap_event *event, void *arg) {
280279
case BLE_HS_EOS:
281280
case BLE_HS_ECONTROLLER:
282281
case BLE_HS_ENOTSYNCED:
283-
NIMBLE_LOGE(LOG_TAG, "host reset, rc=%d", event->adv_complete.reason);
282+
log_e(LOG_TAG, "host reset, rc=%d", event->adv_complete.reason);
284283
BLEDevice::onReset(event->adv_complete.reason);
285284
return 0;
286285
default: break;
@@ -305,11 +304,11 @@ int BLEAdvertising::handleGapEvent(struct ble_gap_event *event, void *arg) {
305304
bool BLEAdvertising::setAdvertisementData(const BLEAdvertisementData &data) {
306305
int rc = ble_gap_adv_set_data(&data.getPayload()[0], data.getPayload().size());
307306
if (rc != 0) {
308-
NIMBLE_LOGE(LOG_TAG, "ble_gap_adv_set_data: %d %s", rc, BLEUtils::returnCodeToString(rc));
307+
log_e(LOG_TAG, "ble_gap_adv_set_data: %d %s", rc, BLEUtils::returnCodeToString(rc));
309308
return false;
310309
}
311310

312-
NIMBLE_LOGD(LOG_TAG, "setAdvertisementData: %s", data.toString().c_str());
311+
log_d(LOG_TAG, "setAdvertisementData: %s", data.toString().c_str());
313312
m_advData = data; // make a copy in the member object in case this is custom.
314313
m_advDataSet = true; // Set the flag that indicates the data was set already so we don't set it again.
315314
return true;
@@ -333,11 +332,11 @@ const BLEAdvertisementData &BLEAdvertising::getAdvertisementData() {
333332
bool BLEAdvertising::setScanResponseData(const BLEAdvertisementData &data) {
334333
int rc = ble_gap_adv_rsp_set_data(&data.getPayload()[0], data.getPayload().size());
335334
if (rc != 0) {
336-
NIMBLE_LOGE(LOG_TAG, "ble_gap_adv_rsp_set_data: %d %s", rc, BLEUtils::returnCodeToString(rc));
335+
log_e(LOG_TAG, "ble_gap_adv_rsp_set_data: %d %s", rc, BLEUtils::returnCodeToString(rc));
337336
return false;
338337
}
339338

340-
NIMBLE_LOGD(LOG_TAG, "setScanResponseData: %s", data.toString().c_str());
339+
log_d(LOG_TAG, "setScanResponseData: %s", data.toString().c_str());
341340
m_scanData = data; // copy the data into the member object in case this is custom.
342341
return true;
343342
} // setScanResponseData

‎libraries/NimBLE/src/BLEAttValue.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "nimble/nimble_npl.h"
2222

2323
#include "BLEAttValue.h"
24-
#include "BLELog.h"
2524

2625
static const char *LOG_TAG = "BLEAttValue";
2726

@@ -36,7 +35,7 @@ BLEAttValue::BLEAttValue(uint16_t init_len, uint16_t max_len)
3635
{
3736
NIMBLE_CPP_DEBUG_ASSERT(m_attr_value);
3837
if (m_attr_value == nullptr) {
39-
NIMBLE_LOGE(LOG_TAG, "Failed to calloc ctx");
38+
log_e(LOG_TAG, "Failed to calloc ctx");
4039
}
4140
}
4241

@@ -83,7 +82,7 @@ void BLEAttValue::deepCopy(const BLEAttValue &source) {
8382
uint8_t *res = static_cast<uint8_t *>(realloc(m_attr_value, source.m_capacity + 1));
8483
NIMBLE_CPP_DEBUG_ASSERT(res);
8584
if (res == nullptr) {
86-
NIMBLE_LOGE(LOG_TAG, "Failed to realloc deepCopy");
85+
log_e(LOG_TAG, "Failed to realloc deepCopy");
8786
return;
8887
}
8988

@@ -111,7 +110,7 @@ BLEAttValue &BLEAttValue::append(const uint8_t *value, uint16_t len) {
111110
}
112111

113112
if ((m_attr_len + len) > m_attr_max_len) {
114-
NIMBLE_LOGE(LOG_TAG, "val > max, len=%u, max=%u", len, m_attr_max_len);
113+
log_e(LOG_TAG, "val > max, len=%u, max=%u", len, m_attr_max_len);
115114
return *this;
116115
}
117116

@@ -123,7 +122,7 @@ BLEAttValue &BLEAttValue::append(const uint8_t *value, uint16_t len) {
123122
}
124123
NIMBLE_CPP_DEBUG_ASSERT(res);
125124
if (res == nullptr) {
126-
NIMBLE_LOGE(LOG_TAG, "Failed to realloc append");
125+
log_e(LOG_TAG, "Failed to realloc append");
127126
return *this;
128127
}
129128

@@ -147,7 +146,7 @@ BLEAttValue &BLEAttValue::append(const uint8_t *value, uint16_t len) {
147146
uint8_t BLEAttValue::operator[](int pos) const {
148147
NIMBLE_CPP_DEBUG_ASSERT(pos < m_attr_len);
149148
if (pos >= m_attr_len) {
150-
NIMBLE_LOGE(LOG_TAG, "pos >= len, pos=%u, len=%u", pos, m_attr_len);
149+
log_e(LOG_TAG, "pos >= len, pos=%u, len=%u", pos, m_attr_len);
151150
return 0;
152151
}
153152
return m_attr_value[pos];

‎libraries/NimBLE/src/BLEBeacon.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEBeacon.h"
2222
#include "BLEUUID.h"
23-
#include "BLELog.h"
2423

2524
#define ENDIAN_CHANGE_U16(x) ((((x) & 0xFF00) >> 8) + (((x) & 0xFF) << 8))
2625

@@ -81,7 +80,7 @@ int8_t BLEBeacon::getSignalPower() {
8180
*/
8281
void BLEBeacon::setData(const uint8_t *data, uint8_t length) {
8382
if (length != sizeof(BeaconData)) {
84-
NIMBLE_LOGE(LOG_TAG, "Data length must be %d bytes, sent: %d", sizeof(BeaconData), length);
83+
log_e(LOG_TAG, "Data length must be %d bytes, sent: %d", sizeof(BeaconData), length);
8584
return;
8685
}
8786
memcpy(&m_beaconData, data, length);

‎libraries/NimBLE/src/BLECharacteristic.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "BLECharacteristic.h"
2222
#include "BLE2904.h"
2323
#include "BLEDevice.h"
24-
#include "BLELog.h"
2524

2625
static BLECharacteristicCallbacks defaultCallback;
2726
static const char *LOG_TAG = "BLECharacteristic";
@@ -78,7 +77,7 @@ BLEDescriptor *BLECharacteristic::createDescriptor(const char *uuid, uint32_t pr
7877
BLEDescriptor *BLECharacteristic::createDescriptor(const BLEUUID &uuid, uint32_t properties, uint16_t maxLen) {
7978
BLEDescriptor *pDescriptor = nullptr;
8079
if (uuid == BLEUUID(static_cast<uint16_t>(0x2904))) {
81-
NIMBLE_LOGW(LOG_TAG, "0x2904 descriptor should be created with create2904()");
80+
log_w(LOG_TAG, "0x2904 descriptor should be created with create2904()");
8281
pDescriptor = create2904();
8382
} else {
8483
pDescriptor = new BLEDescriptor(uuid, properties, maxLen, this);
@@ -277,7 +276,7 @@ bool BLECharacteristic::sendValue(const uint8_t *value, size_t length, bool isNo
277276
// Must re-create the data buffer on each iteration because it is freed by the calls bellow.
278277
os_mbuf *om = ble_hs_mbuf_from_flat(value, length);
279278
if (!om) {
280-
NIMBLE_LOGE(LOG_TAG, "<< sendValue: failed to allocate mbuf");
279+
log_e(LOG_TAG, "<< sendValue: failed to allocate mbuf");
281280
return false;
282281
}
283282

@@ -288,7 +287,7 @@ bool BLECharacteristic::sendValue(const uint8_t *value, size_t length, bool isNo
288287
}
289288

290289
if (rc != 0) {
291-
NIMBLE_LOGE(LOG_TAG, "<< sendValue: failed to send value, rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
290+
log_e(LOG_TAG, "<< sendValue: failed to send value, rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
292291
break;
293292
}
294293
}
@@ -372,7 +371,7 @@ std::string BLECharacteristic::toString() const {
372371
* @param [in] connInfo A reference to a BLEConnInfo instance containing the peer info.
373372
*/
374373
void BLECharacteristicCallbacks::onRead(BLECharacteristic *pCharacteristic, BLEConnInfo &connInfo) {
375-
NIMBLE_LOGD("BLECharacteristicCallbacks", "onRead: default");
374+
log_d("BLECharacteristicCallbacks", "onRead: default");
376375
} // onRead
377376

378377
/**
@@ -381,7 +380,7 @@ void BLECharacteristicCallbacks::onRead(BLECharacteristic *pCharacteristic, BLEC
381380
* @param [in] connInfo A reference to a BLEConnInfo instance containing the peer info.
382381
*/
383382
void BLECharacteristicCallbacks::onWrite(BLECharacteristic *pCharacteristic, BLEConnInfo &connInfo) {
384-
NIMBLE_LOGD("BLECharacteristicCallbacks", "onWrite: default");
383+
log_d("BLECharacteristicCallbacks", "onWrite: default");
385384
} // onWrite
386385

387386
/**
@@ -392,7 +391,7 @@ void BLECharacteristicCallbacks::onWrite(BLECharacteristic *pCharacteristic, BLE
392391
* any other value is an error.
393392
*/
394393
void BLECharacteristicCallbacks::onStatus(BLECharacteristic *pCharacteristic, int code) {
395-
NIMBLE_LOGD("BLECharacteristicCallbacks", "onStatus: default");
394+
log_d("BLECharacteristicCallbacks", "onStatus: default");
396395
} // onStatus
397396

398397
/**
@@ -406,7 +405,7 @@ void BLECharacteristicCallbacks::onStatus(BLECharacteristic *pCharacteristic, in
406405
* * 3 = Notifications and Indications
407406
*/
408407
void BLECharacteristicCallbacks::onSubscribe(BLECharacteristic *pCharacteristic, BLEConnInfo &connInfo, uint16_t subValue) {
409-
NIMBLE_LOGD("BLECharacteristicCallbacks", "onSubscribe: default");
408+
log_d("BLECharacteristicCallbacks", "onSubscribe: default");
410409
}
411410

412411
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

‎libraries/NimBLE/src/BLEClient.cpp

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

‎libraries/NimBLE/src/BLEDescriptor.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEService.h"
2222
#include "BLEDescriptor.h"
23-
#include "BLELog.h"
2423

2524
#include <string>
2625

@@ -48,7 +47,7 @@ BLEDescriptor::BLEDescriptor(const BLEUUID &uuid, uint16_t properties, uint16_t
4847
: BLELocalValueAttribute{uuid, 0, max_len}, m_pCallbacks{&defaultCallbacks}, m_pCharacteristic{pCharacteristic} {
4948
// Check if this is the client configuration descriptor and set to removed if true.
5049
if (uuid == BLEUUID((uint16_t)0x2902)) {
51-
NIMBLE_LOGW(LOG_TAG, "Manually created 2902 descriptor has no functionality; please remove.");
50+
log_w(LOG_TAG, "Manually created 2902 descriptor has no functionality; please remove.");
5251
setRemoved(NIMBLE_ATT_REMOVE_HIDE);
5352
}
5453

@@ -136,7 +135,7 @@ void BLEDescriptor::writeEvent(const uint8_t *val, uint16_t len, BLEConnInfo &co
136135
* @param [in] connInfo A reference to a BLEConnInfo instance containing the peer info.
137136
*/
138137
void BLEDescriptorCallbacks::onRead(BLEDescriptor *pDescriptor, BLEConnInfo &connInfo) {
139-
NIMBLE_LOGD("BLEDescriptorCallbacks", "onRead: default");
138+
log_d("BLEDescriptorCallbacks", "onRead: default");
140139
} // onRead
141140

142141
/**
@@ -145,7 +144,7 @@ void BLEDescriptorCallbacks::onRead(BLEDescriptor *pDescriptor, BLEConnInfo &con
145144
* @param [in] connInfo A reference to a BLEConnInfo instance containing the peer info.
146145
*/
147146
void BLEDescriptorCallbacks::onWrite(BLEDescriptor *pDescriptor, BLEConnInfo &connInfo) {
148-
NIMBLE_LOGD("BLEDescriptorCallbacks", "onWrite: default");
147+
log_d("BLEDescriptorCallbacks", "onWrite: default");
149148
} // onWrite
150149

151150
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */

‎libraries/NimBLE/src/BLEDevice.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
#include "BLEServer.h"
4848
#endif
4949

50-
#include "BLELog.h"
51-
5250
static const char *LOG_TAG = "BLEDevice";
5351

5452
extern "C" void ble_store_config_init(void);
@@ -214,7 +212,7 @@ BLEScan *BLEDevice::getScan() {
214212
*/
215213
void BLEDevice::setScanDuplicateCacheSize(uint16_t size) {
216214
if (m_initialized) {
217-
NIMBLE_LOGE(LOG_TAG, "Cannot change scan cache size while initialized");
215+
log_e(LOG_TAG, "Cannot change scan cache size while initialized");
218216
return;
219217
} else {
220218
if (size > 1000) {
@@ -224,7 +222,7 @@ void BLEDevice::setScanDuplicateCacheSize(uint16_t size) {
224222
}
225223
}
226224

227-
NIMBLE_LOGD(LOG_TAG, "Set duplicate cache size to: %u", size);
225+
log_d(LOG_TAG, "Set duplicate cache size to: %u", size);
228226
m_scanDuplicateSize = size;
229227
}
230228

@@ -243,10 +241,10 @@ void BLEDevice::setScanDuplicateCacheSize(uint16_t size) {
243241
*/
244242
void BLEDevice::setScanFilterMode(uint8_t mode) {
245243
if (m_initialized) {
246-
NIMBLE_LOGE(LOG_TAG, "Cannot change scan duplicate type while initialized");
244+
log_e(LOG_TAG, "Cannot change scan duplicate type while initialized");
247245
return;
248246
} else if (mode > 2) {
249-
NIMBLE_LOGE(LOG_TAG, "Invalid scan duplicate type");
247+
log_e(LOG_TAG, "Invalid scan duplicate type");
250248
return;
251249
}
252250

@@ -282,7 +280,7 @@ BLEClient *BLEDevice::createClient(const BLEAddress &peerAddress) {
282280
}
283281
}
284282

285-
NIMBLE_LOGE(LOG_TAG, "Unable to create client; already at max: %d", NIMBLE_MAX_CONNECTIONS);
283+
log_e(LOG_TAG, "Unable to create client; already at max: %d", NIMBLE_MAX_CONNECTIONS);
286284
return nullptr;
287285
} // createClient
288286

@@ -426,7 +424,7 @@ esp_power_level_t BLEDevice::getPowerLevel(esp_ble_power_type_t powerType) {
426424
bool BLEDevice::setPowerLevel(esp_power_level_t powerLevel, esp_ble_power_type_t powerType) {
427425
esp_err_t errRc = esp_ble_tx_power_set(powerType, powerLevel);
428426
if (errRc != ESP_OK) {
429-
NIMBLE_LOGE(LOG_TAG, "esp_ble_tx_power_set: rc=%d", errRc);
427+
log_e(LOG_TAG, "esp_ble_tx_power_set: rc=%d", errRc);
430428
}
431429

432430
return errRc == ESP_OK;
@@ -478,7 +476,7 @@ int BLEDevice::getPower(BLETxPowerType type) {
478476

479477
int pwr = getPowerLevel(espPwr);
480478
if (pwr < 0) {
481-
NIMBLE_LOGE(LOG_TAG, "esp_ble_tx_power_get failed rc=%d", pwr);
479+
log_e(LOG_TAG, "esp_ble_tx_power_get failed rc=%d", pwr);
482480
return 0xFF;
483481
}
484482

@@ -507,7 +505,7 @@ int BLEDevice::getPower(BLETxPowerType type) {
507505
bool BLEDevice::setMTU(uint16_t mtu) {
508506
int rc = ble_att_set_preferred_mtu(mtu);
509507
if (rc != 0) {
510-
NIMBLE_LOGE(LOG_TAG, "Could not set local mtu value to: %d, rc: %d", mtu, rc);
508+
log_e(LOG_TAG, "Could not set local mtu value to: %d, rc: %d", mtu, rc);
511509
}
512510

513511
return rc == 0;
@@ -547,7 +545,7 @@ int BLEDevice::getNumBonds() {
547545
bool BLEDevice::deleteAllBonds() {
548546
int rc = ble_store_clear();
549547
if (rc != 0) {
550-
NIMBLE_LOGE(LOG_TAG, "Failed to delete all bonds; rc=%d", rc);
548+
log_e(LOG_TAG, "Failed to delete all bonds; rc=%d", rc);
551549
return false;
552550
}
553551
return true;
@@ -632,7 +630,7 @@ bool BLEDevice::whiteListAdd(const BLEAddress &address) {
632630
m_whiteList.push_back(address);
633631
int rc = ble_gap_wl_set(reinterpret_cast<ble_addr_t *>(&m_whiteList[0]), m_whiteList.size());
634632
if (rc != 0) {
635-
NIMBLE_LOGE(LOG_TAG, "Failed adding to whitelist rc=%d", rc);
633+
log_e(LOG_TAG, "Failed adding to whitelist rc=%d", rc);
636634
m_whiteList.pop_back();
637635
return false;
638636
}
@@ -653,7 +651,7 @@ bool BLEDevice::whiteListRemove(const BLEAddress &address) {
653651
int rc = ble_gap_wl_set(reinterpret_cast<ble_addr_t *>(&m_whiteList[0]), m_whiteList.size());
654652
if (rc != 0) {
655653
m_whiteList.push_back(address);
656-
NIMBLE_LOGE(LOG_TAG, "Failed removing from whitelist rc=%d", rc);
654+
log_e(LOG_TAG, "Failed removing from whitelist rc=%d", rc);
657655
return false;
658656
}
659657

@@ -679,7 +677,7 @@ size_t BLEDevice::getWhiteListCount() {
679677
*/
680678
BLEAddress BLEDevice::getWhiteListAddress(size_t index) {
681679
if (index > m_whiteList.size()) {
682-
NIMBLE_LOGE(LOG_TAG, "Invalid index; %u", index);
680+
log_e(LOG_TAG, "Invalid index; %u", index);
683681
return BLEAddress{};
684682
}
685683

@@ -708,7 +706,7 @@ BLEAddress BLEDevice::getWhiteListAddress(size_t index) {
708706
bool BLEDevice::setDefaultPhy(uint8_t txPhyMask, uint8_t rxPhyMask) {
709707
int rc = ble_gap_set_prefered_default_le_phy(txPhyMask, rxPhyMask);
710708
if (rc != 0) {
711-
NIMBLE_LOGE(LOG_TAG, "Failed to set default phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
709+
log_e(LOG_TAG, "Failed to set default phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
712710
}
713711

714712
return rc == 0;
@@ -726,14 +724,14 @@ void BLEDevice::onReset(int reason) {
726724

727725
m_synced = false;
728726

729-
NIMBLE_LOGE(LOG_TAG, "Host reset; reason=%d, %s", reason, BLEUtils::returnCodeToString(reason));
727+
log_e(LOG_TAG, "Host reset; reason=%d, %s", reason, BLEUtils::returnCodeToString(reason));
730728
} // onReset
731729

732730
/**
733731
* @brief Host synced with controller, all clear to make calls to the stack.
734732
*/
735733
void BLEDevice::onSync(void) {
736-
NIMBLE_LOGI(LOG_TAG, "NimBle host synced.");
734+
log_i(LOG_TAG, "NimBle host synced.");
737735
// This check is needed due to potentially being called multiple times in succession
738736
// If this happens, the call to scan start may get stuck or cause an advertising fault.
739737
if (m_synced) {
@@ -747,7 +745,7 @@ void BLEDevice::onSync(void) {
747745
}
748746

749747
if (rc != 0) {
750-
NIMBLE_LOGE(LOG_TAG, "error ensuring address; rc=%d", rc);
748+
log_e(LOG_TAG, "error ensuring address; rc=%d", rc);
751749
return;
752750
}
753751

@@ -782,7 +780,7 @@ void BLEDevice::onSync(void) {
782780
* @brief The main host task.
783781
*/
784782
void BLEDevice::host_task(void *param) {
785-
NIMBLE_LOGI(LOG_TAG, "BLE Host Task Started");
783+
log_i(LOG_TAG, "BLE Host Task Started");
786784
nimble_port_run(); // This function will return only when nimble_port_stop() is executed
787785
nimble_port_freertos_deinit();
788786
} // host_task
@@ -805,7 +803,7 @@ bool BLEDevice::init(const std::string &deviceName) {
805803
}
806804

807805
if (err != ESP_OK) {
808-
NIMBLE_LOGE(LOG_TAG, "nvs_flash_init() failed; err=%d", err);
806+
log_e(LOG_TAG, "nvs_flash_init() failed; err=%d", err);
809807
return false;
810808
}
811809

@@ -829,19 +827,19 @@ bool BLEDevice::init(const std::string &deviceName) {
829827
# endif
830828
err = esp_bt_controller_init(&bt_cfg);
831829
if (err != ESP_OK) {
832-
NIMBLE_LOGE(LOG_TAG, "esp_bt_controller_init() failed; err=%d", err);
830+
log_e(LOG_TAG, "esp_bt_controller_init() failed; err=%d", err);
833831
return false;
834832
}
835833
836834
err = esp_bt_controller_enable(ESP_BT_MODE_BLE);
837835
if (err != ESP_OK) {
838-
NIMBLE_LOGE(LOG_TAG, "esp_bt_controller_enable() failed; err=%d", err);
836+
log_e(LOG_TAG, "esp_bt_controller_enable() failed; err=%d", err);
839837
return false;
840838
}
841839
842840
err = esp_nimble_hci_init();
843841
if (err != ESP_OK) {
844-
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_init() failed; err=%d", err);
842+
log_e(LOG_TAG, "esp_nimble_hci_init() failed; err=%d", err);
845843
return false;
846844
}
847845
# endif
@@ -895,7 +893,7 @@ bool BLEDevice::deinit(bool clearAll) {
895893
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
896894
rc = esp_nimble_hci_and_controller_deinit();
897895
if (rc != ESP_OK) {
898-
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", rc);
896+
log_e(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", rc);
899897
}
900898
#endif
901899
m_initialized = false;
@@ -956,7 +954,7 @@ BLEAddress BLEDevice::getAddress() {
956954
uint8_t type = m_ownAddrType & 1; // input must be random or public, odd values are random
957955
int rc = ble_hs_id_copy_addr(type, addr.val, NULL);
958956
if (rc != 0) {
959-
NIMBLE_LOGE(LOG_TAG, "No address, rc: %d", rc);
957+
log_e(LOG_TAG, "No address, rc: %d", rc);
960958
} else {
961959
addr.type = type;
962960
}
@@ -976,7 +974,7 @@ BLEAddress BLEDevice::getAddress() {
976974
bool BLEDevice::setOwnAddrType(uint8_t type) {
977975
int rc = ble_hs_id_copy_addr(type & 1, NULL, NULL); // Odd values are random
978976
if (rc != 0) {
979-
NIMBLE_LOGE(LOG_TAG, "Unable to set address type %d, rc=%d", type, rc);
977+
log_e(LOG_TAG, "Unable to set address type %d, rc=%d", type, rc);
980978
return false;
981979
}
982980

@@ -1017,7 +1015,7 @@ bool BLEDevice::setOwnAddr(const BLEAddress &addr) {
10171015
bool BLEDevice::setOwnAddr(const uint8_t *addr) {
10181016
int rc = ble_hs_id_set_rnd(addr);
10191017
if (rc != 0) {
1020-
NIMBLE_LOGE(LOG_TAG, "Failed to set address, rc=%d", rc);
1018+
log_e(LOG_TAG, "Failed to set address, rc=%d", rc);
10211019
return false;
10221020
}
10231021

@@ -1035,7 +1033,7 @@ bool BLEDevice::setOwnAddr(const uint8_t *addr) {
10351033
* @param sc If true we will perform secure connection pairing, false we will use legacy pairing.
10361034
*/
10371035
void BLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc) {
1038-
NIMBLE_LOGD(LOG_TAG, "Setting bonding: %d, mitm: %d, sc: %d", bonding, mitm, sc);
1036+
log_d(LOG_TAG, "Setting bonding: %d, mitm: %d, sc: %d", bonding, mitm, sc);
10391037
ble_hs_cfg.sm_bonding = bonding;
10401038
ble_hs_cfg.sm_mitm = mitm;
10411039
ble_hs_cfg.sm_sc = sc;
@@ -1118,7 +1116,7 @@ uint32_t BLEDevice::getSecurityPasskey() {
11181116
bool BLEDevice::startSecurity(uint16_t connHandle, int *rcPtr) {
11191117
int rc = ble_gap_security_initiate(connHandle);
11201118
if (rc != 0) {
1121-
NIMBLE_LOGE(LOG_TAG, "ble_gap_security_initiate: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
1119+
log_e(LOG_TAG, "ble_gap_security_initiate: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
11221120
}
11231121
if (rcPtr) {
11241122
*rcPtr = rc;
@@ -1136,7 +1134,7 @@ bool BLEDevice::startSecurity(uint16_t connHandle, int *rcPtr) {
11361134
bool BLEDevice::injectPassKey(const BLEConnInfo &peerInfo, uint32_t passkey) {
11371135
ble_sm_io pkey{.action = BLE_SM_IOACT_INPUT, .passkey = passkey};
11381136
int rc = ble_sm_inject_io(peerInfo.getConnHandle(), &pkey);
1139-
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_INPUT; ble_sm_inject_io result: %d", rc);
1137+
log_d(LOG_TAG, "BLE_SM_IOACT_INPUT; ble_sm_inject_io result: %d", rc);
11401138
return rc == 0;
11411139
}
11421140

@@ -1148,7 +1146,7 @@ bool BLEDevice::injectPassKey(const BLEConnInfo &peerInfo, uint32_t passkey) {
11481146
bool BLEDevice::injectConfirmPasskey(const BLEConnInfo &peerInfo, bool accept) {
11491147
ble_sm_io pkey{.action = BLE_SM_IOACT_NUMCMP, .numcmp_accept = accept};
11501148
int rc = ble_sm_inject_io(peerInfo.getConnHandle(), &pkey);
1151-
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d", rc);
1149+
log_d(LOG_TAG, "BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d", rc);
11521150
return rc == 0;
11531151
}
11541152
#endif // CONFIG_BT_NIMBLE_ROLE_CENTRAL || CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
@@ -1164,7 +1162,7 @@ bool BLEDevice::injectConfirmPasskey(const BLEConnInfo &peerInfo, bool accept) {
11641162
bool BLEDevice::setDeviceName(const std::string &deviceName) {
11651163
int rc = ble_svc_gap_device_name_set(deviceName.c_str());
11661164
if (rc != 0) {
1167-
NIMBLE_LOGE(LOG_TAG, "Device name not set - too long");
1165+
log_e(LOG_TAG, "Device name not set - too long");
11681166
return false;
11691167
}
11701168

@@ -1179,10 +1177,10 @@ bool BLEDevice::setDeviceName(const std::string &deviceName) {
11791177
bool BLEDevice::setCustomGapHandler(gap_event_handler handler) {
11801178
int rc = ble_gap_event_listener_register(&m_listener, handler, NULL);
11811179
if (rc == BLE_HS_EALREADY) {
1182-
NIMBLE_LOGI(LOG_TAG, "Already listening to GAP events.");
1180+
log_i(LOG_TAG, "Already listening to GAP events.");
11831181
return true;
11841182
} else if (rc != 0) {
1185-
NIMBLE_LOGE(LOG_TAG, "ble_gap_event_listener_register: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
1183+
log_e(LOG_TAG, "ble_gap_event_listener_register: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
11861184
}
11871185

11881186
return rc == 0;

‎libraries/NimBLE/src/BLEEddystoneTLM.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEEddystoneTLM.h"
2222
#include "BLEUUID.h"
23-
#include "BLELog.h"
2423

2524
#define ENDIAN_CHANGE_U16(x) ((((x) & 0xFF00) >> 8) + (((x) & 0xFF) << 8))
2625
#define ENDIAN_CHANGE_U32(x) ((((x) & 0xFF000000) >> 24) + (((x) & 0x00FF0000) >> 8)) + ((((x) & 0xFF00) << 8) + (((x) & 0xFF) << 24))
@@ -146,7 +145,7 @@ std::string BLEEddystoneTLM::toString() {
146145
*/
147146
void BLEEddystoneTLM::setData(const uint8_t *data, uint8_t length) {
148147
if (length != sizeof(m_eddystoneData)) {
149-
NIMBLE_LOGE(LOG_TAG, "Unable to set the data ... length passed in was %d and expected %d", length, sizeof(m_eddystoneData));
148+
log_e(LOG_TAG, "Unable to set the data ... length passed in was %d and expected %d", length, sizeof(m_eddystoneData));
150149
return;
151150
}
152151
memcpy(&m_eddystoneData, data, length);
@@ -166,7 +165,7 @@ void BLEEddystoneTLM::setData(const BLEEddystoneTLM::BeaconData &data) {
166165
*/
167166
void BLEEddystoneTLM::setUUID(const BLEUUID &uuid) {
168167
if (uuid.bitSize() != 16) {
169-
NIMBLE_LOGE(LOG_TAG, "UUID must be 16 bits");
168+
log_e(LOG_TAG, "UUID must be 16 bits");
170169
return;
171170
}
172171
beaconUUID = *reinterpret_cast<const uint16_t *>(uuid.getValue());

‎libraries/NimBLE/src/BLEExtAdvertising.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "BLEDevice.h"
2525
#include "BLEServer.h"
2626
#include "BLEUtils.h"
27-
#include "BLELog.h"
2827

2928
static BLEExtAdvertisingCallbacks defaultCallbacks;
3029
static const char *LOG_TAG = "BLEExtAdvertising";
@@ -75,20 +74,20 @@ bool BLEExtAdvertising::setInstanceData(uint8_t instId, BLEExtAdvertisement &adv
7574
#endif
7675

7776
if (rc != 0) {
78-
NIMBLE_LOGE(LOG_TAG, "Advertising config error: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
77+
log_e(LOG_TAG, "Advertising config error: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
7978
return false;
8079
}
8180

8281
os_mbuf *buf;
8382
buf = os_msys_get_pkthdr(adv.m_payload.size(), 0);
8483
if (!buf) {
85-
NIMBLE_LOGE(LOG_TAG, "Data buffer allocation failed");
84+
log_e(LOG_TAG, "Data buffer allocation failed");
8685
return false;
8786
}
8887

8988
rc = os_mbuf_append(buf, &adv.m_payload[0], adv.m_payload.size());
9089
if (rc != 0) {
91-
NIMBLE_LOGE(LOG_TAG, "Unable to copy data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
90+
log_e(LOG_TAG, "Unable to copy data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
9291
return false;
9392
}
9493

@@ -99,7 +98,7 @@ bool BLEExtAdvertising::setInstanceData(uint8_t instId, BLEExtAdvertisement &adv
9998
}
10099

101100
if (rc != 0) {
102-
NIMBLE_LOGE(LOG_TAG, "Invalid advertisement data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
101+
log_e(LOG_TAG, "Invalid advertisement data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
103102
return false;
104103
}
105104

@@ -108,7 +107,7 @@ bool BLEExtAdvertising::setInstanceData(uint8_t instId, BLEExtAdvertisement &adv
108107
}
109108

110109
if (rc != 0) {
111-
NIMBLE_LOGE(LOG_TAG, "Error setting advertisement address: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
110+
log_e(LOG_TAG, "Error setting advertisement address: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
112111
return false;
113112
}
114113

@@ -123,13 +122,13 @@ bool BLEExtAdvertising::setInstanceData(uint8_t instId, BLEExtAdvertisement &adv
123122
bool BLEExtAdvertising::setScanResponseData(uint8_t instId, BLEExtAdvertisement &data) {
124123
os_mbuf *buf = os_msys_get_pkthdr(data.m_payload.size(), 0);
125124
if (!buf) {
126-
NIMBLE_LOGE(LOG_TAG, "Data buffer allocation failed");
125+
log_e(LOG_TAG, "Data buffer allocation failed");
127126
return false;
128127
}
129128

130129
int rc = os_mbuf_append(buf, &data.m_payload[0], data.m_payload.size());
131130
if (rc != 0) {
132-
NIMBLE_LOGE(LOG_TAG, "Unable to copy scan data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
131+
log_e(LOG_TAG, "Unable to copy scan data: rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
133132
return false;
134133
}
135134

@@ -147,13 +146,13 @@ bool BLEExtAdvertising::setScanResponseData(uint8_t instId, BLEExtAdvertisement
147146
bool BLEExtAdvertising::start(uint8_t instId, int duration, int maxEvents) {
148147
// If Host is not synced we cannot start advertising.
149148
if (!BLEDevice::m_synced) {
150-
NIMBLE_LOGE(LOG_TAG, "Host reset, wait for sync.");
149+
log_e(LOG_TAG, "Host reset, wait for sync.");
151150
return false;
152151
}
153152

154153
int rc = ble_gap_ext_adv_start(instId, duration / 10, maxEvents);
155154
if (rc != 0 && rc != BLE_HS_EALREADY) {
156-
NIMBLE_LOGE(LOG_TAG, "Error enabling advertising; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
155+
log_e(LOG_TAG, "Error enabling advertising; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
157156
return false;
158157
}
159158

@@ -173,7 +172,7 @@ bool BLEExtAdvertising::removeInstance(uint8_t instId) {
173172
return true;
174173
}
175174

176-
NIMBLE_LOGE(LOG_TAG, "ble_gap_ext_adv_remove rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
175+
log_e(LOG_TAG, "ble_gap_ext_adv_remove rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
177176
}
178177

179178
return false;
@@ -190,7 +189,7 @@ bool BLEExtAdvertising::removeAll() {
190189
return true;
191190
}
192191

193-
NIMBLE_LOGE(LOG_TAG, "ble_gap_ext_adv_clear rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
192+
log_e(LOG_TAG, "ble_gap_ext_adv_clear rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
194193
}
195194

196195
return false;
@@ -208,7 +207,7 @@ bool BLEExtAdvertising::stop(uint8_t instId) {
208207
return true;
209208
}
210209

211-
NIMBLE_LOGE(LOG_TAG, "ble_gap_ext_adv_stop rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
210+
log_e(LOG_TAG, "ble_gap_ext_adv_stop rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
212211
return false;
213212
} // stop
214213

@@ -225,7 +224,7 @@ bool BLEExtAdvertising::stop() {
225224
return true;
226225
}
227226

228-
NIMBLE_LOGE(LOG_TAG, "ble_gap_ext_adv_stop rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
227+
log_e(LOG_TAG, "ble_gap_ext_adv_stop rc = %d %s", rc, BLEUtils::returnCodeToString(rc));
229228
return false;
230229
} // stop
231230

@@ -272,7 +271,7 @@ bool BLEExtAdvertising::isAdvertising() {
272271
* we need clear the flag so it reloads it.
273272
*/
274273
void BLEExtAdvertising::onHostSync() {
275-
NIMBLE_LOGD(LOG_TAG, "Host re-synced");
274+
log_d(LOG_TAG, "Host re-synced");
276275
for (auto status : m_advStatus) {
277276
status = false;
278277
}
@@ -297,7 +296,7 @@ int BLEExtAdvertising::handleGapEvent(ble_gap_event *event, void *arg) {
297296
case BLE_HS_EOS:
298297
case BLE_HS_ECONTROLLER:
299298
case BLE_HS_ENOTSYNCED:
300-
NIMBLE_LOGE(LOG_TAG, "host reset, rc = %d", event->adv_complete.reason);
299+
log_e(LOG_TAG, "host reset, rc = %d", event->adv_complete.reason);
301300
BLEDevice::onReset(event->adv_complete.reason);
302301
return 0;
303302
default: break;
@@ -322,11 +321,11 @@ int BLEExtAdvertising::handleGapEvent(ble_gap_event *event, void *arg) {
322321
/* -------------------------------------------------------------------------- */
323322

324323
void BLEExtAdvertisingCallbacks::onStopped(BLEExtAdvertising *pAdv, int reason, uint8_t instId) {
325-
NIMBLE_LOGD("BLEExtAdvertisingCallbacks", "onStopped: Default");
324+
log_d("BLEExtAdvertisingCallbacks", "onStopped: Default");
326325
} // onStopped
327326

328327
void BLEExtAdvertisingCallbacks::onScanRequest(BLEExtAdvertising *pAdv, uint8_t instId, BLEAddress addr) {
329-
NIMBLE_LOGD("BLEExtAdvertisingCallbacks", "onScanRequest: Default");
328+
log_d("BLEExtAdvertisingCallbacks", "onScanRequest: Default");
330329
} // onScanRequest
331330

332331
/* -------------------------------------------------------------------------- */
@@ -682,7 +681,7 @@ bool BLEExtAdvertisement::addServiceUUID(const BLEUUID &serviceUUID) {
682681
case 2: type = BLE_HS_ADV_TYPE_COMP_UUIDS16; break;
683682
case 4: type = BLE_HS_ADV_TYPE_COMP_UUIDS32; break;
684683
case 16: type = BLE_HS_ADV_TYPE_COMP_UUIDS128; break;
685-
default: NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, invalid size!"); return false;
684+
default: log_e(LOG_TAG, "Cannot add UUID, invalid size!"); return false;
686685
}
687686

688687
int dataLoc = getDataLocation(type);
@@ -692,7 +691,7 @@ bool BLEExtAdvertisement::addServiceUUID(const BLEUUID &serviceUUID) {
692691
}
693692

694693
if (length + getDataSize() > CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN) {
695-
NIMBLE_LOGE(LOG_TAG, "Cannot add UUID, data length exceeded!");
694+
log_e(LOG_TAG, "Cannot add UUID, data length exceeded!");
696695
return false;
697696
}
698697

@@ -731,7 +730,7 @@ bool BLEExtAdvertisement::removeServiceUUID(const BLEUUID &serviceUUID) {
731730
case 2: type = BLE_HS_ADV_TYPE_COMP_UUIDS16; break;
732731
case 4: type = BLE_HS_ADV_TYPE_COMP_UUIDS32; break;
733732
case 16: type = BLE_HS_ADV_TYPE_COMP_UUIDS128; break;
734-
default: NIMBLE_LOGE(LOG_TAG, "Cannot remove UUID, invalid size!"); return false;
733+
default: log_e(LOG_TAG, "Cannot remove UUID, invalid size!"); return false;
735734
}
736735

737736
int dataLoc = getDataLocation(type);
@@ -846,20 +845,20 @@ bool BLEExtAdvertisement::setServices(bool complete, uint8_t size, const std::ve
846845
case 16: header[1] = complete ? BLE_HS_ADV_TYPE_COMP_UUIDS16 : BLE_HS_ADV_TYPE_INCOMP_UUIDS16; break;
847846
case 32: header[1] = complete ? BLE_HS_ADV_TYPE_COMP_UUIDS32 : BLE_HS_ADV_TYPE_INCOMP_UUIDS32; break;
848847
case 128: header[1] = complete ? BLE_HS_ADV_TYPE_COMP_UUIDS128 : BLE_HS_ADV_TYPE_INCOMP_UUIDS128; break;
849-
default: NIMBLE_LOGE(LOG_TAG, "Cannot set services, invalid size!"); return false;
848+
default: log_e(LOG_TAG, "Cannot set services, invalid size!"); return false;
850849
}
851850

852851
if (addData(header, 2)) {
853852
int count = 0;
854853
for (const auto &uuid : uuids) {
855854
if (uuid.bitSize() != size) {
856-
NIMBLE_LOGE(LOG_TAG, "Service UUID(%d) invalid", size);
855+
log_e(LOG_TAG, "Service UUID(%d) invalid", size);
857856
continue;
858857
} else {
859858
if (addData(uuid.getValue(), uuidBytes)) {
860859
count++;
861860
} else {
862-
NIMBLE_LOGE(LOG_TAG, "Error setting service UUIDs");
861+
log_e(LOG_TAG, "Error setting service UUIDs");
863862
m_payload.erase(m_payload.end() - 2 - (count * uuidBytes), m_payload.end());
864863
return false;
865864
}
@@ -893,7 +892,7 @@ bool BLEExtAdvertisement::setServiceData(const BLEUUID &uuid, const uint8_t *dat
893892
case 2: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID16; break;
894893
case 4: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID32; break;
895894
case 16: type = BLE_HS_ADV_TYPE_SVC_DATA_UUID128; break;
896-
default: NIMBLE_LOGE(LOG_TAG, "Cannot set service data, invalid size!"); return false;
895+
default: log_e(LOG_TAG, "Cannot set service data, invalid size!"); return false;
897896
}
898897

899898
if (length == 0) {

‎libraries/NimBLE/src/BLELog.h

Lines changed: 0 additions & 146 deletions
This file was deleted.

‎libraries/NimBLE/src/BLERemoteCharacteristic.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "BLERemoteService.h"
2424
#include "BLEClient.h"
2525
#include "BLEUtils.h"
26-
#include "BLELog.h"
2726

2827
#include <climits>
2928

@@ -66,7 +65,7 @@ int BLERemoteCharacteristic::descriptorDiscCB(uint16_t connHandle, const ble_gat
6665
auto pTaskData = (BLETaskData *)filter->taskData;
6766
const auto pChr = (BLERemoteCharacteristic *)pTaskData->m_pInstance;
6867
const auto uuid = filter->uuid; // UUID to filter for
69-
NIMBLE_LOGD(LOG_TAG, "Descriptor Discovery >> status: %d handle: %d", rc, (rc == 0) ? dsc->handle : -1);
68+
log_d(LOG_TAG, "Descriptor Discovery >> status: %d handle: %d", rc, (rc == 0) ? dsc->handle : -1);
7069

7170
// Results for chrHandle added until rc != 0
7271
// Must find specified UUID if filter is used
@@ -78,7 +77,7 @@ int BLERemoteCharacteristic::descriptorDiscCB(uint16_t connHandle, const ble_gat
7877

7978
if (rc != 0) {
8079
BLEUtils::taskRelease(*pTaskData, rc);
81-
NIMBLE_LOGD(LOG_TAG, "<< Descriptor Discovery");
80+
log_d(LOG_TAG, "<< Descriptor Discovery");
8281
}
8382
return rc;
8483
}
@@ -89,30 +88,30 @@ int BLERemoteCharacteristic::descriptorDiscCB(uint16_t connHandle, const ble_gat
8988
* @return True if successfully retrieved, success = BLE_HS_EDONE.
9089
*/
9190
bool BLERemoteCharacteristic::retrieveDescriptors(BLEDescriptorFilter *filter) const {
92-
NIMBLE_LOGD(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());
91+
log_d(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());
9392

9493
// If this is the last handle then there are no descriptors
9594
if (getHandle() == getRemoteService()->getEndHandle()) {
96-
NIMBLE_LOGD(LOG_TAG, "<< retrieveDescriptors(): found 0 descriptors.");
95+
log_d(LOG_TAG, "<< retrieveDescriptors(): found 0 descriptors.");
9796
return true;
9897
}
9998

10099
int rc =
101100
ble_gattc_disc_all_dscs(getClient()->getConnHandle(), getHandle(), getRemoteService()->getEndHandle(), BLERemoteCharacteristic::descriptorDiscCB, filter);
102101
if (rc != 0) {
103-
NIMBLE_LOGE(LOG_TAG, "ble_gattc_disc_all_dscs: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
102+
log_e(LOG_TAG, "ble_gattc_disc_all_dscs: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
104103
return false;
105104
}
106105

107106
BLEUtils::taskWait(filter->taskData, BLE_NPL_TIME_FOREVER);
108107
rc = ((BLETaskData *)filter->taskData)->m_flags;
109108
if (rc != BLE_HS_EDONE) {
110-
NIMBLE_LOGE(LOG_TAG, "<< retrieveDescriptors(): failed: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
109+
log_e(LOG_TAG, "<< retrieveDescriptors(): failed: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
111110
return false;
112111
}
113112

114113
filter->dsc = m_vDescriptors.back();
115-
NIMBLE_LOGD(LOG_TAG, "<< retrieveDescriptors(): found %d descriptors.", m_vDescriptors.size());
114+
log_d(LOG_TAG, "<< retrieveDescriptors(): found %d descriptors.", m_vDescriptors.size());
116115
return true;
117116
} // retrieveDescriptors
118117

@@ -122,7 +121,7 @@ bool BLERemoteCharacteristic::retrieveDescriptors(BLEDescriptorFilter *filter) c
122121
* @return The Remote descriptor (if present) or nullptr if not present.
123122
*/
124123
BLERemoteDescriptor *BLERemoteCharacteristic::getDescriptor(const BLEUUID &uuid) const {
125-
NIMBLE_LOGD(LOG_TAG, ">> getDescriptor: uuid: %s", uuid.toString().c_str());
124+
log_d(LOG_TAG, ">> getDescriptor: uuid: %s", uuid.toString().c_str());
126125
BLETaskData taskData(const_cast<BLERemoteCharacteristic *>(this));
127126
BLEDescriptorFilter filter = {nullptr, &uuid, &taskData};
128127
BLEUUID uuidTmp;
@@ -151,7 +150,7 @@ BLERemoteDescriptor *BLERemoteCharacteristic::getDescriptor(const BLEUUID &uuid)
151150
}
152151

153152
Done:
154-
NIMBLE_LOGD(LOG_TAG, "<< getDescriptor: %sfound", filter.dsc ? "" : "not ");
153+
log_d(LOG_TAG, "<< getDescriptor: %sfound", filter.dsc ? "" : "not ");
155154
return filter.dsc;
156155
} // getDescriptor
157156

@@ -205,16 +204,16 @@ const BLERemoteService *BLERemoteCharacteristic::getRemoteService() const {
205204
* @return false if writing to the descriptor failed.
206205
*/
207206
bool BLERemoteCharacteristic::setNotify(uint16_t val, notify_callback notifyCallback, bool response) const {
208-
NIMBLE_LOGD(LOG_TAG, ">> setNotify()");
207+
log_d(LOG_TAG, ">> setNotify()");
209208

210209
m_notifyCallback = notifyCallback;
211210
BLERemoteDescriptor *desc = getDescriptor(BLEUUID((uint16_t)0x2902));
212211
if (desc == nullptr) {
213-
NIMBLE_LOGW(LOG_TAG, "<< setNotify(): Callback set, CCCD not found");
212+
log_w(LOG_TAG, "<< setNotify(): Callback set, CCCD not found");
214213
return true;
215214
}
216215

217-
NIMBLE_LOGD(LOG_TAG, "<< setNotify()");
216+
log_d(LOG_TAG, "<< setNotify()");
218217
return desc->writeValue(reinterpret_cast<uint8_t *>(&val), 2, response);
219218
} // setNotify
220219

@@ -246,14 +245,14 @@ bool BLERemoteCharacteristic::unsubscribe(bool response) const {
246245
* them. This method does just that.
247246
*/
248247
void BLERemoteCharacteristic::deleteDescriptors() const {
249-
NIMBLE_LOGD(LOG_TAG, ">> deleteDescriptors");
248+
log_d(LOG_TAG, ">> deleteDescriptors");
250249

251250
for (const auto &it : m_vDescriptors) {
252251
delete it;
253252
}
254253
std::vector<BLERemoteDescriptor *>().swap(m_vDescriptors);
255254

256-
NIMBLE_LOGD(LOG_TAG, "<< deleteDescriptors");
255+
log_d(LOG_TAG, "<< deleteDescriptors");
257256
} // deleteDescriptors
258257

259258
/**
@@ -262,7 +261,7 @@ void BLERemoteCharacteristic::deleteDescriptors() const {
262261
* @return Number of descriptors left in the vector.
263262
*/
264263
size_t BLERemoteCharacteristic::deleteDescriptor(const BLEUUID &uuid) const {
265-
NIMBLE_LOGD(LOG_TAG, ">> deleteDescriptor");
264+
log_d(LOG_TAG, ">> deleteDescriptor");
266265

267266
for (auto it = m_vDescriptors.begin(); it != m_vDescriptors.end(); ++it) {
268267
if ((*it)->getUUID() == uuid) {
@@ -272,7 +271,7 @@ size_t BLERemoteCharacteristic::deleteDescriptor(const BLEUUID &uuid) const {
272271
}
273272
}
274273

275-
NIMBLE_LOGD(LOG_TAG, "<< deleteDescriptor");
274+
log_d(LOG_TAG, "<< deleteDescriptor");
276275
return m_vDescriptors.size();
277276
} // deleteDescriptor
278277

‎libraries/NimBLE/src/BLERemoteService.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "BLEClient.h"
2424
#include "BLEAttValue.h"
2525
#include "BLEUtils.h"
26-
#include "BLELog.h"
2726

2827
#include <climits>
2928

@@ -75,7 +74,7 @@ BLERemoteCharacteristic *BLERemoteService::getCharacteristic(const char *uuid) c
7574
* @return A pointer to the characteristic object, or nullptr if not found.
7675
*/
7776
BLERemoteCharacteristic *BLERemoteService::getCharacteristic(const BLEUUID &uuid) const {
78-
NIMBLE_LOGD(LOG_TAG, ">> getCharacteristic: uuid: %s", uuid.toString().c_str());
77+
log_d(LOG_TAG, ">> getCharacteristic: uuid: %s", uuid.toString().c_str());
7978
BLERemoteCharacteristic *pChar = nullptr;
8079
size_t prev_size = m_vChars.size();
8180

@@ -119,7 +118,7 @@ BLERemoteCharacteristic *BLERemoteService::getCharacteristic(const BLEUUID &uuid
119118
}
120119

121120
Done:
122-
NIMBLE_LOGD(LOG_TAG, "<< Characteristic %sfound", pChar ? "" : "not ");
121+
log_d(LOG_TAG, "<< Characteristic %sfound", pChar ? "" : "not ");
123122
return pChar;
124123
} // getCharacteristic
125124

@@ -144,12 +143,12 @@ const std::vector<BLERemoteCharacteristic *> &BLERemoteService::getCharacteristi
144143
* @return success == 0 or error code.
145144
*/
146145
int BLERemoteService::characteristicDiscCB(uint16_t conn_handle, const ble_gatt_error *error, const ble_gatt_chr *chr, void *arg) {
147-
NIMBLE_LOGD(LOG_TAG, "Characteristic Discovery >> status: %d handle: %d", error->status, (error->status == 0) ? chr->def_handle : -1);
146+
log_d(LOG_TAG, "Characteristic Discovery >> status: %d handle: %d", error->status, (error->status == 0) ? chr->def_handle : -1);
148147
auto pTaskData = (BLETaskData *)arg;
149148
const auto pSvc = (BLERemoteService *)pTaskData->m_pInstance;
150149

151150
if (error->status == BLE_HS_ENOTCONN) {
152-
NIMBLE_LOGE(LOG_TAG, "<< Characteristic Discovery; Not connected");
151+
log_e(LOG_TAG, "<< Characteristic Discovery; Not connected");
153152
BLEUtils::taskRelease(*pTaskData, error->status);
154153
return error->status;
155154
}
@@ -165,7 +164,7 @@ int BLERemoteService::characteristicDiscCB(uint16_t conn_handle, const ble_gatt_
165164
}
166165

167166
BLEUtils::taskRelease(*pTaskData, error->status);
168-
NIMBLE_LOGD(LOG_TAG, "<< Characteristic Discovery");
167+
log_d(LOG_TAG, "<< Characteristic Discovery");
169168
return error->status;
170169
}
171170

@@ -175,7 +174,7 @@ int BLERemoteService::characteristicDiscCB(uint16_t conn_handle, const ble_gatt_
175174
* @return True if successful.
176175
*/
177176
bool BLERemoteService::retrieveCharacteristics(const BLEUUID *uuidFilter) const {
178-
NIMBLE_LOGD(LOG_TAG, ">> retrieveCharacteristics()");
177+
log_d(LOG_TAG, ">> retrieveCharacteristics()");
179178
int rc = 0;
180179
BLETaskData taskData(const_cast<BLERemoteService *>(this));
181180

@@ -188,18 +187,18 @@ bool BLERemoteService::retrieveCharacteristics(const BLEUUID *uuidFilter) const
188187
}
189188

190189
if (rc != 0) {
191-
NIMBLE_LOGE(LOG_TAG, "ble_gattc_disc_chrs rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
190+
log_e(LOG_TAG, "ble_gattc_disc_chrs rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
192191
return false;
193192
}
194193

195194
BLEUtils::taskWait(taskData, BLE_NPL_TIME_FOREVER);
196195
rc = taskData.m_flags;
197196
if (rc == 0 || rc == BLE_HS_EDONE) {
198-
NIMBLE_LOGD(LOG_TAG, "<< retrieveCharacteristics()");
197+
log_d(LOG_TAG, "<< retrieveCharacteristics()");
199198
return true;
200199
}
201200

202-
NIMBLE_LOGE(LOG_TAG, "<< retrieveCharacteristics() rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
201+
log_e(LOG_TAG, "<< retrieveCharacteristics() rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
203202
return false;
204203
} // retrieveCharacteristics
205204

‎libraries/NimBLE/src/BLERemoteValueAttribute.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
#include "BLERemoteValueAttribute.h"
2222
#include "BLEClient.h"
2323
#include "BLEUtils.h"
24-
#include "BLELog.h"
2524

2625
#include <climits>
2726

2827
static const char *LOG_TAG = "BLERemoteValueAttribute";
2928

3029
bool BLERemoteValueAttribute::writeValue(const uint8_t *data, size_t length, bool response) const {
31-
NIMBLE_LOGD(LOG_TAG, ">> writeValue()");
30+
log_d(LOG_TAG, ">> writeValue()");
3231

3332
const BLEClient *pClient = getClient();
3433
int retryCount = 1;
@@ -45,7 +44,7 @@ bool BLERemoteValueAttribute::writeValue(const uint8_t *data, size_t length, boo
4544

4645
do {
4746
if (length > mtu) {
48-
NIMBLE_LOGI(LOG_TAG, "writeValue: long write");
47+
log_i(LOG_TAG, "writeValue: long write");
4948
os_mbuf *om = ble_hs_mbuf_from_flat(data, length);
5049
rc = ble_gattc_write_long(pClient->getConnHandle(), getHandle(), 0, om, BLERemoteValueAttribute::onWriteCB, &taskData);
5150
} else {
@@ -62,7 +61,7 @@ bool BLERemoteValueAttribute::writeValue(const uint8_t *data, size_t length, boo
6261
case 0:
6362
case BLE_HS_EDONE: rc = 0; break;
6463
case BLE_HS_ATT_ERR(BLE_ATT_ERR_ATTR_NOT_LONG):
65-
NIMBLE_LOGE(LOG_TAG, "Long write not supported by peer; Truncating length to %d", mtu);
64+
log_e(LOG_TAG, "Long write not supported by peer; Truncating length to %d", mtu);
6665
retryCount++;
6766
length = mtu;
6867
break;
@@ -80,9 +79,9 @@ bool BLERemoteValueAttribute::writeValue(const uint8_t *data, size_t length, boo
8079

8180
Done:
8281
if (rc != 0) {
83-
NIMBLE_LOGE(LOG_TAG, "<< writeValue failed, rc: %d %s", rc, BLEUtils::returnCodeToString(rc));
82+
log_e(LOG_TAG, "<< writeValue failed, rc: %d %s", rc, BLEUtils::returnCodeToString(rc));
8483
} else {
85-
NIMBLE_LOGD(LOG_TAG, "<< writeValue");
84+
log_d(LOG_TAG, "<< writeValue");
8685
}
8786

8887
return (rc == 0);
@@ -97,7 +96,7 @@ int BLERemoteValueAttribute::onWriteCB(uint16_t conn_handle, const ble_gatt_erro
9796
const auto pAtt = static_cast<BLERemoteValueAttribute *>(pTaskData->m_pInstance);
9897

9998
if (error->status == BLE_HS_ENOTCONN) {
100-
NIMBLE_LOGE(LOG_TAG, "<< Write complete; Not connected");
99+
log_e(LOG_TAG, "<< Write complete; Not connected");
101100
BLEUtils::taskRelease(*pTaskData, error->status);
102101
return error->status;
103102
}
@@ -106,7 +105,7 @@ int BLERemoteValueAttribute::onWriteCB(uint16_t conn_handle, const ble_gatt_erro
106105
return 0;
107106
}
108107

109-
NIMBLE_LOGI(LOG_TAG, "Write complete; status=%d", error->status);
108+
log_i(LOG_TAG, "Write complete; status=%d", error->status);
110109
BLEUtils::taskRelease(*pTaskData, error->status);
111110
return 0;
112111
}
@@ -117,7 +116,7 @@ int BLERemoteValueAttribute::onWriteCB(uint16_t conn_handle, const ble_gatt_erro
117116
* @return The value of the remote characteristic.
118117
*/
119118
BLEAttValue BLERemoteValueAttribute::readValue(time_t *timestamp) const {
120-
NIMBLE_LOGD(LOG_TAG, ">> readValue()");
119+
log_d(LOG_TAG, ">> readValue()");
121120

122121
BLEAttValue value{};
123122
const BLEClient *pClient = getClient();
@@ -138,7 +137,7 @@ BLEAttValue BLERemoteValueAttribute::readValue(time_t *timestamp) const {
138137
case BLE_HS_EDONE: rc = 0; break;
139138
// Characteristic is not long-readable, return with what we have.
140139
case BLE_HS_ATT_ERR(BLE_ATT_ERR_ATTR_NOT_LONG):
141-
NIMBLE_LOGI(LOG_TAG, "Attribute not long");
140+
log_i(LOG_TAG, "Attribute not long");
142141
rc = ble_gattc_read(pClient->getConnHandle(), getHandle(), BLERemoteValueAttribute::onReadCB, &taskData);
143142
if (rc != 0) {
144143
goto Done;
@@ -164,9 +163,9 @@ BLEAttValue BLERemoteValueAttribute::readValue(time_t *timestamp) const {
164163

165164
Done:
166165
if (rc != 0) {
167-
NIMBLE_LOGE(LOG_TAG, "<< readValue failed rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
166+
log_e(LOG_TAG, "<< readValue failed rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
168167
} else {
169-
NIMBLE_LOGD(LOG_TAG, "<< readValue");
168+
log_d(LOG_TAG, "<< readValue");
170169
}
171170

172171
return value;
@@ -181,7 +180,7 @@ int BLERemoteValueAttribute::onReadCB(uint16_t conn_handle, const ble_gatt_error
181180
const auto pAtt = static_cast<BLERemoteValueAttribute *>(pTaskData->m_pInstance);
182181

183182
if (error->status == BLE_HS_ENOTCONN) {
184-
NIMBLE_LOGE(LOG_TAG, "<< Read complete; Not connected");
183+
log_e(LOG_TAG, "<< Read complete; Not connected");
185184
BLEUtils::taskRelease(*pTaskData, error->status);
186185
return error->status;
187186
}
@@ -191,7 +190,7 @@ int BLERemoteValueAttribute::onReadCB(uint16_t conn_handle, const ble_gatt_error
191190
}
192191

193192
int rc = error->status;
194-
NIMBLE_LOGI(LOG_TAG, "Read complete; status=%d", rc);
193+
log_i(LOG_TAG, "Read complete; status=%d", rc);
195194

196195
if (rc == 0) {
197196
if (attr) {
@@ -200,7 +199,7 @@ int BLERemoteValueAttribute::onReadCB(uint16_t conn_handle, const ble_gatt_error
200199
if ((valBuf->size() + data_len) > BLE_ATT_ATTR_MAX_LEN) {
201200
rc = BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
202201
} else {
203-
NIMBLE_LOGD(LOG_TAG, "Got %u bytes", data_len);
202+
log_d(LOG_TAG, "Got %u bytes", data_len);
204203
valBuf->append(attr->om->om_data, data_len);
205204
return 0;
206205
}

‎libraries/NimBLE/src/BLEScan.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEScan.h"
2222
#include "BLEDevice.h"
23-
#include "BLELog.h"
2423

2524
#include <string>
2625
#include <climits>
@@ -71,7 +70,7 @@ int BLEScan::handleGapEvent(ble_gap_event *event, void *arg) {
7170
// stop processing if already connected
7271
BLEClient *pClient = BLEDevice::getClientByPeerAddress(advertisedAddress);
7372
if (pClient != nullptr && pClient->isConnected()) {
74-
NIMBLE_LOGI(LOG_TAG, "Ignoring device: address: %s, already connected", advertisedAddress.toString().c_str());
73+
log_i(LOG_TAG, "Ignoring device: address: %s, already connected", advertisedAddress.toString().c_str());
7574
return 0;
7675
}
7776
#endif
@@ -101,18 +100,18 @@ int BLEScan::handleGapEvent(ble_gap_event *event, void *arg) {
101100
}
102101

103102
if (isLegacyAdv && event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP) {
104-
NIMBLE_LOGI(LOG_TAG, "Scan response without advertisement: %s", advertisedAddress.toString().c_str());
103+
log_i(LOG_TAG, "Scan response without advertisement: %s", advertisedAddress.toString().c_str());
105104
}
106105

107106
advertisedDevice = new BLEAdvertisedDevice(event, event_type);
108107
pScan->m_scanResults.m_deviceVec.push_back(advertisedDevice);
109-
NIMBLE_LOGI(LOG_TAG, "New advertiser: %s", advertisedAddress.toString().c_str());
108+
log_i(LOG_TAG, "New advertiser: %s", advertisedAddress.toString().c_str());
110109
} else {
111110
advertisedDevice->update(event, event_type);
112111
if (isLegacyAdv && event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP) {
113-
NIMBLE_LOGI(LOG_TAG, "Scan response from: %s", advertisedAddress.toString().c_str());
112+
log_i(LOG_TAG, "Scan response from: %s", advertisedAddress.toString().c_str());
114113
} else {
115-
NIMBLE_LOGI(LOG_TAG, "Duplicate; updated: %s", advertisedAddress.toString().c_str());
114+
log_i(LOG_TAG, "Duplicate; updated: %s", advertisedAddress.toString().c_str());
116115
}
117116
}
118117

@@ -142,7 +141,7 @@ int BLEScan::handleGapEvent(ble_gap_event *event, void *arg) {
142141

143142
case BLE_GAP_EVENT_DISC_COMPLETE:
144143
{
145-
NIMBLE_LOGD(LOG_TAG, "discovery complete; reason=%d", event->disc_complete.reason);
144+
log_d(LOG_TAG, "discovery complete; reason=%d", event->disc_complete.reason);
146145

147146
if (pScan->m_maxResults == 0) {
148147
pScan->clearResults();
@@ -296,10 +295,10 @@ void BLEScan::setPeriod(uint32_t periodMs) {
296295
* @return True if scan started or false if there was an error.
297296
*/
298297
bool BLEScan::start(uint32_t duration, bool isContinue, bool restart) {
299-
NIMBLE_LOGD(LOG_TAG, ">> start: duration=%" PRIu32, duration);
298+
log_d(LOG_TAG, ">> start: duration=%" PRIu32, duration);
300299
if (isScanning()) {
301300
if (restart) {
302-
NIMBLE_LOGI(LOG_TAG, "Scan already in progress, restarting it");
301+
log_i(LOG_TAG, "Scan already in progress, restarting it");
303302
if (!stop()) {
304303
return false;
305304
}
@@ -332,19 +331,19 @@ bool BLEScan::start(uint32_t duration, bool isContinue, bool restart) {
332331
#endif
333332
switch (rc) {
334333
case 0:
335-
case BLE_HS_EALREADY: NIMBLE_LOGD(LOG_TAG, "Scan started"); break;
334+
case BLE_HS_EALREADY: log_d(LOG_TAG, "Scan started"); break;
336335

337-
case BLE_HS_EBUSY: NIMBLE_LOGE(LOG_TAG, "Unable to scan - connection in progress."); break;
336+
case BLE_HS_EBUSY: log_e(LOG_TAG, "Unable to scan - connection in progress."); break;
338337

339338
case BLE_HS_ETIMEOUT_HCI:
340339
case BLE_HS_EOS:
341340
case BLE_HS_ECONTROLLER:
342-
case BLE_HS_ENOTSYNCED: NIMBLE_LOGE(LOG_TAG, "Unable to scan - Host Reset"); break;
341+
case BLE_HS_ENOTSYNCED: log_e(LOG_TAG, "Unable to scan - Host Reset"); break;
343342

344-
default: NIMBLE_LOGE(LOG_TAG, "Error starting scan; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc)); break;
343+
default: log_e(LOG_TAG, "Error starting scan; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc)); break;
345344
}
346345

347-
NIMBLE_LOGD(LOG_TAG, "<< start()");
346+
log_d(LOG_TAG, "<< start()");
348347
return rc == 0 || rc == BLE_HS_EALREADY;
349348
} // start
350349

@@ -353,11 +352,11 @@ bool BLEScan::start(uint32_t duration, bool isContinue, bool restart) {
353352
* @return True if successful.
354353
*/
355354
bool BLEScan::stop() {
356-
NIMBLE_LOGD(LOG_TAG, ">> stop()");
355+
log_d(LOG_TAG, ">> stop()");
357356

358357
int rc = ble_gap_disc_cancel();
359358
if (rc != 0 && rc != BLE_HS_EALREADY) {
360-
NIMBLE_LOGE(LOG_TAG, "Failed to cancel scan; rc=%d", rc);
359+
log_e(LOG_TAG, "Failed to cancel scan; rc=%d", rc);
361360
return false;
362361
}
363362

@@ -369,7 +368,7 @@ bool BLEScan::stop() {
369368
BLEUtils::taskRelease(*m_pTaskData);
370369
}
371370

372-
NIMBLE_LOGD(LOG_TAG, "<< stop()");
371+
log_d(LOG_TAG, "<< stop()");
373372
return true;
374373
} // stop
375374

@@ -378,7 +377,7 @@ bool BLEScan::stop() {
378377
* @param [in] address The address of the device to delete from the results.
379378
*/
380379
void BLEScan::erase(const BLEAddress &address) {
381-
NIMBLE_LOGD(LOG_TAG, "erase device: %s", address.toString().c_str());
380+
log_d(LOG_TAG, "erase device: %s", address.toString().c_str());
382381
for (auto it = m_scanResults.m_deviceVec.begin(); it != m_scanResults.m_deviceVec.end(); ++it) {
383382
if ((*it)->getAddress() == address) {
384383
delete *it;
@@ -393,7 +392,7 @@ void BLEScan::erase(const BLEAddress &address) {
393392
* @param [in] device The device to delete from the results.
394393
*/
395394
void BLEScan::erase(const BLEAdvertisedDevice *device) {
396-
NIMBLE_LOGD(LOG_TAG, "erase device: %s", device->getAddress().toString().c_str());
395+
log_d(LOG_TAG, "erase device: %s", device->getAddress().toString().c_str());
397396
for (auto it = m_scanResults.m_deviceVec.begin(); it != m_scanResults.m_deviceVec.end(); ++it) {
398397
if ((*it) == device) {
399398
delete *it;
@@ -419,11 +418,11 @@ void BLEScan::onHostSync() {
419418
*/
420419
BLEScanResults BLEScan::getResults(uint32_t duration, bool is_continue) {
421420
if (duration == 0) {
422-
NIMBLE_LOGW(LOG_TAG, "Blocking scan called with duration = forever");
421+
log_w(LOG_TAG, "Blocking scan called with duration = forever");
423422
}
424423

425424
if (m_pTaskData != nullptr) {
426-
NIMBLE_LOGE(LOG_TAG, "Scan already in progress");
425+
log_e(LOG_TAG, "Scan already in progress");
427426
return m_scanResults;
428427
}
429428

@@ -467,7 +466,7 @@ void BLEScan::clearResults() {
467466
void BLEScanResults::dump() const {
468467
#if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 3
469468
for (const auto &dev : m_deviceVec) {
470-
NIMBLE_LOGI(LOG_TAG, "- %s", dev->toString().c_str());
469+
log_i(LOG_TAG, "- %s", dev->toString().c_str());
471470
}
472471
#endif
473472
} // dump
@@ -525,15 +524,15 @@ const BLEAdvertisedDevice *BLEScanResults::getDevice(const BLEAddress &address)
525524
static const char *CB_TAG = "BLEScanCallbacks";
526525

527526
void BLEScanCallbacks::onDiscovered(const BLEAdvertisedDevice *pAdvertisedDevice) {
528-
NIMBLE_LOGD(CB_TAG, "Discovered: %s", pAdvertisedDevice->toString().c_str());
527+
log_d(CB_TAG, "Discovered: %s", pAdvertisedDevice->toString().c_str());
529528
}
530529

531530
void BLEScanCallbacks::onResult(const BLEAdvertisedDevice *pAdvertisedDevice) {
532-
NIMBLE_LOGD(CB_TAG, "Result: %s", pAdvertisedDevice->toString().c_str());
531+
log_d(CB_TAG, "Result: %s", pAdvertisedDevice->toString().c_str());
533532
}
534533

535534
void BLEScanCallbacks::onScanEnd(const BLEScanResults &results, int reason) {
536-
NIMBLE_LOGD(CB_TAG, "Scan ended; reason %d, num results: %d", reason, results.getCount());
535+
log_d(CB_TAG, "Scan ended; reason %d, num results: %d", reason, results.getCount());
537536
}
538537

539538
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_OBSERVER */

‎libraries/NimBLE/src/BLEServer.cpp

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEServer.h"
2222
#include "BLEDevice.h"
23-
#include "BLELog.h"
2423

2524
#if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
2625
#include "BLEClient.h"
@@ -178,7 +177,7 @@ void BLEServer::start() {
178177

179178
int rc = ble_gatts_start();
180179
if (rc != 0) {
181-
NIMBLE_LOGE(LOG_TAG, "ble_gatts_start; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
180+
log_e(LOG_TAG, "ble_gatts_start; rc=%d, %s", rc, BLEUtils::returnCodeToString(rc));
182181
return;
183182
}
184183

@@ -192,7 +191,7 @@ void BLEServer::start() {
192191
if (svc->getRemoved() == 0) {
193192
rc = ble_gatts_find_svc(svc->getUUID().getBase(), &svc->m_handle);
194193
if (rc != 0) {
195-
NIMBLE_LOGW(
194+
log_w(
196195
LOG_TAG, "GATT Server started without service: %s, Service %s", svc->getUUID().toString().c_str(), svc->isStarted() ? "missing" : "not started"
197196
);
198197
continue; // Skip this service as it was not started
@@ -225,7 +224,7 @@ void BLEServer::start() {
225224
bool BLEServer::disconnect(uint16_t connHandle, uint8_t reason) const {
226225
int rc = ble_gap_terminate(connHandle, reason);
227226
if (rc != 0 && rc != BLE_HS_ENOTCONN && rc != BLE_HS_EALREADY) {
228-
NIMBLE_LOGE(LOG_TAG, "ble_gap_terminate failed: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
227+
log_e(LOG_TAG, "ble_gap_terminate failed: rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
229228
return false;
230229
}
231230

@@ -289,7 +288,7 @@ std::vector<uint16_t> BLEServer::getPeerDevices() const {
289288
*/
290289
BLEConnInfo BLEServer::getPeerInfo(uint8_t index) const {
291290
if (index >= m_connectedPeers.size()) {
292-
NIMBLE_LOGE(LOG_TAG, "Invalid index %u", index);
291+
log_e(LOG_TAG, "Invalid index %u", index);
293292
return BLEConnInfo{};
294293
}
295294

@@ -314,7 +313,7 @@ BLEConnInfo BLEServer::getPeerInfo(uint8_t index) const {
314313
BLEConnInfo BLEServer::getPeerInfo(const BLEAddress &address) const {
315314
BLEConnInfo peerInfo{};
316315
if (ble_gap_conn_find_by_addr(address.getBase(), &peerInfo.m_desc) != 0) {
317-
NIMBLE_LOGE(LOG_TAG, "Peer info not found");
316+
log_e(LOG_TAG, "Peer info not found");
318317
}
319318

320319
return peerInfo;
@@ -328,7 +327,7 @@ BLEConnInfo BLEServer::getPeerInfo(const BLEAddress &address) const {
328327
BLEConnInfo BLEServer::getPeerInfoByHandle(uint16_t connHandle) const {
329328
BLEConnInfo peerInfo{};
330329
if (ble_gap_conn_find(connHandle, &peerInfo.m_desc) != 0) {
331-
NIMBLE_LOGE(LOG_TAG, "Peer info not found");
330+
log_e(LOG_TAG, "Peer info not found");
332331
}
333332

334333
return peerInfo;
@@ -338,7 +337,7 @@ BLEConnInfo BLEServer::getPeerInfoByHandle(uint16_t connHandle) const {
338337
* @brief Gap event handler.
339338
*/
340339
int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
341-
NIMBLE_LOGD(LOG_TAG, ">> handleGapEvent: %s", BLEUtils::gapEventToString(event->type));
340+
log_d(LOG_TAG, ">> handleGapEvent: %s", BLEUtils::gapEventToString(event->type));
342341

343342
int rc = 0;
344343
BLEConnInfo peerInfo{};
@@ -348,7 +347,7 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
348347
case BLE_GAP_EVENT_CONNECT:
349348
{
350349
if (event->connect.status != 0) {
351-
NIMBLE_LOGE(LOG_TAG, "Connection failed");
350+
log_e(LOG_TAG, "Connection failed");
352351
#if !CONFIG_BT_NIMBLE_EXT_ADV
353352
BLEDevice::startAdvertising();
354353
#endif
@@ -380,7 +379,7 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
380379
case BLE_HS_EOS:
381380
case BLE_HS_ECONTROLLER:
382381
case BLE_HS_ENOTSYNCED:
383-
NIMBLE_LOGE(LOG_TAG, "Disconnect - host reset, rc=%d", event->disconnect.reason);
382+
log_e(LOG_TAG, "Disconnect - host reset, rc=%d", event->disconnect.reason);
384383
BLEDevice::onReset(event->disconnect.reason);
385384
break;
386385
default: break;
@@ -416,7 +415,7 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
416415

417416
case BLE_GAP_EVENT_SUBSCRIBE:
418417
{
419-
NIMBLE_LOGI(
418+
log_i(
420419
LOG_TAG, "subscribe event; attr_handle=%d, subscribed: %s", event->subscribe.attr_handle,
421420
((event->subscribe.cur_notify || event->subscribe.cur_indicate) ? "true" : "false")
422421
);
@@ -445,7 +444,7 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
445444

446445
case BLE_GAP_EVENT_MTU:
447446
{
448-
NIMBLE_LOGI(LOG_TAG, "mtu update event; conn_handle=%d mtu=%d", event->mtu.conn_handle, event->mtu.value);
447+
log_i(LOG_TAG, "mtu update event; conn_handle=%d mtu=%d", event->mtu.conn_handle, event->mtu.value);
449448
if (ble_gap_conn_find(event->mtu.conn_handle, &peerInfo.m_desc) == 0) {
450449
pServer->m_pServerCallbacks->onMTUChange(event->mtu.value, peerInfo);
451450
}
@@ -567,10 +566,10 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
567566
pkey.passkey = pServer->m_pServerCallbacks->onPassKeyDisplay();
568567
}
569568
rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
570-
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d", rc);
569+
log_d(LOG_TAG, "BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d", rc);
571570

572571
} else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) {
573-
NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %" PRIu32, event->passkey.params.numcmp);
572+
log_d(LOG_TAG, "Passkey on device's display: %" PRIu32, event->passkey.params.numcmp);
574573

575574
rc = ble_gap_conn_find(event->passkey.conn_handle, &peerInfo.m_desc);
576575
if (rc != 0) {
@@ -586,9 +585,9 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
586585
// pkey.oob[i] = tem_oob[i];
587586
// }
588587
// rc = ble_sm_inject_io(event->passkey.conn_handle, &pkey);
589-
// NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_OOB; ble_sm_inject_io result: %d", rc);
588+
// log_d(LOG_TAG, "BLE_SM_IOACT_OOB; ble_sm_inject_io result: %d", rc);
590589
} else if (event->passkey.params.action == BLE_SM_IOACT_NONE) {
591-
NIMBLE_LOGD(LOG_TAG, "No passkey action required");
590+
log_d(LOG_TAG, "No passkey action required");
592591
}
593592

594593
break;
@@ -597,15 +596,15 @@ int BLEServer::handleGapEvent(ble_gap_event *event, void *arg) {
597596
default: break;
598597
}
599598

600-
NIMBLE_LOGD(LOG_TAG, "<< handleGapEvent");
599+
log_d(LOG_TAG, "<< handleGapEvent");
601600
return 0;
602601
} // handleGapEvent
603602

604603
/**
605604
* @brief GATT event handler.
606605
*/
607606
int BLEServer::handleGattEvent(uint16_t connHandle, uint16_t attrHandle, ble_gatt_access_ctxt *ctxt, void *arg) {
608-
NIMBLE_LOGD(LOG_TAG, "Gatt %s event", (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) ? "Read" : "Write");
607+
log_d(LOG_TAG, "Gatt %s event", (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) ? "Read" : "Write");
609608
auto pAtt = static_cast<BLELocalValueAttribute *>(arg);
610609
const BLEAttValue &val = pAtt->getAttVal();
611610

@@ -742,7 +741,7 @@ void BLEServer::removeService(BLEService *service, bool deleteSvc) {
742741
void BLEServer::addService(BLEService *service) {
743742
// Check that a service with the supplied UUID does not already exist.
744743
if (getServiceByUUID(service->getUUID()) != nullptr) {
745-
NIMBLE_LOGW(LOG_TAG, "Warning creating a duplicate service UUID: %s", std::string(service->getUUID()).c_str());
744+
log_w(LOG_TAG, "Warning creating a duplicate service UUID: %s", std::string(service->getUUID()).c_str());
746745
}
747746

748747
// If adding a service that was not removed add it and return.
@@ -832,7 +831,7 @@ bool BLEServer::stopAdvertising(uint8_t instId) const {
832831
bool BLEServer::updatePhy(uint16_t connHandle, uint8_t txPhyMask, uint8_t rxPhyMask, uint16_t phyOptions) {
833832
int rc = ble_gap_set_prefered_le_phy(connHandle, txPhyMask, rxPhyMask, phyOptions);
834833
if (rc != 0) {
835-
NIMBLE_LOGE(LOG_TAG, "Failed to update phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
834+
log_e(LOG_TAG, "Failed to update phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
836835
}
837836

838837
return rc == 0;
@@ -848,7 +847,7 @@ bool BLEServer::updatePhy(uint16_t connHandle, uint8_t txPhyMask, uint8_t rxPhyM
848847
bool BLEServer::getPhy(uint16_t connHandle, uint8_t *txPhy, uint8_t *rxPhy) {
849848
int rc = ble_gap_read_le_phy(connHandle, txPhy, rxPhy);
850849
if (rc != 0) {
851-
NIMBLE_LOGE(LOG_TAG, "Failed to read phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
850+
log_e(LOG_TAG, "Failed to read phy; rc=%d %s", rc, BLEUtils::returnCodeToString(rc));
852851
}
853852

854853
return rc == 0;
@@ -906,7 +905,7 @@ void BLEServer::updateConnParams(uint16_t connHandle, uint16_t minInterval, uint
906905

907906
int rc = ble_gap_update_params(connHandle, &params);
908907
if (rc != 0) {
909-
NIMBLE_LOGE(LOG_TAG, "Update params error: %d, %s", rc, BLEUtils::returnCodeToString(rc));
908+
log_e(LOG_TAG, "Update params error: %d, %s", rc, BLEUtils::returnCodeToString(rc));
910909
}
911910
} // updateConnParams
912911

@@ -924,7 +923,7 @@ void BLEServer::setDataLen(uint16_t connHandle, uint16_t octets) const {
924923

925924
int rc = ble_gap_set_data_len(connHandle, octets, tx_time);
926925
if (rc != 0) {
927-
NIMBLE_LOGE(LOG_TAG, "Set data length error: %d, %s", rc, BLEUtils::returnCodeToString(rc));
926+
log_e(LOG_TAG, "Set data length error: %d, %s", rc, BLEUtils::returnCodeToString(rc));
928927
}
929928
} // setDataLen
930929

@@ -940,7 +939,7 @@ BLEClient *BLEServer::getClient(uint16_t connHandle) {
940939
BLEConnInfo connInfo;
941940
int rc = ble_gap_conn_find(connHandle, &connInfo.m_desc);
942941
if (rc != 0) {
943-
NIMBLE_LOGE(LOG_TAG, "Client info not found");
942+
log_e(LOG_TAG, "Client info not found");
944943
return nullptr;
945944
}
946945

@@ -978,42 +977,42 @@ void BLEServer::deleteClient() {
978977

979978
/** Default callback handlers */
980979
void BLEServerCallbacks::onConnect(BLEServer *pServer, BLEConnInfo &connInfo) {
981-
NIMBLE_LOGD("BLEServerCallbacks", "onConnect(): Default");
980+
log_d("BLEServerCallbacks", "onConnect(): Default");
982981
} // onConnect
983982

984983
void BLEServerCallbacks::onDisconnect(BLEServer *pServer, BLEConnInfo &connInfo, int reason) {
985-
NIMBLE_LOGD("BLEServerCallbacks", "onDisconnect(): Default");
984+
log_d("BLEServerCallbacks", "onDisconnect(): Default");
986985
} // onDisconnect
987986

988987
void BLEServerCallbacks::onMTUChange(uint16_t MTU, BLEConnInfo &connInfo) {
989-
NIMBLE_LOGD("BLEServerCallbacks", "onMTUChange(): Default");
988+
log_d("BLEServerCallbacks", "onMTUChange(): Default");
990989
} // onMTUChange
991990

992991
uint32_t BLEServerCallbacks::onPassKeyDisplay() {
993-
NIMBLE_LOGD("BLEServerCallbacks", "onPassKeyDisplay: default: 123456");
992+
log_d("BLEServerCallbacks", "onPassKeyDisplay: default: 123456");
994993
return 123456;
995994
} // onPassKeyDisplay
996995

997996
void BLEServerCallbacks::onConfirmPassKey(BLEConnInfo &connInfo, uint32_t pin) {
998-
NIMBLE_LOGD("BLEServerCallbacks", "onConfirmPasskey: default: true");
997+
log_d("BLEServerCallbacks", "onConfirmPasskey: default: true");
999998
BLEDevice::injectConfirmPasskey(connInfo, true);
1000999
} // onConfirmPasskey
10011000

10021001
void BLEServerCallbacks::onIdentity(BLEConnInfo &connInfo) {
1003-
NIMBLE_LOGD("BLEServerCallbacks", "onIdentity: default");
1002+
log_d("BLEServerCallbacks", "onIdentity: default");
10041003
} // onIdentity
10051004

10061005
void BLEServerCallbacks::onAuthenticationComplete(BLEConnInfo &connInfo) {
1007-
NIMBLE_LOGD("BLEServerCallbacks", "onAuthenticationComplete: default");
1006+
log_d("BLEServerCallbacks", "onAuthenticationComplete: default");
10081007
} // onAuthenticationComplete
10091008

10101009
void BLEServerCallbacks::onConnParamsUpdate(BLEConnInfo &connInfo) {
1011-
NIMBLE_LOGD("BLEServerCallbacks", "onConnParamsUpdate: default");
1010+
log_d("BLEServerCallbacks", "onConnParamsUpdate: default");
10121011
} // onConnParamsUpdate
10131012

10141013
#if CONFIG_BT_NIMBLE_EXT_ADV
10151014
void BLEServerCallbacks::onPhyUpdate(BLEConnInfo &connInfo, uint8_t txPhy, uint8_t rxPhy) {
1016-
NIMBLE_LOGD("BLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
1015+
log_d("BLEServerCallbacks", "onPhyUpdate: default, txPhy: %d, rxPhy: %d", txPhy, rxPhy);
10171016
} // onPhyUpdate
10181017
#endif
10191018

‎libraries/NimBLE/src/BLEService.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#endif
2727
#include "BLEDevice.h"
2828
#include "BLEUtils.h"
29-
#include "BLELog.h"
3029

3130
#include <string>
3231

@@ -64,7 +63,7 @@ BLEService::~BLEService() {
6463
* @brief Dump details of this BLE GATT service.
6564
*/
6665
void BLEService::dump() const {
67-
NIMBLE_LOGD(LOG_TAG, "Service: uuid:%s, handle: 0x%2x", getUUID().toString().c_str(), getHandle());
66+
log_d(LOG_TAG, "Service: uuid:%s, handle: 0x%2x", getUUID().toString().c_str(), getHandle());
6867

6968
std::string res;
7069
int count = 0;
@@ -80,7 +79,7 @@ void BLEService::dump() const {
8079
res += ", uuid: " + std::string(it->getUUID());
8180
}
8281

83-
NIMBLE_LOGD(LOG_TAG, "Characteristics:\n%s", res.c_str());
82+
log_d(LOG_TAG, "Characteristics:\n%s", res.c_str());
8483
} // dump
8584

8685
/**
@@ -89,7 +88,7 @@ void BLEService::dump() const {
8988
* @return bool success/failure .
9089
*/
9190
bool BLEService::start() {
92-
NIMBLE_LOGD(LOG_TAG, ">> start(): Starting service: %s", toString().c_str());
91+
log_d(LOG_TAG, ">> start(): Starting service: %s", toString().c_str());
9392

9493
// If started previously and no characteristics have been added or removed,
9594
// then we can skip the service registration process.
@@ -113,7 +112,7 @@ bool BLEService::start() {
113112
++numChrs;
114113
}
115114

116-
NIMBLE_LOGD(LOG_TAG, "Adding %d characteristics for service %s", numChrs, toString().c_str());
115+
log_d(LOG_TAG, "Adding %d characteristics for service %s", numChrs, toString().c_str());
117116
if (numChrs) {
118117
int i = 0;
119118

@@ -170,17 +169,17 @@ bool BLEService::start() {
170169
m_pSvcDef->type = BLE_GATT_SVC_TYPE_PRIMARY;
171170
int rc = ble_gatts_count_cfg(m_pSvcDef);
172171
if (rc != 0) {
173-
NIMBLE_LOGE(LOG_TAG, "ble_gatts_count_cfg failed, rc= %d, %s", rc, BLEUtils::returnCodeToString(rc));
172+
log_e(LOG_TAG, "ble_gatts_count_cfg failed, rc= %d, %s", rc, BLEUtils::returnCodeToString(rc));
174173
return false;
175174
}
176175

177176
rc = ble_gatts_add_svcs(m_pSvcDef);
178177
if (rc != 0) {
179-
NIMBLE_LOGE(LOG_TAG, "ble_gatts_add_svcs, rc= %d, %s", rc, BLEUtils::returnCodeToString(rc));
178+
log_e(LOG_TAG, "ble_gatts_add_svcs, rc= %d, %s", rc, BLEUtils::returnCodeToString(rc));
180179
return false;
181180
}
182181

183-
NIMBLE_LOGD(LOG_TAG, "<< start()");
182+
log_d(LOG_TAG, "<< start()");
184183
return true;
185184
} // start
186185

@@ -205,7 +204,7 @@ BLECharacteristic *BLEService::createCharacteristic(const char *uuid, uint32_t p
205204
BLECharacteristic *BLEService::createCharacteristic(const BLEUUID &uuid, uint32_t properties, uint16_t max_len) {
206205
BLECharacteristic *pChar = new BLECharacteristic(uuid, properties, max_len, this);
207206
if (getCharacteristic(uuid) != nullptr) {
208-
NIMBLE_LOGD(LOG_TAG, "Adding a duplicate characteristic with UUID: %s", std::string(uuid).c_str());
207+
log_d(LOG_TAG, "Adding a duplicate characteristic with UUID: %s", std::string(uuid).c_str());
209208
}
210209

211210
addCharacteristic(pChar);

‎libraries/NimBLE/src/BLEUUID.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEUtils.h"
2222
#include "BLEUUID.h"
23-
#include "BLELog.h"
2423

2524
/**** FIX COMPILATION ****/
2625
#undef min
@@ -73,7 +72,7 @@ BLEUUID::BLEUUID(const std::string &value) {
7372
memcpy(m_uuid.u128.value, &second_half, 8);
7473
m_uuid.u.type = BLE_UUID_TYPE_128;
7574
} else {
76-
NIMBLE_LOGE(LOG_TAG, "Invalid UUID length");
75+
log_e(LOG_TAG, "Invalid UUID length");
7776
m_uuid.u.type = 0;
7877
}
7978
} // BLEUUID(std::string)
@@ -85,7 +84,7 @@ BLEUUID::BLEUUID(const std::string &value) {
8584
*/
8685
BLEUUID::BLEUUID(const uint8_t *pData, size_t size) {
8786
if (ble_uuid_init_from_buf(&m_uuid, pData, size)) {
88-
NIMBLE_LOGE(LOG_TAG, "Invalid UUID size");
87+
log_e(LOG_TAG, "Invalid UUID size");
8988
m_uuid.u.type = 0;
9089
}
9190
} // BLEUUID(const uint8_t* pData, size_t size)

‎libraries/NimBLE/src/BLEUtils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "BLEUtils.h"
2222
#include "BLEAddress.h"
23-
#include "BLELog.h"
2423

2524
#include "host/ble_hs.h"
2625

@@ -57,7 +56,7 @@ BLETaskData::BLETaskData(void *pInstance, int flags, void *buf)
5756
{
5857
ble_npl_sem *sem = new ble_npl_sem;
5958
if (ble_npl_sem_init(sem, 0) != BLE_NPL_OK) {
60-
NIMBLE_LOGE(LOG_TAG, "Failed to init semaphore");
59+
log_e(LOG_TAG, "Failed to init semaphore");
6160
delete sem;
6261
m_pHandle = nullptr;
6362
} else {
@@ -390,7 +389,7 @@ const char *BLEUtils::gapEventToString(uint8_t eventType) {
390389
return "BLE_GAP_EVENT_LINK_ESTAB";
391390
#endif
392391
#endif
393-
default: NIMBLE_LOGD(LOG_TAG, "Unknown event type %d 0x%.2x", eventType, eventType); return "Unknown event type";
392+
default: log_d(LOG_TAG, "Unknown event type %d 0x%.2x", eventType, eventType); return "Unknown event type";
394393
}
395394
#else // #if defined(CONFIG_NIMBLE_CPP_ENABLE_GAP_EVENT_CODE_TEXT)
396395
(void)eventType;
@@ -427,7 +426,7 @@ BLEAddress BLEUtils::generateAddr(bool nrpa) {
427426
ble_addr_t addr{};
428427
int rc = ble_hs_id_gen_rnd(nrpa, &addr);
429428
if (rc != 0) {
430-
NIMBLE_LOGE(LOG_TAG, "Generate address failed, rc=%d", rc);
429+
log_e(LOG_TAG, "Generate address failed, rc=%d", rc);
431430
}
432431

433432
return BLEAddress{addr};

0 commit comments

Comments
 (0)
Please sign in to comment.