i am using DA14585 chip to run in both master and slave mode, it makes confused that sometimes the chip is not broadcasting (when it is not be connected,in most time),so i should use some API to query whether device is broadcasting periodically. thank you!
Device:
Hi moiify
Since you are using a DA14585, in order to perform role switching, you can set the role in GAP_ROLE_ALL and advertise or scan (you cannot do both at the same time). However, you can advertise and set a timer, upon timer expiration, ou should stop advertising and as soon as it stops you can start scanning and 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) so as soon as the scanning completes start the advertising again. Please check the steps below in order to perform it in ble_app_peripheral example of the SDK:
- Change in the user_config.h file the .role member of the user_gapm_conf to GAP_ROLE_ALL.
——创建一个user_scan_start()函数为了the device 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 i won’t use an additional timer in order to cancel the command, but i will use the timeout of the scanning itself.
- In order 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();
Please try the steps above and let me know if it is working.