Tool/software:
Hello
I am developing a multirole-based application and I have the following task:
I have several devices that are located near each other. Under some condition, they (all, or just some) can go on air with broadcast messages (advertising) for some time (T1). At the same time, they themselves must scan the air during the time (T1) and find neighboring devices that are currently broadcasting on the air.
While I was setting this up, I had several questions.
1. The most important, what is the best way to configure the parameters to guarantee 100% of all my devices are on the air: GAP_ADV_PARAM_PRIMARY_INTERVAL_MIN and GAP_ADV_PARAM_PRIMARY_INTERVAL_MAX (the comments say that the second parameter is not actually used), SCAN_INTERVAL and SCAN_WINDOW?
2. When I studied the theory about advertising, it was written that according to the BLE standard, the device broadcasts on three channels (37,38,39) for no more than 10 ms on each. I conducted an experiment with one device that simply broadcasts on the air and used the NRF sniffer and wireshark. I see broadcast packets on different channels, but the time between them is about 850 μs, regardless of the settings of the GAP_ADV_PARAM_PRIMARY_INTERVAL_MIN and GAP_ADV_PARAM_PRIMARY_INTERVAL_MAX values. Why is that? Why does the broadcast duration not increase to 10 ms?
Now I have achieved the optimal configuration option, when GAP_ADV_PARAM_PRIMARY_INTERVAL_MIN = GAP_ADV_PARAM_PRIMARY_INTERVAL_MAX = 32 (32*0.625 = 20ms)
SCAN_WINDOW = 32 (20ms)
SCAN_INTERVAL = 64 (40ms)
Scan type - passive
Scanner Duplicate Filter - disable
I proceed from the following logic: each device at one point in time can either broadcast on the air or scan it. Therefore, I set the scanning interval to 40ms, of which 20ms will be spent on active scanning (scan window), and the other 20ms will be spent on broadcasting on the air. Considering that after each scan a pseudo-random delay of up to 10ms is added, I expect that due to the short time and additional delay I will achieve a situation where some devices are scanning, while others are broadcasting at the same time and therefore will be able to see each other.
In general, this logic works successfully in about 80% of cases, but if you disable the duplicate filter, it works almost 100%. I don't quite understand how the filter affects this?
What strategy is best to follow to ensure that all devices that go on the air can find their neighbors?