Scan | Retransmission - role switch

⚠️
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.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
8个帖子/ 0新
Last post
wisilica
Offline
Last seen:11 months 4 days ago
Joined:2015-03-17 08:16
Scan | Retransmission - role switch

Hi Dialog Team,

我正在自定义BLE_APP_PERITELAL以实现以下要求。
1) Device should scan for BLE packets in the GAP_OBSERVER_SCA mode.
2)在接收到第一BLE分组时,必须尽快重新发送该数据包。
3) After retransmission of the packet, the device should switch back to scanning mode.
We have to continue this process (steps 1 - 3) throughout the life of the device.
如果SDK 6.0.2支持此(角色交换机),请告诉我们。

谢谢in advance,
Wisilica

设备:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
Hi wisillica,

Hi wisillica,

Yes its possible to switch the roles of the device the same way that the 580 does, just send a GAPM_RESET_CMD and set up the device in the corresponding role.

谢谢MT_dialog

wisilica
Offline
Last seen:11 months 4 days ago
Joined:2015-03-17 08:16
Hi,

Hi,
We have tried issuing the reset command for role switching purpose. But, the time required for this was observed to be around 5ms. Please suggest the reasons for the same and techniques to reduce this time.

谢谢
Wisilica

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
嗨Wisilica,

嗨Wisilica,

你发送一个重置命令堆栈,和then you go through the entire configuration, we haven't estimated a maximum or a minimum time for this change but i suppose that it is quite reasonable, there are no techniques to reduce this time as far as i am aware. But since this is a 585, if you are worried about the timing that it takes to switch between two roles you can set the role in GAP_ROLE_ALL and advertise or scan (you can not do both at the same time) but you can advertise and set a timer, as soon as the timer elapses, stop the advertising procedure 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.

谢谢MT_dialog

wisilica
Offline
Last seen:11 months 4 days ago
Joined:2015-03-17 08:16
Hi,

Hi,
Could you please provide a sample code which demonstrates this kind of advertisement and scan switch by using GAP_ROLE_ALL.
谢谢
Wisilica

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
Joined:2015-06-08 11:34
嗨Wisilica,

嗨Wisilica,

I will provide the changes in order to perform this, using the ble_app_peripheral example:

  • Change in the user_config.h file the .role member of the user_gapm_conf to GAP_ROLE_ALL.
  • Create a user_scan_start() function in order for the device to start scanning like the one implemented below.

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_PASSIVE;
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 of the demo 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() erase the updating of the advertising string and invoke the app_easy_gap_advertise_stop() function.
  • 在user_app_add_undirect_complete()函数中调用user_scan_start()函数,以便当设备停止广告开始扫描。
  • In order to stop scanning i wont 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();

在上面的指令之后,您应该能够创建一个宣传和扫描固定间隔的演示,而无需在585上切换角色。

谢谢MT_dialog

Ruchi Patel
Offline
Last seen:2 years 7 months ago
Joined:2017-03-29 10:50
Hello Dialog_Support,

Hello Dialog_Support,

我在所有帖子上阅读,我想按照上面提到的情况进行确切的功能。但我有DA14580板,不支持GAP_ALL_ROLE,所以如果我使用DA14580板,我需要执行哪些更改?您可以为我提供像上面发布的DA14585的步骤吗?或者您可以提供或建议我任何示例代码。

感谢致敬,
Ruchi Patel

PM_Dialog
Offline
Last seen:3 days 1 hour ago
Staff
Joined:2018-02-08 11:03
Hi Ruchi Patel,

Hi Ruchi Patel,

The DA14580 doesn’t support dual role by default, so it can operate either as central (scanning operation) or as peripheral (advertising operation). In order to do this, you will have switch between roles override some functionalities. So, you should issue a gapm reset command in order to reset BLE stack and re-configure the device as peripheral or as central depending on your application. Please check the following past posts in which the steps for that configuration are referred.

https://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...

https://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...

谢谢pm_dialog.