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.
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);
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.
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