Skip to content

Commit aa5486b

Browse files
authored
Fixes Eddystone URL decoding
1 parent c9bf68d commit aa5486b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: libraries/BLE/examples/BLE_Beacon_Scanner/BLE_Beacon_Scanner.ino

+3-4
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
8787
{
8888
Serial.println("Found an EddystoneURL beacon!");
8989
BLEEddystoneURL foundEddyURL = BLEEddystoneURL();
90-
std::string eddyContent((char *)payLoad); // incomplete EddystoneURL struct!
91-
92-
foundEddyURL.setData(eddyContent);
90+
uint8_t URLLen = *(payLoad - 4) - 3; // Get Field Length less 3 bytes (type and UUID)
91+
foundEddyURL.setData(std::string((char*)payLoad, URLLen));
9392
std::string bareURL = foundEddyURL.getURL();
9493
if (bareURL[0] == 0x00)
9594
{
@@ -98,7 +97,7 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
9897
uint8_t *payLoad = advertisedDevice.getPayload();
9998
for (int idx = 0; idx < payLoadLen; idx++)
10099
{
101-
Serial.printf("0x%08X ", payLoad[idx]);
100+
Serial.printf("0x%02X ", payLoad[idx]);
102101
}
103102
Serial.println("\nInvalid Data");
104103
return;

0 commit comments

Comments
 (0)