Scan | Retransmission - role switch

Learn MoreFAQsTutorials

8个帖子/ 0新
Last post
wisilica
Offline
Last seen:6个月5天前
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.
Please let us know if this (role switch) is supported by SDK 6.0.2.

谢谢in advance,
Wisilica

Device:
MT_dialog
Offline
Last seen:1 month 1 week 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:6个月5天前
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:1 month 1 week 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:6个月5天前
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:1 month 1 week 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.
  • 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 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年2个月前
Joined:2017-03-29 10:50
Hello Dialog_Support,

Hello Dialog_Support,

I have read above all post and i want to perform exact functionality as mentioned above. But i have DA14580 board which doesn't support GAP_ALL_ROLE so what changes i need to perform if i use DA14580 board? Can you provide me steps like you have posted above for Da14585 or you can provide or suggest me any example code.

谢谢and Regards,
Ruchi Patel

PM_Dialog
Offline
Last seen:22 hours 9 min 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.