Can DA14586 work as peripheral and central at same time?

2 posts / 0 new
Last post
karanshah28
Offline
Last seen: 2 days 6 hours ago
Joined: 2018-07-14 11:10
Can DA14586 work as peripheral and central at same time?

Hi Dialog Team,

We are planning to create a "Device A" (It will have DA14586 controller) which can act as a peripheral so that central devices like mobile can communicate with it.

Also we have few peripherals like devices which we can refer as "Device XYZ". We want to communicate with "Device XYZ" from "Device A".

As "Devices XYZ" are peripheral we will require "Device A" to be central in order to connect with them.

Is this possible via DA14586? 

Thanks, Karan

Device: 
PM_Dialog
Offline
Last seen: 27 min 37 sec ago
Staff
Joined: 2018-02-08 11:03
Hi karanshah28,

Hi karanshah28,

The DA14585/6 can act as peripheral and a central via setting the gap role of the device in GAP_ROLE_ALL instead of just a central or a peripheral, as soon as you are done with that you should be able to advertise or scan. You will NOT be able to do both procedures at the same time; you will have to cancel the scanning in order to initiate an advertising and vice versa. You could find below some steps in order to achieve GAP_ROLE_ALL in the ble_app_peripheral example (you cannot do both at the same time) The device starts advertising and setting up a timer, as soon as the timer elapses, the advertising procedure is stopped . Since, 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.

  1. Change in the user_config.h file the .role member of the user_gapm_conf to GAP_ROLE_ALL.
  2. 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);

}

 

  1. 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.
  2. 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.
  3. In the user_app_adv_undirect_complete() function invoke the user_scan_start() function, so that when the device stops advertising to start scanning.
  4. 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.
  5. 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();

Also, the SW Example: BLE Central Security Demo Project configures the DA14585 both as a peripheral and as a central device. Please check the role item of user_gapm_conf structure which is located into the user_config.h header file. Its value is GAP_ROLE_ALL which means that the device can act ether as a peripheral or as a central (not at the same time).

Thanks, PM_Dialog