cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Gap discovery duration?

Saksham
Associate

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Vyacheslav
Senior II

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.

View solution in original post

3 REPLIES 3
Vyacheslav
Senior II

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.

@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.

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.