BLE AdvertisementData returns empty []

Hi,
You may want to look at this-

I'm using Arduino with HM10 BLE (not the Nordic you are using) but having the same results (of return empty).
Same as you, other apps and utilities (Like the Nordic nRF Connect for Android) are receiving the data as expected.

At the moment I am testing with a transmit every second and I see that not every time the advertismentData is updated. sometimes it stops for 15 seconds or so, and then continues.
I does receive the message correctly every time
That is a worry.

with the ble app I see that the messages are send correctly, a test counter increments correctly

it is actually consequently 30 secs between updates.


Yet more research revealed that using the devicefound block as above, two things happen.

  • When okay it show the correct string received. All is fine.
  • But when not okay, the call AdvertiseAddress block returns empty. So it has found the mac address and the viax2 name, but no advertise data available?
    The is a string prevents error messages for the empty data.
    Anybody know how this could happen?

You may want to read the link I post here yesterday..
You can use AdvertaiserServicesUuid block and it will return the correct service UUID, but you can't get the DATA :frowning:

Also, pay att. to the workaround I posted at the end of that post.
Beyond the current prototyping, what's the length of the data you want to send?
Is 4 byte long enough?

BTW, from your test2.ino the declaration of user_data2 is not clear:
char user_data2[2] = {0x16,0x180,0x41,0x42,0x43,0x44};
The length of the array defined as[2], thought it should be at least 6.

1 Like

Hi Zivo, yes thanks I saw your post before, there are not so many postst about this problem.
But your solution did not work for me, but it led me to use the 2 byte uuid in there. S o thanks for that.
Your are right the array is wrong, was because I edited the code for this thread.

I have tried everything, I do think that there is a bugg in the library itself.

I am now about to give up, and use connected mode. It should be possible to connect, exchange data and disconnect quickly.

To make it clear, this works:

start advertising and do that for 30 secs.
in stop callback update the advertising data contents
and start advertising again.
It does get every message then.

But I would have liked to do this every one or two seconds

There's a couple of things in the Block:

  1. If "Viax2" is found, break the for each loop
  2. calling rx - the procedure will not complete before the next function executes, so either make it the last function or make it return a value.

Thanks Chris,
Yeah the break is allready build in. I saw a lot of Viax2 coming by in the same second, getting one of them is enough of course.

But I dont understand your second point. How is not completing?

rx is now returning a true.
But the problem is the same

Zivo, got your email, but could not email back.
however, tried your suggestion still gives the same problem. three or four in a row okay, then stops for a while and repeats

I suspect deviceFound is triggered when NEW device is found (you have the same device adv. all the time).
I'm using timer for looping for new data ( and renew the adv. scan).
You can print some message to verify the loop run at all.

I can see here that DeviceFound triggers on every advertisement, also from the same device. In there I check for the viax2 name on the devicelist. that works all the time.

Then I check for advertisment address validity with viax2.
When i transmit messages faster than 30 seconds it does find a couple, but then the returned address is empty. Untill the 30 secs is passed.

When I transmit a message with 30 secs interval, it works all the time.

That is fine for some applications, but I would want to process a message every one or two seconds.

and again, your timer solution gives me the same behaviour

The functions that follow do not wait for the procedure to complete, they are executed immediately. If anything down the line relies on what the procedure does, it may not have completed it's task in time, so it's about good programming habits in order not to get caught out.

Ah thanks very much for that info. That is very important to consider!!!

My project include additional none relevant I'd tried to clean / clear as possible.
The device is using UUID - 0000FFE0-0000-1000-8000-00805F9B34FB
and the first two byte of the data are always- CDCD (the "real" data is posted at the next 4Bytes).
The timer is 3000ms and ScanAdvertizment is calling every 3 cycles for 9000ms.
This solution works continuously with no miss.
Pay att. to the UUID I'm using at Inventor side, this is what make it working.

BM_Clean.aia (244.1 KB)

Well I dont know. I got it working now, with a blend of both of us, Zivo.
So using your scanning with 9 secs in a loop, but using my DeviceFound. It needs to be slow, but now I do get the one second update from my device.
And also with 12 databytes, not with four.

Here it is, as it is now, it is a bit messy but you get the idea.
sometimes it misses a message, but not for a long time. So thats good!

Advertise_test (7).aia (280.9 KB)

I will still try with the original uuid, and see if the CDCD is relevant for me or not.

UUID - just to be clear, it's not must be CDCD. The only important is it must stay fix (because I'm using it for the query).

ah okay, understood.

OK, after reviewing .
Sorry, my mistake for using "Bytes" for sizing the data (it confusing and wrong at this case).

Without diving into all the little / big Indian using by the Android side , lets talk about what you SEND (from the Arduino).
UUID is sent as HEX (from Arduino) and handled as HEX at Android side.
The data payload is handled different.
What AdvertainmentData return is every two characters are translated into one signed DEC number (signed 2's complement ,2 digits).
At my case, I'm sending 12 characters of data .
The first 4 are stay fix and using part of the UUID (for fetching the data. This is the CDCD ) and 8 characters (4 DEC numbers) us using for the data itself.

Running your .aia I'm getting exactly the same results (AdvertainmentData return "only" 4 signed DEC number )
It may related to the data you nRf is sending.
Can you pls. share your latest (test2.ino?).

THX