我将设备角色设置为中心,我使用以下函数
静态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 = user_scan_conf.code;
cmd-> op.addr_src = user_scan_conf.addr_src;
cmd-> interval = user_scan_conf.interval;
cmd-> window = user_scan_conf.window;
cmd-> mode = user_scan_conf.mode;
cmd->filt_policy = user_scan_conf.filt_policy;
cmd-> filter_duplic = user_scan_conf.filter_duplic;
//发送消息
ke_msg_send(cmd);
// We are now connectable
ke_state_set(TASK_APP, APP_CONNECTABLE);
}
to cause the device to start scanning.But,It can not be executed to the function of app_on_scanning_completed.(I refer to the project of DSPS)
did i missed something? and i did not find the project of ble_central ?can you tell where can I download?
I want you to tell me how to configure the ble start scan?I think there are some errors on the kernel tasks or omissions.
提前致谢
嗨2455321262,
The app_on_scanning_completed callback is the function that is going to be executed when the device stops that scanning procedure, either via the scanning operation timeout (approximatelly 8 seconds) or if you cancel the operation. So if you dont start scanning the callback will never execute thus you wont get your function to execute. After the configuration of your device completes (after the configuration of the device completes the .app_on_set_dev_config_complete callback will occur) this is where you should place the start scanning operation. Also for an example of a central you might want to have a look at the DSPS reference design in the HOST project. You will be able to find the DSPS reference design under the reference design section on the support portal.
谢谢mt_dialog.
嗨mt_dialog,
thanks for your advice,I'm suer i call function start scanning in function .app_on_set_dev_config_complete callback.But my device is unable to implement function .app_on_set_dev_config_complete .I found that my device was able to scan to the surrounding Bluetooth signal,i don't know why the device did not scan timeout,the time of timeout is fixed for 8 seconds?If it not 8 seconds,where can i Configuration it ?
我希望你能尽快帮助我,提前感谢。
嗨,2455321262
您可以启动计时器以取消扫描过程,因此您的程序可以达到扫描完整的回调。
您可以取消像这样的当前扫描。
struct gapm_cancel_cmd * cmd =(struct gapm_cancel_cmd *)ke_msg_alloc(gapm_cancel_cmd,task_gapm,task_app,gapm_cancel_cmd);
cmd->操作= gapm_scan_passive;//设置GAPM_SCAN_PASSIVE.
KE_MSG_SEND(CMD); //发送消息
嗨,chrise0409.
我认为解决我的问题是一个好主意,感谢你的忠诚。但我仍然想知道如何配置自动扫描超时吗?我认为这对我来说不会伤害。
嗨杰瑞,
The scanning procedure scans for about 8 seconds by default, there is no option in order to change that, the scanning function when you are scanning in GAP_GEN_DISCOVERY or GAP_LIM_DISCOVERY has this time out, if you dont want this time out you can scan in GAP_OBSERVER_MODE (you will be able to find more info on this in the RW-BLE-GAP-IS). What i dont get is the exact problem, your device scans at the beggining and you dont see the scan function executed when the timeout occurs ? If your device scans that means that somewhere the device executes the scanning procedure (i suppose that this happens in the app_on_set_dev_config). The DSPS starts the scan in the user_on_set_dev_config_complete (.app_on_set_dev_config_complete callback) and when the timeout occurs (timeout not cancelation) the .app_on_scanning_completed gets triggered. Check if at the callback function that you are using at the custom_on_scanning_completed() you make a check if the status of the scanning only GAP_ERR_CANCELED and not timed out (GAP_ERR_TIMEOUT). Also check in the gapm_cmp_evt_handler() in the app_task.c if the callback app_on_scanning_completed() is getting invoked in the project that you are using in order to implement your project.
案例Gapm_scan_active:
案例GAPM_SCAN_PASSIVE:
{
Execute_callback_param(app_on_scanning_completed,param->状态);
}
休息;
谢谢mt_dialog.
嗨,mt_dialog,
Thank you very much for your advice, I have told you where to do one by one check, and now my scan has been able to run successfully, really thank you very much
谢谢杰里
嗨杰瑞,
I am not sure i understand the question, when you dont handle the app_on_scanning_completed (you provide NULL at your callback) what happens exactly ? If you dont handle completion of the scanning your device will just go into sleep without doing anything. I dont see what Jlink has to do with the fact that you dont handle the scanning completion.
谢谢mt_dialog.
嗨,mt_dialog,
I am sorry for my bad statement about my question.
I found that my J-LINK did not work properly after wake up in sleep mode.
I'm in debug mode,Someone of predecessors said DA14580 can not be in both sleep mode and debug mode ,I think I have entered the sleep mode successful, but after the implementation of the function arch_resume_from_sleep, my J-LINK will not work, it seems to quit the debug mode?
I find the function as follows:
void BLE_SLP_Handler(void)
{
syscntl_use_highest_amba_clocks();
TOGGLE_GPIO13_SHORT
充电();//上电BLE核心
wakeup_lp_comp = 0; // clear flag for next time
setbits16(sys_ctrl_reg,debugger_enable,0);
setbits16(gp_control_reg,ble_wakeup_req,0);
...................
}
我可以评论setBits16的代码吗(sys_ctrl_reg,debugger_enable,0)?或修改setbits16(sys_ctrl_reg,debugger_enable,1)?
如果我想同时进入两个调试和睡眠模式,我会做什么?
谢谢杰里
嗨杰瑞,
在较旧的SDK中,您无法在睡眠模式和调试中同时,该功能在SDK5.0.4中添加,of ove 5.0.3您无法使用keil调试并处于睡眠模式。如果您使用的SDK是5.0.3并且您已删除了阻止在启用调试器时暂停的Check_sys_start_up_period()中停止FW的代码,然后启用调试器,则可以删除禁用调试器在SLP处理程序中(删除SetBits16(Sys_ctrl_reg,debugger_enable,0);),您应该能够做到您想要的。您是经验的原因是禁用手臂的调试器模块的原因,而您的调试模式在调试模式下。
谢谢mt_dialog.
Hi,
我想问一些connection with this thread.
When the scanning is performed in general discoverable/ limited discoverable mode, does the timeout happen even if advertisement reports are being received continuosly ? Or, only if no BLE packets are received during the scan mode ?
谢谢
wisilica
嗨Wisilica,
如果您正在执行的扫描是GAP_GEN_DISCOVERY或GAP_LIM_DISCOVERY,操作将自动超时,无论广告报告如何,即使设备未收到任何报告,扫描过程将在大约8秒后超时。
谢谢mt_dialog.