cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox Bluetooth SDK

New Contributor II

I'd like to perform master slave switch when establishing a connection.

I cannot find the API for this function for now.  can I have the information about how to perform this?

0 Likes
Reply
1 Solution
Moderator
Moderator

Hi ToKo_4602001 ,

Currently these APIs are not included in SDK for CYW20819.

Our software team is working on this to fix in next BTSDK releases.

Sorry for the inconvenience caused.

Regards,

Anjana

View solution in original post

0 Likes
Reply
7 Replies
Moderator
Moderator

Hi ToKo_4602001​ ,

Can you please confirm if you are using BLE or BT classic?

If BT classic which profile?

Regards,

Anjana

0 Likes
Reply
New Contributor II

I use SPP and iAP profile on classic Bluetooth.

For example, I want to connect to a peer device as master and after that I want to change role to slave.

Thanks

0 Likes
Reply
Moderator
Moderator

Hi ToKo_4602001 ,

You may try the API BTM_SwitchRole to switch role. Please add the API as extern in your application code as below:

#define ROLE_MASTER 0

#define ROLE_SLAVE 1

typedef uint8_t tBTM_STATUS;

extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, uint8_t *p_role, tBT_TRANSPORT transport);

extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, wiced_bt_dev_cmpl_cback_t *p_cb);

Example:

1. btm_status = BTM_GetRole (p_data->open.bdaddr, &role, BT_TRANSPORT_BR_EDR);

  WICED_BT_TRACE( "GetRole status:%d role:%d\n", btm_status, role ); // 0:Master, 1:Slave

2. btm_status = BTM_SwitchRole( p_data->open.bdaddr, ROLE_MASTER, BTMRoleSwitchHandler);

void BTMRoleSwitchHandler(void *role_switch_data)

{

  tBTM_BL_ROLE_CHG_DATA *p_event_data = (tBTM_BL_ROLE_CHG_DATA *)role_switch_data;

  uint8_t status = p_event_data->hci_status;

  UINT8 new_role = p_event_data->new_role;

  WICED_BT_TRACE( %B status %d new_role %d \n", p_event_data->rem_bda, status, new_role );

}

The API's will be added in future SDK releases.

Regards,

Anjana

0 Likes
Reply
New Contributor II

Thank you for your response.

I tried but unfortunately I got the following results.

    undefined reference to `BTM_SwitchRole'

    error: ld returned 1 exit status

I assume that the definition in "wiced_btsdk\dev-kit\baselib\20819A1\internal\20819A1\patches\patch.sym" is also required.

  BTM_SetLocalDeviceName = 0x024493;

  BTM_ReadLocalDeviceName = 0x0244b9;

  BTM_SwitchRole = XXXXXXXXXXX

Regards,

0 Likes
Reply
Moderator
Moderator

Hi ToKo_4602001 ,

Let me check internally if this API is not available for CYW20819 or not and update you.

Regards,

Anjana

0 Likes
Reply
Moderator
Moderator

Hi ToKo_4602001 ,

Currently these APIs are not included in SDK for CYW20819.

Our software team is working on this to fix in next BTSDK releases.

Sorry for the inconvenience caused.

Regards,

Anjana

View solution in original post

0 Likes
Reply
New Contributor II

I get it.

Thank you for your confirmation.

Regards,

0 Likes
Reply