Skip to content

Commit 5896b2b

Browse files
committed
BLEAdvertiseDevice refactor toString method: Added RSSI / serviceData
espressif/arduino-esp32#7561
1 parent b118677 commit 5896b2b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/BLEAdvertisedDevice.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,18 @@ std::string BLEAdvertisedDevice::toString() {
560560
res += ", txPower: ";
561561
res += val;
562562
}
563-
return res;
563+
if (haveRSSI()) {
564+
char val[4];
565+
snprintf(val, sizeof(val), "%i", getRSSI());
566+
res += ", rssi: ";
567+
res += val;
568+
}
569+
if (haveServiceData()) {
570+
for (int i=0; i <getServiceDataCount(); i++) {
571+
res += ", serviceData: " + getServiceData(i);
572+
}
573+
}
574+
return res;
564575
} // toString
565576

566577
uint8_t* BLEAdvertisedDevice::getPayload() {

0 commit comments

Comments
 (0)