Fixed Number Advertisement Packets

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

cross mob
Anonymous
Not applicable

Has anyone worked with sending only a fixed number of advertisement packets from the radio before?

   

I tried using the cypress function CyBle_GappSetNumOfAdvPkts(&cyBle_discoveryModeInfo,3) to send 3 packets, but it seems to only want to send one. Even trying to count the number of advertisement start_stop messages didn't work for manually sending each packet.

   

Does everyone use timers for advertising for a flat amount of time instead? I would think there is a way to do a fixed number of packets; e.g exactly 7 or something.

0 Likes
1 Solution
Anonymous
Not applicable

Hi! The CyBle_GappSetNumOfAdvPkts() API sends a fixed number of advertisement packets. In your case, I believe you are advertising on all 3 channels: 37, 38, 39. Since, you have set the count to 3, the API will send 1 packet on these 3 channels in a single advertisement event and stop advertisement. If you see the air logs(using a sniffer), you will be able to see that there were 1 packet each on channel 37, 38  and 39.

   

I reckon you would want to use the count as 9 = 3 times * 3 channels, or you could choose to advertise only on a single channel.

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

Hi! The CyBle_GappSetNumOfAdvPkts() API sends a fixed number of advertisement packets. In your case, I believe you are advertising on all 3 channels: 37, 38, 39. Since, you have set the count to 3, the API will send 1 packet on these 3 channels in a single advertisement event and stop advertisement. If you see the air logs(using a sniffer), you will be able to see that there were 1 packet each on channel 37, 38  and 39.

   

I reckon you would want to use the count as 9 = 3 times * 3 channels, or you could choose to advertise only on a single channel.

0 Likes
Anonymous
Not applicable

Hello yssu,

   

How do I tell when it has finished sending all three packets?

   

I tried using the CyBle_GappSetNumOfAdvPkts() with a count of 3 (sniffing it using the CySmart USB dongle), but if I try to detect when the packets have finished with the CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP event and a DISCONNECTED state, the unit then seems to disconnect as soon as it has sent the first packet.

   

Is there a different way I should be checking to see when the unit has finished sending the packets? Polling the BLESS state in main for example?

   

It seems easy enough to start the fixed-packet-number of advertisements, but using the usual checking of cyble_state when receiving an advertisement start/stop event makes it disconnect as soon as it starts. 

0 Likes
Anonymous
Not applicable

For those interested:

   

the CyBle_GappSetNumOfAdvPkts() function works as intended, but since the cyble_blessstate does not seem to be accurate in the event handler, I had to implement my own boolean that keeps track of whether the advertisement_start_stop event is a start or a stop event.

   

Once I started keeping track of the state in main, it made the code work much more reliably.

Hi, we are trying to implement CyBle_GappSetNumOfAdvPkts() as well. We are wondering how exactly you keep track of the state in the main loop. Do you set a flag upon receiving a CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP event? Is the flag set within the event handler (AppCallback)? If so, how do you tell if the event is a start or stop event? In the main loop, after calling CyBle_GappSetNumOfAdvPkts(), do you then block until that flag is set?

Thanks

0 Likes