DA14585 windows size and scan interval

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
ltdev
Offline
Last seen:3 months 4 days ago
加入:2018-11-12 09:19
DA14585 windows size and scan interval

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:
PM_Dialog
Offline
Last seen:1 day 11 hours ago
Staff
加入:2018-02-08 11:03
Hi btdev,

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

ltdev
Offline
Last seen:3 months 4 days ago
加入:2018-11-12 09:19
// Scan stop timer callback
// Scan stop timer callback void scanStopTimer_CB(void) { arch_printf( "SCAN STOP\r\n"); struct gapm_cancel_cmd *cmd =(struct gapm_cancel_cmd *) KE_MSG_ALLOC(GAPM_CANCEL_CMD, TASK_GAPM, TASK_APP, gapm_cancel_cmd); cmd->operation = GAPM_SCAN_PASSIVE; // Set GAPM_SCAN_PASSIVE ke_msg_send(cmd);// Send the message } // scan start function static void user_scan_start(void) { struct gapm_start_scan_cmd* cmd = KE_MSG_ALLOC(GAPM_START_SCAN_CMD, TASK_GAPM, TASK_APP, gapm_start_scan_cmd); cmd->op.code = GAPM_SCAN_PASSIVE; cmd->op.addr_src = GAPM_STATIC_ADDR; cmd->interval = 10; cmd->window = 5; cmd->mode = GAP_GEN_DISCOVERY; cmd->filt_policy = SCAN_ALLOW_ADV_ALL; cmd->filter_duplic = SCAN_FILT_DUPLIC_EN; // Send the message ke_msg_send(cmd); // We are now connectable //ke_state_set(TASK_APP, APP_CONNECTABLE); scanStopTimer = app_easy_timer(300,scanStopTimer_CB); arch_printf( "SCAN START\r\n"); } //.scan completed callback void user_on_scan_complete(const uint8_t param){ arch_printf( "Advertise Start = %d\r\n", param); // begin other process // }

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

PM_Dialog
Offline
Last seen:1 day 11 hours ago
Staff
加入:2018-02-08 11:03
Hi btdev,

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