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 posts / 0 new
Last post
wisilica
Offline
Last seen:11 months 3 days ago
Joined:2015-03-17 08:16
Scan | Retransmission - role switch

Hi Dialog Team,

I am customising the ble_app_peripheral to implement the following requirement.
1) Device should scan for BLE packets in the GAP_OBSERVER_SCA mode.
2) Upon reception of the first BLE packet, the packet has to be retransmitted by the device as soon as possible.
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.

Thanks in advance,
Wisilica

Device:
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.

Thanks MT_dialog

wisilica
Offline
Last seen:11 months 3 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.

Thanks
Wisilica

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

Hi 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.

Thanks MT_dialog

wisilica
Offline
Last seen:11 months 3 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.
Thanks
Wisilica

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

Hi 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();

Following the instruction above you should be able to create a demo that advertises and scans in fixed intervals, without having to switch roles on the 585.

Thanks MT_dialog

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

Hello Dialog_Support,

我读过最重要的是,我想执行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.

Thanks and Regards,
Ruchi Patel

PM_Dialog
Offline
Last seen:2 days 10 hours 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-semiconductor.com/forums/post/dialog-smartbond-bl...

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...

Thanks PM_dialog