DA14585 Scan and Advertise

Learn MoreFAQsTutorials

6 posts / 0 new
Last post
ltdev
Offline
Last seen:1 week 6 days ago
加入:2018-11-12 09:19
DA14585 Scan and Advertise

Hi; can we use da14585 for scan and advertise same time? if yes how can implement it?

Device:
PM_Dialog
Online
Last seen:14 min 44 sec ago
工作人员
加入:2018-02-08 11:03
Hi btdev,

Hi btdev,

According to Bluetooth LE specification, it is not possible to scan ( GAP Central role) and advertise ( GAP Peripheral role) at the same time. Since you are using DA14585, you can perform role switching from Peripheral to Central GAP configuration and vice versa. This can be done by setting the role to GAP_ROLE_ALL, so that you can either advertise or scan. It’s not possible to do both simultaneously.

Thanks, PM_Dialog

ltdev
Offline
Last seen:1 week 6 days ago
加入:2018-11-12 09:19
Hi thank you for support. I

Hi thank you for support. I have a question. How can i switch between scan and advertise?

PM_Dialog
Online
Last seen:14 min 44 sec ago
工作人员
加入:2018-02-08 11:03
Hi btdev,

Hi btdev,

让我们来的ble_app_peripheral example of the SDK as a start point. By default, the DA14585 isconfigured as a peripheral, so it starts advertising (undirected). You can use an app_easy_timer() and upon its expiration, you should stop advertising. As soon as it stops, you can configure the device as a Central and start scanning. You can either wait for the scan to complete (if you are scanning in GAP_GEN_DISCOVERY) or set an additional timer and cancel the scanning procedure. When the scanning is completed, maybe you can start advertising again. Please check the steps below in order to perform role switching.

- Change the .role member of the user_gapm_conf structure to to GAP_ROLE_ALL , in the user_config.h file.

- Create a user_scan_start() function in order to start scanning:

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_ACTIVE; cmd->op.addr_src = GAPM_STATIC_ADDR; cmd->interval = 16384; cmd->window = 16384; 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); }

- In the user_app_adv_start() function there is a timer that starts up in order to stop the advertising after about 30 seconds, so we are going to use that in order to stop the advertising.

- So in the callback of the timer adv_data_update_timer_cb() instead of updating of the advertising string, invoke the app_easy_gap_advertise_stop() function.

- In the user_app_adv_undirect_complete() function invoke the user_scan_start() function, so that when the device stops advertising to start scanning.

- In order to stop scanning, an additional timer won’t be used in order to cancel the command, but the timeout of the scanning itself will be used.

- To start advertising as soon as the scanning ends create a function user_on_scanning_completed() and from that function invoke the user_app_adv_start();

Hope my suggestions help you! If you found any answer useful, please mark it as “accepted”. Please come back to me with your feedback.

Thanks, PM_Dialog

ltdev
Offline
Last seen:1 week 6 days ago
加入:2018-11-12 09:19
Thank you for support. I

Thank you for support. I thought of this algorithm before. but I was concerned about data loss

PM_Dialog
Online
Last seen:14 min 44 sec ago
工作人员
加入:2018-02-08 11:03
Thanks for accepting my

Thanks for accepting my answer! Regards, PM_Dialog