⚠️ 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.
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.
Let’s take the 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:
- 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.
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
Hi thank you for support. I have a question. How can i switch between scan and advertise?
Hi btdev,
Let’s take the 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:
- 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
Thank you for support. I thought of this algorithm before. but I was concerned about data loss
Thanks for accepting my answer! Regards, PM_Dialog