Skip to main content

Role switch Peripheral to Central

5 months ago

Role switch Peripheral to Central

Posted bymarios0 points 3 replies
0 upvotes

Hello Dialog Support !

We want to implement a role swap on DA14580:

When system boots starts on adverising mode: GAP_PERIPHERAL_SLV to be conectable from mobile devices when it's gets the data from mobile device we do a

cmd->operation = GAPM_RESET;
to the stack and set the device role cmd->role = GAP_CENTRAL_MST;

then a conection establised to the second sps_device and data transfered after that device 1 switch back to GAP_PERIPHERAL_SLV to advertise and waits again for conection.

we have used the sps_device project example and modify the below:

1st. try of role swap implementation please sugest the best solution:

app.c

static struct gapm_set_dev_config_cmd* app_easy_gap_dev_config_create_msg(void)
{
// Allocate a message for GAP
if (set_dev_config_cmd == NULL)
{
struct gapm_set_dev_config_cmd* cmd;
cmd = app_gapm_configure_msg_create();
set_dev_config_cmd = cmd;

cmd->operation = GAPM_SET_DEV_CONFIG;
cmd->role = user_gapm_conf.role;
memcpy(cmd->irk.key, user_gapm_conf.irk, KEY_LEN*sizeof(uint8_t));
cmd->appearance = user_gapm_conf.appearance;
cmd->appearance_write_perm = user_gapm_conf.appearance_write_perm;
cmd->name_write_perm = user_gapm_conf.name_write_perm;
cmd->max_mtu = user_gapm_conf.max_mtu;
cmd->con_intv_min = user_gapm_conf.con_intv_min;
cmd->con_intv_max = user_gapm_conf.con_intv_max;
cmd - > con_latency = user_gapm_conf.con_latency;
cmd->superv_to = user_gapm_conf.superv_to;
cmd->flags = user_gapm_conf.flags;
cmd->operation = GAPM_RESET; //MARIOS EDIT
cmd->role = GAP_CENTRAL_MST; //MARIOS EDIT
}
return (set_dev_config_cmd);
}

2nd. try implementation please sugest the best solution:

app.c

volatile uint8_t current_role = 1; //MARIOS EDIT 15/11/2020
static struct gapm_set_dev_config_cmd* app_easy_gap_dev_config_create_msg(void)
{
// Allocate a message for GAP
if (set_dev_config_cmd == NULL)
{
struct gapm_set_dev_config_cmd* cmd;
cmd = app_gapm_configure_msg_create();
set_dev_config_cmd = cmd;

if(USER_CONFIG)
{
cmd->operation = GAPM_SET_DEV_CONFIG;

if( 1 == current_role ){

cmd->role = user_gapm_conf.role;// CURENT ROLE IS GAP_PERIPHERAL_SLV System start Advertising! Marios edit
current_role = 0;

}else{
cmd->role = GAP_CENTRAL_MST; // CURENT ROLE IS GAP_CENTRAL_MST System start Scanning ! Marios edit
current_role = 1;
}
cmd->appearance = user_gapm_conf.appearance;
cmd->appearance_write_perm = user_gapm_conf.appearance_write_perm;
cmd->name_write_perm = user_gapm_conf.name_write_perm;
cmd->max_mtu = user_gapm_conf.max_mtu;
cmd->con_intv_min = user_gapm_conf.con_intv_min;
cmd->con_intv_max = user_gapm_conf.con_intv_max;
cmd - > con_latency = user_gapm_conf.con_latency;
cmd->superv_to = user_gapm_conf.superv_to;
cmd->flags = user_gapm_conf.flags;
memcpy(cmd->irk.key,user_gapm_conf.irk,KEY_LEN);
}

}
return (set_dev_config_cmd);
}

we are waiting for your precius help!
Thanks in advance,
Marios

5 months ago

TR_Dialog 0 points

Hi Marios:

Before getting into the details of your question, can you please provide the following information:

1. Are you using DA14580?

2. Which SDK version are you using?

Thanks,

TR_DIALOG

5 months ago

marios 0 points

Hello TR_Dialog !

Yes i'm using da14580 and SDK 5.0.4 version

is any newer version avalable ?

Thanks in advance,

Marios

5 months ago

PM_Dialog

Hi Marios,

I would strongly recommend not modifying the DSPS, as it is supported as provided be Dialog. Since you would like to perform role switch, my suggestion would be to start with any of the SDK BLE example ( such as prox_reporter ).

Please check the ticket below to find guidelines how to implement the role switching :

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-42-%E2%80%93-software/dynamic-adv-data-scan

被超越的需求方是专门的参考设计ates a serial cable communication and supports point to point connection. If you still need to do it in the DSPS, this will not be a straight-forward implementation, as you should port all the DSP functionality from the sps_device to sps_host and implement it by you own.

If you are starting a new design / project, we would strongly recommend to start with DA14531 or DA14585/586 products and our latest SDK6.0.14, as it is much more improved. We have a lot of code examples and improved documentation, and there is also software roadmap support. There is no software roadmap support for DA14580 product family and SDK5.

Please check out DA14531:

//www.wsdof.com/products/connectivity/bluetooth-low-energy/products/da14531

We also have a DA14531 module, namely DA14531 SmartBond TINY™ Module! It has very small dimensions and is very low power. Follow the link below to find datasheet, documentation and HW collaterals for the module:

//www.wsdof.com/products/bluetooth-module-da14531-smartbond-tiny

The specific application might be much easier to be developed if the new CodeLess was used.

//www.wsdof.com/products/smartbond-codeless-commands

It supports binary mope, so you can have the DSPS functionality and you could perform role switching by executing the appropriate AT commands.

http://lpccs-docs.dialog-semiconductor.com/UM-140-DA145x-CodeLess/binarymode.html

http://lpccs-docs.dialog-semiconductor.com/UM-140-DA145x-CodeLess/demo.html

Thanks, PM_Dialog