static void bta_hf_client_start_at_resp_timer(void) { if (bta_hf_client_cb.scb.at_cb.resp_timer_on) { bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.resp_timer); } bta_hf_client_cb.scb.at_cb.resp_timer.p_cback = (TIMER_CBACK *)&bta_hf_client_at_resp_timer_cback; bta_sys_start_timer(&bta_hf_client_cb.scb.at_cb.resp_timer, 0, BTA_HF_CLIENT_AT_TIMEOUT); bta_hf_client_cb.scb.at_cb.resp_timer_on = TRUE; }
static void bta_hf_client_start_at_hold_timer(void) { TIMER_LIST_ENT *timer = &bta_hf_client_cb.scb.at_cb.hold_timer; APPL_TRACE_DEBUG("%s", __FUNCTION__); if (bta_hf_client_cb.scb.at_cb.hold_timer_on) { bta_sys_stop_timer (timer); } timer->p_cback = (TIMER_CBACK *)&bta_hf_client_at_hold_timer_cback; bta_sys_start_timer(timer, 0, BTA_HF_CLIENT_AT_HOLD_TIMEOUT); bta_hf_client_cb.scb.at_cb.hold_timer_on = TRUE; }
/******************************************************************************* ** ** Function bta_ag_collision_cback ** ** Description Get notified about collision. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr) { UINT16 handle; tBTA_AG_SCB *p_scb; UNUSED(status); UNUSED(app_id); /* Check if we have opening scb for the peer device. */ handle = bta_ag_idx_by_bdaddr (peer_addr); p_scb = bta_ag_scb_by_idx (handle); if (p_scb && (p_scb->state == BTA_AG_OPENING_ST)) { if (id == BTA_ID_SYS) /* ACL collision */ { APPL_TRACE_WARNING ("AG found collision (ACL) ..."); } else if (id == BTA_ID_AG) /* RFCOMM collision */ { APPL_TRACE_WARNING ("AG found collision (RFCOMM) ..."); } else { APPL_TRACE_WARNING ("AG found collision (\?\?\?) ..."); } p_scb->state = BTA_AG_INIT_ST; /* Cancel SDP if it had been started. */ if(p_scb->p_disc_db) { (void)SDP_CancelServiceSearch (p_scb->p_disc_db); bta_ag_free_db(p_scb, NULL); } /* reopen registered servers */ /* Collision may be detected before or after we close servers. */ if (bta_ag_is_server_closed (p_scb)) bta_ag_start_servers(p_scb, p_scb->reg_services); /* Start timer to han */ p_scb->colli_timer.p_cback = (TIMER_CBACK*)&bta_ag_colli_timer_cback; p_scb->colli_timer.param = (INT32)p_scb; bta_sys_start_timer(&p_scb->colli_timer, 0, BTA_AG_COLLISION_TIMER); p_scb->colli_tmr_on = TRUE; } }
/******************************************************************************* ** ** Function bta_av_switch_if_needed ** ** Description This function checks if there is another existing AV ** channel that is local as slave role. ** If so, role switch and remove it from link policy. ** ** Returns TRUE, if role switch is done ** *******************************************************************************/ BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb) { UINT8 role; BOOLEAN needed = FALSE; tBTA_AV_SCB *p_scbi; int i; UINT8 mask; for(i=0; i<BTA_AV_NUM_STRS; i++) { mask = BTA_AV_HNDL_TO_MSK(i); p_scbi = bta_av_cb.p_scb[i]; if( p_scbi && (p_scb->hdi != i) && /* not the original channel */ ((bta_av_cb.conn_audio & mask) ||/* connected audio */ (bta_av_cb.conn_video & mask)) ) /* connected video */ { BTM_GetRole(p_scbi->peer_addr, &role); /* this channel is open - clear the role switch link policy for this link */ if(BTM_ROLE_MASTER != role) { if (bta_av_cb.features & BTA_AV_FEAT_MASTER) bta_sys_clear_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH, p_scbi->peer_addr); if (BTM_CMD_STARTED != BTM_SwitchRole(p_scbi->peer_addr, BTM_ROLE_MASTER, NULL)) { /* can not switch role on SCBI * start the timer on SCB - because this function is ONLY called when SCB gets API_OPEN */ bta_sys_start_timer(&p_scb->timer, BTA_AV_AVRC_TIMER_EVT, BTA_AV_RS_TIME_VAL); } needed = TRUE; /* mark the original channel as waiting for RS result */ bta_av_cb.rs_idx = p_scb->hdi + 1; break; } } } return needed; }
/******************************************************************************* ** ** Function bta_dm_pm_set_mode ** ** Description Set the power mode for the device ** ** ** Returns void ** *******************************************************************************/ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, BOOLEAN timed_out ) { tBTA_DM_PM_ACTTION pm_action = BTA_DM_PM_NO_ACTION; UINT16 timeout = 0; UINT8 i,j; tBTA_DM_PM_ACTTION failed_pm = 0; tBTA_DM_PEER_DEVICE *p_peer_device = NULL; tBTA_DM_PM_ACTTION allowed_modes = 0; tBTA_DM_PM_ACTTION pref_modes = 0; tBTA_DM_PM_CFG *p_pm_cfg; tBTA_DM_PM_SPEC *p_pm_spec; tBTA_DM_PM_ACTN *p_act0, *p_act1; tBTA_DM_SRVCS *p_srvcs; if(!bta_dm_cb.device_list.count) return; /* see if any attempt to put device in low power mode failed */ p_peer_device = bta_dm_find_peer_device(peer_addr); /* if no peer device found return */ if (p_peer_device == NULL) return; failed_pm = p_peer_device->pm_mode_failed; for(i=0; i<bta_dm_conn_srvcs.count ; i++) { p_srvcs = &bta_dm_conn_srvcs.conn_srvc[i]; if(!bdcmp(p_srvcs->peer_bdaddr, peer_addr)) { /* p_bta_dm_pm_cfg[0].app_id is the number of entries */ for(j=1; j<=p_bta_dm_pm_cfg[0].app_id; j++) { if((p_bta_dm_pm_cfg[j].id == p_srvcs->id) && ((p_bta_dm_pm_cfg[j].app_id == BTA_ALL_APP_ID ) || (p_bta_dm_pm_cfg[j].app_id == p_srvcs->app_id))) break; } p_pm_cfg = &p_bta_dm_pm_cfg[j]; p_pm_spec = &p_bta_dm_pm_spec[p_pm_cfg->spec_idx]; p_act0 = &p_pm_spec->actn_tbl[p_srvcs->state][0]; p_act1 = &p_pm_spec->actn_tbl[p_srvcs->state][1]; APPL_TRACE_DEBUG("bta_dm_pm_set_mode: srvcsid: %d, state: %d, j: %d", p_srvcs->id, p_srvcs->state, j); allowed_modes |= p_pm_spec->allow_mask; /* PM actions are in the order of strictness */ /* first check if the first preference is ok */ if(!(failed_pm & p_act0->power_mode)) { pref_modes |= p_act0->power_mode; if(p_act0->power_mode > pm_action) { pm_action = p_act0->power_mode; timeout = p_act0->timeout; } } /* if first preference has already failed, try second preference */ else if(!(failed_pm & p_act1->power_mode)) { pref_modes |= p_act1->power_mode; if(p_act1->power_mode > pm_action) { pm_action = p_act1->power_mode; timeout = p_act1->timeout; } } } } if(pm_action & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF)) { /* some service don't like the mode */ if(!(allowed_modes & pm_action)) { /* select the other mode if its allowed and preferred, otherwise 0 which is BTA_DM_PM_NO_ACTION */ pm_action = (allowed_modes & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF) & pref_modes); /* no timeout needed if no action is required */ if(pm_action == BTA_DM_PM_NO_ACTION) { timeout = 0; } } } if(!timed_out && timeout) { for(i=0; i<BTA_DM_NUM_PM_TIMER; i++) { if(!bta_dm_cb.pm_timer[i].in_use) { bta_dm_cb.pm_timer[i].in_use = TRUE; bdcpy(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr); bta_dm_cb.pm_timer[i].timer.p_cback = bta_dm_pm_timer_cback; bta_sys_start_timer(&bta_dm_cb.pm_timer[i].timer, 0, timeout); APPL_TRACE_DEBUG("start dm_pm_timer:%d, %d", i, timeout); return; } } /* no more timers */ if(i==BTA_DM_NUM_PM_TIMER) { APPL_TRACE_WARNING("bta_dm_act dm_pm_timer no more"); return; } } if(pm_action == BTA_DM_PM_NO_ACTION) { } else if(pm_action == BTA_DM_PM_PARK) { p_peer_device->pm_mode_attempted = BTA_DM_PM_PARK; bta_dm_pm_park(peer_addr); } else if(pm_action & BTA_DM_PM_SNIFF) { /* dont initiate SNIFF, if link_policy has it disabled */ if (p_peer_device->link_policy & HCI_ENABLE_SNIFF_MODE) { p_peer_device->pm_mode_attempted = BTA_DM_PM_SNIFF; bta_dm_pm_sniff(p_peer_device, (UINT8)(pm_action & 0x0F) ); } else { APPL_TRACE_DEBUG("bta_dm_pm_set_mode: Link policy disallows SNIFF, ignore request"); } } else if(pm_action == BTA_DM_PM_ACTIVE) { bta_dm_pm_active(peer_addr); } }