BLE AdvertisingData Format

I’m trying to read BLE Advertising Data from an ESP32 Eddystone beacon created using PCBReflux sample code at:

I’ve verified that the NRFConnect App sees the advertisement and correctly decodes the output. I’ve been able to create an app in AI2 that scans for advertisements and calls AdvertisementData to get the advertisement data and place it into a text box or a list view. This all works except that the data that’s being sent by the EPS32 is hex and it is being translated to negative numbers by AI2. For instance, the second byte of the voltage, beacon_data[3] on the ESP32 is 228 as sent by the ESP32 but the results reported by the AdvertisementData method is -28. I’m assuming this is attributable to a difference in data types between the ESP32 and AI2. The ESP32 code is using char as the data type and I have no idea what data type the AI2 BLE extension is using but I’m guessing its a signed byte. Am I interpreting something wrong or is there something I should be doing to properly interpret the data?

In AI2, Ask for text, not bytes.

How would I go about that? I’m not sure what data type the AdvertisementData method returns. I can attach it to methods that expect text, but it appears to be an array or list based on what I get back. When I set a text box to the return of AdvertismentData, i get back something along the lines of [32,0,12,-28,0,0,0,0,47,0,0.25,40] with values over 128 being displayed as negative numbers. I was able to verify that it is a signing issue by doing a bitwise and with the returned value and 255 to get the expected value.

Please show your relevant blocks,
if relevant, your data or lists,
screenshots of the Designer screen or app in action,
so we can see what you are trying to do…

Right Click in Blocks Editor and select “Download Blocks as Image”
for the best image of your blocks.

Here are the relevant blocks. Using my procedure ConverNeg, I get the correct value in ListView1 and TextBox2. The text that Value is set to and displayed in Label2 shows negative numbers…

blocks3 blocks2

I’m not a BLE expert, so I am working from the documentation here.

I see the doc for the Get AdvertisementData block:


  • AdvertisementData – Returns the advertisement data associated with the specified device address. Parameters :
    • deviceAddress ( text ) — The Media Access Control (MAC) address of the target Bluetooth low energy device.
    • serviceUuid ( text ) — The unique identifier of the advertised service.

call BluetoothLE1 AdvertisementDatadeviceAddressserviceUuid

Unfortunately, the documentation does not state the expected format of the returned value.

I am bumping this to the developer of the extension (and its doc.)

Thanks. I did review that before posting. I couldn’t find anything that specifies the data types though.

I have a new issue. I’ve been working on the code off and on for a few days with the same ESP32. Everything was working as expected except the issue above. However, I added another Eddystone beacon and I couldn’t get my AI2 app to detect it using ScanAdvertisements. I saw random other devices in the list of addresses and the original ESP32. I tried everything I could think of code wise and the new ESP32 never showed up. So I finally powered off my phone and powered it back on. After the reboot I can’t get anything to populate in the BLE.AdvertiserAddresses list. I’ve tried the ESP32 iBeacon sample code and the PCBReflux Eddystone beacon code on multiple ESP32 boards. They all show up in the NRFConnect app on the phone. I also tried another android phone with no luck.


I have another thread regarding the “new” issue that notes the cause of devices not showing up being that the devices are either not setting or android is not populating the device name. I’m still not sure why it worked initially and then stopped.

The problem with the format of BLE AdvertisingData appears to be worse than I originally feared. After digging through the source of the BLE Extension, it appears that much of the data returned by the extension is a conversion from various types to Strings. In the case of AdvertisingData, the android BLE class actually returns an array of bytes and the the BLE Extension converts that to a String using Arrays.toString() and returns it to AI2. Arrays.toString() treats the bytes as signed.

HI,I meet the same problem,did you solve it?how to get the correct data?

For current BLE news, see