Can BLE device with GAP Role Peripheral have dynamic advertisement packets ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
shrac_2642471
Level 4
Level 4
5 likes given First like received First like given

I have a scenario like this as shown in the figrue below

Advertisement.jpg

I have a peripheral which while advertising should send

data = 0x1 /* When there is data available for sync*/

When there is no data the above flag would be 0x0.

Now if the data flag is set in Advertisement packet then the Phone should pair and exchange the information. If there is no data packet available then the phone shouldn't pair.

So in my configuration, is it possible to do this ? Or if I advertise a "Service" Can I achieve the same ? How do I do this?

PS == I don't want to use my device as a ​Broadcaster.

Regards,
Shrey

0 Likes
1 Solution
Anonymous
Not applicable

The example project: Project #009: Dynamic Broadcaster - Changing Advertising Packets

Shows how to dynamically change packets for broadcasting/advertising. Merely change the project to advertise instead of broadcast, and the dynamic packet updating will be interfaced/changed in the exact same way for your case (minor changes may be needed to make sure the application code doesn't do something weird that you don't want like power saving modes, different state modes, etc.)

View solution in original post

0 Likes
6 Replies
shrac_2642471
Level 4
Level 4
5 likes given First like received First like given

Capture.PNG
This is my Problem Statement

0 Likes
Anonymous
Not applicable

The example project: Project #009: Dynamic Broadcaster - Changing Advertising Packets

Shows how to dynamically change packets for broadcasting/advertising. Merely change the project to advertise instead of broadcast, and the dynamic packet updating will be interfaced/changed in the exact same way for your case (minor changes may be needed to make sure the application code doesn't do something weird that you don't want like power saving modes, different state modes, etc.)

0 Likes

Hi e.pratt_1639216

Okay this sounds really amazing. So I am planning to do something like this. But I can also use a dedicated service as well during advertisement to do a broadcast right ?

0 Likes
Anonymous
Not applicable

Not exactly; While advertising you can only do the advertisement I think.

But once connected, you can also still broadcast data to other devices (albeit without being able to connect to anyone else)

If you are using the advertisement packets to notify phones of data available, I would recommend just advertising with the "data available" flag set, get connected to and communicate, disconnect and go back to advertising with data available. But if you are using the flags as an indication for the phones to connect to the peripheral, then it is kind of pointless to keep broadcasting that data is available if it is busy transmitting data to a phone already.

A broadcast is just an advertisement packet that can't be responded to with scan requests or connection requests. An advertisement packet is a broadcast packet, but allows scan requests and connection requests.

@e.pratt_1639216 

Okay I will see how I can add this flag during advertisement. I am hoping that during advertisement I will create a service which would be advertised and the peripheral can connect and see if there is any data available or not. If there is data available then perhaps it can proceed towards bonding and storing the bond information
Capture1.PNG

As shown in the above figure i am going to create a custom service for read only and that would have the flag information available

This service would be advertised along with the advertisement packet as is shown in the figure below -->

Capture2.PNG

Hope this should provide the solution I am looking for.

Thanks !

Shrey

Anonymous
Not applicable

Yes. That should work well

Just as a note: Remember that when the device advertises, all phones scanning will see it, so if you have already connected with your phone app to read the data within a few seconds, you will want to have a period of "don't reconnect" to allow other phones/devices to connect and read the data if that is your application