Hi, in a project we want advertise 2 for seconds after that scan for 3 seconds. I implemented advertise and scan switch mechanism but i have some problemms. how can i set scan window and scan interval values? I want to scan beacons about 3 seconds?
I define that values
cmd->op.code = GAPM_SCAN_ACTIVE;
cmd->op.addr_src = GAPM_STATIC_ADDR;
cmd->interval = MS_TO_BLESLOTS(3000); // total interval 3000 ms
cmd->window = MS_TO_BLESLOTS(1000); // each channel 1000 ms
cmd->mode = GAP_GEN_DISCOVERY;
cmd->filt_policy = SCAN_ALLOW_ADV_ALL;
cmd->filter_duplic = SCAN_FILT_DUPLIC_EN;
但扫描时间大约需要7.94秒
scan completed status is 69 (GAP_ERR_TIMEOUT)
Device:
Hi btdev,
Please try to use GAPM_SCAN_PASSIVE instead of GAPM_SCAN_ACTIVE. In passive scanning configuration, the central receives only advertising data and doesn’t send a scan request (SCAN_REQ) in order to receive a scan response (SCAN_RESP) from the peripheral. Regarding the timeout, you should setup a second timer to stop the scanning procedure. Then, you should add another callback .app_on_scanning_completed = scanning_completed. In scanning_completed() you should reconfigure the device to Peripheral and restart advertising.
Thanks, PM_Dialog
Hi i add a timer. and scan completed callback (in user_callback.h) . In the running scan stop after 3 secs but don't print SCAN STOP printf and dont'run scan completed callback. Just stop application after 3secs
Hi btdev,
你mentioned that as soon as the scanning procedure is completed, no callback function is triggered. Did you register your callback function in the .app_on_scanning_completed item of the user_app_callbacks sttacture in the user_callback_config.h file? When the scanning is stopped, where the code goes?
Thanks, PM_Dialog