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.
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.
1 of 1 people found this helpful
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?