Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Bluetooth SDK Forum Discussions

KoFo_4760836
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

We're using HF Audio Gateway example on CYW920706WCDEVAL and ModusToolbox 2.3. Every time we accept ACL connection from remote device, the SDK issues a role switch - see BTSpy log extract below.

 

3962 17:35:02.583 D🠊 HCI CMD HCI_RAW Command Data:
3963 17:35:02.583 D🠊 HCI CMD 0000: b3 18 a8 0d ec 38 00 .....8.
3964 17:35:02.583 D🠊 HCI CMD SENT [2] Command to HCI. Name: HCI_Accept_Connection_Request (Hex Code: 0x0409 Param Len: 7)
3965 17:35:02.583 D🠊 HCI CMD BD_ADDR of remote device : 38-ec-0d-a8-18-b3
3966 17:35:02.583 D🠊 HCI CMD Role (0 = master, 1 = slave) : 0 (0x00)

 

How to disable that? We want that our evaluation board remains slave after accepting incoming connection.

0 Likes
1 Solution
Owen_Zhang123
Moderator
Moderator
Moderator
500 solutions authored 250 sign-ins 1000 replies posted

Please try the following code to see if it works:

wiced_result_t hci_control_management_callback( wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data )
{

    ....
    switch( event )
    {
    case BTM_ENABLED_EVT:
          ....
    			{
				uint8_t role;
				role = wiced_bt_l2cap_set_desire_role(L2CAP_ROLE_DISALLOW_SWITCH);
				WICED_BT_TRACE("==== disable switch role=%d\n", role );
				role = wiced_bt_l2cap_set_desire_role(HCI_ROLE_SLAVE);
				WICED_BT_TRACE("==== set desire role=%d\n", role );
			}
    break;
     ....
    }
    
}

 

View solution in original post

4 Replies
Owen_Zhang123
Moderator
Moderator
Moderator
500 solutions authored 250 sign-ins 1000 replies posted

Please try the following code to see if it works:

wiced_result_t hci_control_management_callback( wiced_bt_management_evt_t event, wiced_bt_management_evt_data_t *p_event_data )
{

    ....
    switch( event )
    {
    case BTM_ENABLED_EVT:
          ....
    			{
				uint8_t role;
				role = wiced_bt_l2cap_set_desire_role(L2CAP_ROLE_DISALLOW_SWITCH);
				WICED_BT_TRACE("==== disable switch role=%d\n", role );
				role = wiced_bt_l2cap_set_desire_role(HCI_ROLE_SLAVE);
				WICED_BT_TRACE("==== set desire role=%d\n", role );
			}
    break;
     ....
    }
    
}

 

KoFo_4760836
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

@Owen_Zhang123  Thank you for the answer! Just let me understand: the 1st API call wiced_bt_l2cap_set_desire_role(L2CAP_ROLE_DISALLOW_SWITCH) disables role switch and the 2nd call wiced_bt_l2cap_set_desire_role(HCI_ROLE_SLAVE) makes sure that our device will be a slave even if it initiates ACL connection, right? But what about incoming connections? Does the 1st API call wiced_bt_l2cap_set_desire_role(L2CAP_ROLE_DISALLOW_SWITCH) disables role switch for incoming connections as well?

0 Likes

Yes, you can use the API wiced_bt_l2cap_set_desire_role(L2CAP_ROLE_DISALLOW_SWITCH) to disable the role switch.

KoFo_4760836
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

@Owen_Zhang123 Thank you very much for the answer! The suggested solution seems to work.

0 Likes