I am use BLE version 3.65.
I want to send advertising packet on 3 channels with period from 1 second to 1 minute.
I use CyBle_GappSetNumOfAdvPkts().
I have 2 inexplicable behavior:
Where can I find the description of the CyBle_GappSetNumOfAdvPkts? I don’t find the answer in the header description and the document “Bluetooth Low Energy” that attached to the PsocCreator.
Please, assist and explain the situation.
Q) What is the parameter “NumOfAdvPkts” of the function “CyBle_GappSetNumOfAdvPkts()”? Is it number of bundles of TX on 3 channels OR this is number of TX packets? What should I see in sniffer if I use value 1 and value 3?
Ans: The parameter “NumOfAdvPkts” of the function “CyBle_GappSetNumOfAdvPkts() will define the total number of packets to transmitted over the air. If you set this value to 1 then you will see only one TX packet on channel 37. If you set this value to 3, then you will see three packets on channel 37, 38,39 as shown in below image. After transmitting the Number of packets the advertisement will be stopped.
Q) What is the advertising interval for this function? For example, if I use the NumOfAdvPkts == 9. What is the period between two TX on ch.37 and what is the period between channels 37-38-39?
Ans: The advertising interval is the value which you set in Advertising settings in the BLE component. The time between the beginning of two consecutive ADV_IND PDUs within an advertising event shall be less than or equal to 10 ms as shown below. The advertising event shall be closed within the advertising interval.
i) Below image will show the 9 advertisement packets on channel 7 with advertising interval of 50ms(Only channel 7 is selected in Advertising channel map in BLE component).
ii) Below image will show the 9 advertisement packets on ALL channels with advertising interval of 50ms(All channels are selected in Advertising channel map in BLE component).
Q) Can I set the specific number of advertising channels?
Ans: You can set the specific number of advertising channels in Advertising settings in BLE component as shown in below.
Please let me know if you have any questions.
I have 2 unexpected behavior:
1. When CyBle_GappSetNumOfAdvPkts called with value 3, I get one extra, unexpected advertising on 3 channels, with advertising interval delay after expected (required). This happens randomly, with probability 30%. In other words, I send the function with value 3 and i see 3 adv.packets and after delay of the interval i see additional 3 advertising on 3 channels. Total: I get 6 TX packet.
2. When i use CyBle_GappSetNumOfAdvPkts with number of packets 1, I get advertising on channels: 37,38, 39. Total: 3 TX packets. In this case there isn't any additional unexpected broadcast.
The issue happens only when the project compiled with bootloader (Dual-Application) and with Virtual Node Substitution Level is 3.
The issue doesn't happen when tested without bootloader and without optimization. I can't separate the test. For my opinion, the optimization is most likely.
Could you please share your project so that we can check at our end ?
Unfortunately I can't share the project.
I called CyBle_GappSetNumOfAdvPkts with value 3. To stop broadcast i use CyBle_GappStopAdvertisement(); The system most of the time in sleep. Waked up ones per second. And according to state it sends broadcast.
According to my test and investigation:
1. The unexpected packet is sent after elapsing advertising interval if CyBle_GappStopAdvertisement was not called before.
2. If new request is sent without a stop, after the broadcast of required number of packets is done and before the advertisement interval elapsed, the new request is ignored. After broadcast of requested number of packets, the system is in state CYBLE_STATE_DISCONNECTED. Apparently i wrong think that we should not sent the stop in this state (when it already finished to send).
Obviously i am wrong about TX 3 packets on 3 channels when CyBle_GappSetNumOfAdvPkts called with value 1. For indication I use Nordic Sniffer. When I request to scan only specific channel, sniffer scans all 3 adv channels.
Please share your ble sniffer log files, we can check at our end.