How to access BLE advertsing data using BLE Extension

I need to accesss the advertised data from my Victron Smartshunt a BLE V4.2 battery monitor.

I have successully run my new (very green) App on my mobile and connected to the Smartshunt OK. I am able to read data from at least one of the Custom Services. But that is not the data I need. That data is "advertised" ***without establishing a connection *** to the Smartshunt (i.e. on BLE channels 37,38,39).

I can verify this using the free "nRF Connect" app from Google Play that shows the very data I need being advertised by the Smartshunt, and it updates every second or so as expected (the data is things like battery voltage & current).

The 2 screenshots below show the data. It comprises 22 bytes from the smartshunt. Comparing the screenshots shows the first 7 bytes remain constant, the remainder is updated every second or so. That is the correct/expected behaviour.


I have tried to use the various block options that mention advertising they all fail to get any data. Searching the forum on this I cannot find anyone confirming it is possible to access this data.

Is this supported by the BLE Extension? If so, how should I code this in the app

TIA

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

Be sure to use the latest extension.

That canned response doesn't help, I already have the latest BLE extension installed (2024-08-22)

This thread looks like the one that came the closest to success.

It's not for the faint of heart.

1 Like

Well, that thread sent me down a few million rabbit holes ... not for the faint hearted indeed :slightly_smiling_face:

I've spent a few days trying pretty much all options in the BLE extension related to Advertising, and so far I've only been able to get a response to one:
call BluetoothLE1.AdvertiserAddress

I started with the BLE_Advertise.aia provided by @ChrisWard in your referenced thread at post 15 (started by @ChrisR1)

I've made a number of changes, mainly to match my equipment.
Here are my blocks at present:
Blocks BLE_Adv_B.png

The App starts OK, finds my Device quickly, and 3 seconds later the "Get Adv Data" button is enabled, as expected. Before I push the button, and after I always get feedback that the device is onmt advertising, like this:

When I don't use the if-then
if BluetoothLE1.IsDeviceAdvertising then ...
I get errors trying to get .AdvertiserServiceUUIDs
BLE_Advertise_error

I don't understand why BluetoothLE1.IsDeviceAdvertising is always false, whether I'm scanning or not, and why all other BluetoothLE1 blocks return empty values (apart from .AdvertiserAddress).

BTW I came across this excellent reference BLE Advertising Primer by Argenox
It probably explains the query raised by @Zivo in his unanswered post a year ago.

AFAIK this is the only detailed MIT reference for the BLE Extension

What's missing is an introductory para or two to briefly explaining how Advertising blocks work. If I can resolve my problems (with help!) then I'd be happy to do that write-up, if I can contribute?

I just want to get the advertised data ... help!

TIA

PS: adding the AIA
BLE_Advertise_B.aia (200.5 KB)

I don't know much about BLE, but do you have Location Services enabled on your phone?

Yes, I also tried adding permissions for BLUETOOTH SCAn and FINELOCATION to my AI2 App, but it made no diff.

Your .aia have some problems I can point of (you need to verify the target MAC exist and can't assume it's) , but still, there is the problem of advertised data return null.
I can recall some Arduino code at the other thread, if this is the case, 4 bytes for data are enough (for yours needs)?
If yes you can go with the workaround I proposed.

Actually I don't use the MAC in the project I posted (it's declared but never used).
Anyway I know it is the right MAC from nRF Connect plus I have another project using BLE Extension to successfully connect using the MAC, and retreives data (but not the advertising data).

Your 4 byte method doesn't apply in my case. I need to read all the advertised data as shown under "BATTbank_SmartShunt" in my first post #1 that's 32 bytes !

Here is another screenshot from "nRF Connect" showing more of the advertised data. I know what every one of these 48 byte mean. For example the last 19 bytes are the name ("BATTbank_Smartshunt") in ASCII. But I need to read all this data using BLE Extension.

OOOPPPSS......
Data type 0xFF mean Manufacturer Special Data.
The AdvertismentData block return type 0x16,Service Data.
I'm not aware of case / implementation of AdvertismentData return Manufacturer Special Data.

Just to be clear, the BLE extension when it was first developed combined both the behavior of the central and peripheral sides of the BLE spec. At the time, extensions were restricted to a single component per AIX, so it combined what is effectively the BLE equivalent of the BluetoothClient and BluetoothServer components into a single class. The vast majority of the blocks discussed previously are related to having the phone advertise and nothing to do with reading the advertising data from a connected peripheral.

Probably a less useful function than reading advertising devices, such as medical devices or beacons.

Regardless, medical devices should put the data in an existing service UUID defined by the Bluetooth SIG. That data likely shouldn't go into advertising data since it's unencrypted and it seems like it'd violate laws in multiple countries to put medical data in an unencrypted advertising packet.

It does look like we can support reading the manufacturer data on iOS, so it's something to consider.

Thanks for the new info ewpatton.

My arrangement has a Victron Bluetooth Battery Monitor that acts as a Peripheral / Server and it is the source of the advertised data. My mobile is acting as the Central device (Client) which is meant to read the advertsed data, in particular the Manafacturer Specific Data that Victron have enmbedded in the advertsed data.

Can you say which of the blocks in the BLE Extension are applicable to a Central / Client application?

re you subsequent post, Are you saying App INventor in IOS supports manufacturer data, but in Android it doesn't?