2020-11-19 08:46 AM
Hi,
I tried the BLE p2p Client example from cubemx and running on STM32IDE.
Whenever I push the button, the device starts scanning in general discovery mode. The issue is it always scans for 10 seconds and I am not able to change it.
I have tried changing the scan interval and window but that's different and still the same result. I tried to find a timeout for this but can't seem to locate it.
Can someone help me please, I am new to this chip and BLE so having a hard time understanding.
Solved! Go to Solution.
2020-11-19 09:02 AM
Hi.
In AN5270 :
2.4.23 ACI_GAP_START_GENERAL_DISCOVERY_PROC
Start the general discovery procedure. The controller is commanded to start active scanning. The procedure is terminated when either the upper layers issue a command to terminate the procedure by issuing the command ACI_GAP_TERMINATE_GAP_PROC with the procedure code set to 0x02 or a timeout happens
(the timeout value is fixed at 10.24 s). When the procedure is terminated due to any of the above reasons, ACI_GAP_PROC_COMPLETE_EVENT event is returned with the procedure code set to 0x02.
You need to catch event ACI_GAP_PROC_COMPLETE_EVENT and restart scan if need.
2020-11-19 09:02 AM
Hi.
In AN5270 :
2.4.23 ACI_GAP_START_GENERAL_DISCOVERY_PROC
Start the general discovery procedure. The controller is commanded to start active scanning. The procedure is terminated when either the upper layers issue a command to terminate the procedure by issuing the command ACI_GAP_TERMINATE_GAP_PROC with the procedure code set to 0x02 or a timeout happens
(the timeout value is fixed at 10.24 s). When the procedure is terminated due to any of the above reasons, ACI_GAP_PROC_COMPLETE_EVENT event is returned with the procedure code set to 0x02.
You need to catch event ACI_GAP_PROC_COMPLETE_EVENT and restart scan if need.
2020-11-20 01:43 AM
@Vyacheslav Thanks I was referencing the STM32wb Prog guidelines only, didn't know about AN570
So if I understand correctly, I would always need to check the scanned packets for a condition and then send a terminate command. Otherwise it would go on till timeout.
So, here if I set interval to 100ms and window 50ms, it would repeatedly scan every 100 ms till there is a timeout or I stop the scan?
I wanted to make it scan every second or two with very small scan interval and window (100-200ms).
I can set hardware timer to stop and restart the scan every second if no packets are detected, but would have to increase BLE interval to 1sec with 100 ms window?
I am not sure if this would be a good way to go about it.
2020-11-20 02:16 AM
Hi, Saksham.
Yes, you understand correctly. You need to scan always while you need to find peer device or any time what you want :)
Yes, scan will run untill timeout.
No problem. You may set scan intertval to 1600 (it will be 1sec: 1600*0.625 =1000msec) and scan window to 320 (in will be 200msec)
or
use hardware or appication timer how you describe.
But in fist case you need to check scan timeout to start scan again.
Best regaards,
Vyacheslav.