Keep in slave role

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

cross mob
wenchilo
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hi cypress team,

I am work on spp sample code with CYBT-343026. And I want to keep my 343026 in slave, but sometimes there's a role switch that my 343026 become master. I have tride wiced_bt_dev_switch_role to switch it back to slave but it doesn't  work. What can I do to keep it in slave mode.

0 Likes
1 Solution

The API can work for BT configuration. Please set it as follows:

uint8_t  role;

        case BTM_ENABLED_EVT:

              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(0x01);//slave = 0x01

            WICED_BT_TRACE("==== set desire role=%d\n", role );

View solution in original post

0 Likes
7 Replies
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi @wenchilo 

Can you please let us know the peer device you are using? 

What is the result of wiced_bt_dev_switch_role  API ? Where exactly you are using this API in your application code?

Regards,

Anjana

 

0 Likes
wenchilo
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

1. The peer device is also CYBT-343026

2. I am not sure about the result of wiced_bt_dev_switch_role cause WICED_BT_CMD_STARTED and 

WICED_BT_MODE_UNSUPPORTED are undefined, but I think it should be one of them.
3.I am using this api in rx callback, while I receiving a specific uart command
Thanks
0 Likes
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

Please try to use the following API:

/**
*
* Function wiced_bt_l2cap_set_desire_role
*
* This function sets the desire role for L2CAP.
* If the new role is L2CAP_ROLE_ALLOW_SWITCH, allow switch on
* HciCreateConnection.
* If the new role is L2CAP_ROLE_DISALLOW_SWITCH, do not allow switch on
* HciCreateConnection.
*
* If the new role is a valid role (HCI_ROLE_CENTRAL or HCI_ROLE_PERIPHERAL),
* the desire role is set to the new value. Otherwise, it is not changed.
*
* @param[in] new_role: New role value
*
* @return the new (current) role
*
*/
uint8_t wiced_bt_l2cap_set_desire_role (uint8_t new_role);

0 Likes
wenchilo
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hi, can this API be called after making a connection, or do I have to choose the role before connection

0 Likes
wenchilo
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

I have tried calling wiced_bt_l2cap_set_desire_role before and after making a connection. But it still doesn't work. 

0 Likes
wenchilo
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

I am not sure if wiced_bt_l2cap_set_desire_role works on bt cause the introduction says valid role including HCI_ROLE_CENTRAL or HCI_ROLE_PERIPHERAL but not master and slave.

0 Likes

The API can work for BT configuration. Please set it as follows:

uint8_t  role;

        case BTM_ENABLED_EVT:

              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(0x01);//slave = 0x01

            WICED_BT_TRACE("==== set desire role=%d\n", role );

0 Likes