BLE AdvertisementData returns empty []

Hello Chris

  1. Getting down to basics, what is your Project actually designed to do?

  2. Where does the Sketch come from? I see you have not used the Seeed BLE Library (for the Arduino IDE) but instead you are using Bluefruit from AdaFruit.

We don't often see two BLE services run on one board. I recognise the GATT LED Button Service LBS, but what is "VService" "FFE1"?

If you have no genuine manufacturer data, do not advertise it.

oh I am prototyping, and was interested to get the manufacturer data into my app, without the need to connect
Also it needs to be very low power. I succeeded by using the bluefruit and the nrf52840.
So for now , as a test, it is just FFE1.

I just cant understand why the AdvertisementData is returning an empty array.

Does someone maybe have a working example for me? I keep trying all kind of different hw and sw solutions, but no success. Stuck now.
Dont really want to go back to flutter... :frowning:

You haven't explained what the goal of Project is, nor why 'FFE1' exits, which is likely to be part of the issue.

So you tried the library intended for your microcontroller and found it to be too slow?

Well, BLEService VService("FFE1") is an invalid service - I can't find it in the 2024 GATT list. You could generate your own custom UUID here:

ProfessorCad: Tips & Tricks Create/Validate BLE UUIDs

e.g.:

BLEService VService("F36C8650-671D-46FE-8462-7321DA6AAFFA");
Bluefruit.Advertising.addService(VService);

There is also a typo here:

As far as I am aware, the AdaFruit library doesn't use type char array for data, it uses type uint8_t (byte) unsigned chars (integers), but you may have discovered a different method, which is why I asked where the Sketch came from.

Try the custom UUID and correction of the typo.

1 Like

Without knowing the goal, how can we?

That isn't the correct UUID. I hadn't looked at your App Inventor code, good effort but unfortunately there is a lot wrong and the snag is there is a lot missing too. How did you get any kind of a result? I think what you have posted is not all of your code.

Post the App Inventor file (.aia)

Export to PC from Projects List

Here is a simple Project to try. It does not list available devices because you have the name of the device of interest, "Viax". It also does not ask for BLE permissions, which you will need if later you connect to the device. I have nothing to test the code with here!

We find it best to test Bluetooth Apps as an APK rather than use the Companion.

BLE_Advertise.aia (198.9 KB)

Hi Chris,
The goal for now is to is to let MIT show me the manufacturer data from the AdvertismentData block. Any data... Let say a 1 from a button service.
nothing fancy just something simple stupid.

this is the full aia, at this point:
Advertise_test (3).aia (278.4 KB)

data2 is null after scan.

ble scanner now shows the xiao sending:
0x01 0x06
0x0A 0x00
0xFF 0x082234353637
0x09 0x56696178

So decided started again, with a led example from arduino

LED1.ino (2.7 KB)
and the aia:
Advertise_test (5).aia (278.3 KB)
Label1 shows the correct uuid, so device is found
I would think I could use the uuid global for AdvertisementData. But then I get:
err
So I use the preset value.
But data2 is still : null

BLE scanner shows the manufacturer name and the data and the name and service. Obviously because mit finds it also.

edit :runtime error was solved using Select List Item List 1 after global uuid. But still null on data2

Ah, you are ahead of me. Actually your original Sketch "test.ino" has a better chance of working, with the tweaks I mentioned.

LED1.ino does not have a BLEService UUID for advertising.

EDIT: - though if you fix the UUID issues, LED1.ino will be more familiar to the Power Users. Adafruit have their own way of doing things, so if using their libs, best to be using their hardware too.

Ah okay, i thought that would be the setAdvertisedService function?

... You are right! I have been too long without a coffee......

Yeah i know about adafruit and power, but i am now at a state that I am desperate to get my data into MIT. Once that works I can probably go back, because then I know what i am doing wrong...

I'm just compiling a Sketch.
You are using a recent Arduino IDE right?
And you have uploaded the Seeed Lib for XIAO?

Thanks Chris , yeah Ive got both
and using the nrf52840

Well here is the News - ArduinoBLE.h (On my PC) is apparently not compatible with the XIAO boards. I have compiled a version of LED1.ino as LED2.ino with the function niggles fixed (for example, add the Service before adding the Characteristic to the Service). Compiles for Arduino BLE boards, but for the Seeed XIAO nr52840, it verifies but fails to compile:

Arduino: 1.8.18 (Windows 7), Board: "Seeed XIAO nRF52840, S140 7.3.0, Level 0 (Release)" ArduinoBLE at version 1.3.6
Error compiling for board Seeed XIAO nRF52840.

LED2.ino (3.0 KB)

did you select the non mbed version of the board?

I am now back to where I started. by also changing to yet another uuid.
I now get the empty array returned again. When I change the uuid or user_data2 it goes to null.
so everything okay: advertismentData returns

ino:
test2.ino (2.4 KB)

aia
Advertise_test7.aia (278.2 KB)

oh wauw i got it!
had to add some data to the user_data2 array
at last.

Thanks Chris for your help. It is very much appreciated!!
I know a lot more about BLE, thats for sure!