/*******************************************************************************
**
-** Function btm_save_remote_device_role
-**
-** Description This function is to save remote device role
-**
-** Returns void
-**
-*******************************************************************************/
-static void btm_save_remote_device_role(BD_ADDR bd_addr, UINT8 role)
-{
- UINT8 i, j;
- if (role == BTM_ROLE_UNDEFINED) return;
-
- for (i = 0; i < BTM_ROLE_DEVICE_NUM; i++) {
- if ((btm_cb.previous_connected_role[i] != BTM_ROLE_UNDEFINED) &&
- (!bdcmp(bd_addr, btm_cb.previous_connected_remote_addr[i]))) {
- break;
- }
- }
-
- if (i < BTM_ROLE_DEVICE_NUM) {
- UINT8 end;
- if (i < btm_cb.front) {
- for (j = i; j > 0; j--) {
- bdcpy(btm_cb.previous_connected_remote_addr[j],
- btm_cb.previous_connected_remote_addr[j-1]);
- }
- bdcpy(btm_cb.previous_connected_remote_addr[0],
- btm_cb.previous_connected_remote_addr[BTM_ROLE_DEVICE_NUM-1]);
- end = BTM_ROLE_DEVICE_NUM-1;
- } else {
- end = i;
- }
-
- for (j = end; j > btm_cb.front; j--) {
- bdcpy(btm_cb.previous_connected_remote_addr[j],
- btm_cb.previous_connected_remote_addr[j-1]);
- }
- }
-
- bdcpy(btm_cb.previous_connected_remote_addr[btm_cb.front], bd_addr);
- btm_cb.previous_connected_role[btm_cb.front] = role;
- btm_cb.front = (btm_cb.front + 1) % BTM_ROLE_DEVICE_NUM;
-}
-
-/*******************************************************************************
-**
** Function btm_acl_init
**
** Description This function is called at BTM startup to initialize
{
p->hci_handle = hci_handle;
p->link_role = link_role;
- btm_save_remote_device_role(bda, link_role);
#if BLE_INCLUDED == TRUE
p->transport = transport;
#endif
p->in_use = TRUE;
p->hci_handle = hci_handle;
p->link_role = link_role;
- btm_save_remote_device_role(bda, link_role);
p->link_up_issued = FALSE;
#if BLE_INCLUDED == TRUE
/* Update cached value */
p->link_role = new_role;
- btm_save_remote_device_role(p_bda, new_role);
+
/* Reload LSTO: link supervision timeout is reset in the LM after a role switch */
if (new_role == BTM_ROLE_MASTER)
{
*/
#define BTM_MAX_SCN PORT_MAX_RFC_PORTS
-/* Definition for number of the remote device role saved
-*/
-#define BTM_ROLE_DEVICE_NUM 4
-
/* Define masks for supported and exception 2.0 ACL packet types
*/
#define BTM_ACL_SUPPORTED_PKTS_MASK (HCI_PKT_TYPES_MASK_DM1 | \
tBTM_PCM2_ACTION pcm2_action;
#endif
- BD_ADDR previous_connected_remote_addr[BTM_ROLE_DEVICE_NUM];
- UINT8 previous_connected_role[BTM_ROLE_DEVICE_NUM];
- UINT8 front; /* front index of the role table */
} tBTM_CB;
*******************************************************************************/
void btm_init (void)
{
- UINT8 i;
/* All fields are cleared; nonzero fields are reinitialized in appropriate function */
memset(&btm_cb, 0, sizeof(tBTM_CB));
#else
btm_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
#endif
- for (i = 0; i < BTM_ROLE_DEVICE_NUM; i++) {
- btm_cb.previous_connected_role[i] = BTM_ROLE_UNDEFINED;
- }
/* Initialize BTM component structures */
btm_inq_db_init(); /* Inquiry Database and Structures */
btm_acl_init(); /* ACL Database and Structures */
*******************************************************************************/
UINT8 l2cu_get_conn_role (tL2C_LCB *p_this_lcb)
{
- UINT8 i;
- for (i = 0; i < BTM_ROLE_DEVICE_NUM; i++) {
- if ((btm_cb.previous_connected_role[i] != BTM_ROLE_UNDEFINED) &&
- (!bdcmp(p_this_lcb->remote_bd_addr, btm_cb.previous_connected_remote_addr[i]))) {
- L2CAP_TRACE_WARNING ("l2cu_get_conn_role %d",
- btm_cb.previous_connected_role[i]);
- return btm_cb.previous_connected_role[i];
- }
- }
return l2cb.desire_role;
}