请让我分享一个建议的实现this. You can start advertising and set up a timer. Upon timer’s expiration, you 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). When the scanning is completed, start the advertising again. Please check the steps below in order to perform role switching. The ble_app_peripheral example of the SDK is used in my side.
Hi moiify,
根据您的描述,我假设DA14585作为外设使用,因为它与移动电话(中央)相连。请记住,根据蓝牙LE规范,设备不能同时作为外围设备和中央设备。如果我的理解是正确的,DA14585被配置为外设,它可以在连接状态下播发。我不确定您使用的是哪个SDK示例,或者您是否有自定义代码,但是当与对等设备(您的手机)建立连接时,会触发user\u app\u connection()回调。为此,当触发此回调时,您应该通过调用user\u app\u adv\u start()重新启动广告。
谢谢,下午好
我非常感谢你的回答!我使用的是14858 SDK 6.0.10。我找到了调用和结构:cmd=app\u gapm\u configure\u msg\u create();cmd->role=GAP\u role\u ALL;我不知道这样行不行。。。另外,我可以用14585在扫描时做广告吗?我正在寻找问题的答案,谢谢
Hi moiify,
根据蓝牙LE规范,系统不允许同时作为中央和外围设备。因为您使用的是DA14585,所以应该执行从外围设备到中心间隙配置的角色切换,反之亦然。通过将角色设置为GAP\u role\u ALL,这意味着您可以播发(外围角色)或扫描(中心角色)。两者不可能同时进行
请让我分享一个建议的实现this. You can start advertising and set up a timer. Upon timer’s expiration, you 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). When the scanning is completed, start the advertising again. Please check the steps below in order to perform role switching. The ble_app_peripheral example of the SDK is used in my side.
-在user\u config.h文件中,将user\u gapm\u conf的.role成员更改为GAP\u role\u ALL。
-创建一个user\u scan\u start()函数,以便设备开始扫描:
-在user\u app\u adv\u start()函数中,有一个计时器会在大约30秒后启动以停止广告,因此我们将使用它来停止广告。
-因此,在timer adv\u data\u update\u timer\u cb()的回调中,而不是更新播发字符串,调用app\u easy\u gap\u advertive\u stop()函数。
-在user\u app\u adv\u undirect\u complete()函数中,调用user\u scan\u start()函数,以便在设备停止播发时开始扫描。
-为了停止扫描,我将不使用额外的计时器来取消命令,但我将使用扫描本身的超时。
-要在扫描结束后立即开始播发,请创建一个函数user_on_scanning_completed(),并从该函数调用user_app_adv_start();
谢谢,下午好
谢谢你的回答!它真的帮助了我。再次谢谢你。
Hi moiify,
很高兴我的回答很有帮助,谢谢你接受。如果您有任何后续问题,请创建一个新的论坛线程。
谢谢,下午好