static void bta_hf_client_stop_at_resp_timer(void) { if (bta_hf_client_cb.scb.at_cb.resp_timer_on) { bta_hf_client_cb.scb.at_cb.resp_timer_on = FALSE; bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.resp_timer); } }
static void bta_hf_client_stop_at_hold_timer(void) { APPL_TRACE_DEBUG("%s", __FUNCTION__); if (bta_hf_client_cb.scb.at_cb.hold_timer_on) { bta_hf_client_cb.scb.at_cb.hold_timer_on = FALSE; bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.hold_timer); } }
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_scb_dealloc ** ** Description Deallocate a service control block. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_scb_dealloc(tBTA_AG_SCB *p_scb) { UINT8 idx; BOOLEAN allocated = FALSE; APPL_TRACE_DEBUG("bta_ag_scb_dealloc %d", bta_ag_scb_to_idx(p_scb)); /* stop timers */ bta_sys_stop_timer(&p_scb->act_timer); #if (BTM_WBS_INCLUDED == TRUE) bta_sys_stop_timer(&p_scb->cn_timer); #endif bta_sys_stop_timer(&p_scb->colli_timer); /* initialize control block */ memset(p_scb, 0, sizeof(tBTA_AG_SCB)); p_scb->sco_idx = BTM_INVALID_SCO_INDEX; /* If all scbs are deallocated, callback with disable event */ if (!bta_sys_is_register (BTA_ID_AG)) { for (idx = 0; idx < BTA_AG_NUM_SCB; idx++) { if (bta_ag_cb.scb[idx].in_use) { allocated = TRUE; break; } } if (!allocated) { (*bta_ag_cb.p_cback)(BTA_AG_DISABLE_EVT, NULL); } } }
/******************************************************************************* ** ** Function bta_dm_pm_stop_timer ** ** Description stop a PM timer ** ** ** Returns void ** *******************************************************************************/ static void bta_dm_pm_stop_timer(BD_ADDR peer_addr) { UINT8 i; for(i=0; i<BTA_DM_NUM_PM_TIMER; i++) { if(bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr)) { APPL_TRACE_DEBUG("stop dm_pm_timer:%d", i); bta_sys_stop_timer(&bta_dm_cb.pm_timer[i].timer); bta_dm_cb.pm_timer[i].in_use = FALSE; break; } } }
/******************************************************************************* ** ** Function bta_hf_client_rfc_acp_open ** ** Description Handle RFCOMM channel open when accepting connection. ** ** ** Returns void ** *******************************************************************************/ void bta_hf_client_rfc_acp_open(tBTA_HF_CLIENT_DATA *p_data) { UINT16 lcid; BD_ADDR dev_addr; int status; /* set role */ bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP; APPL_TRACE_DEBUG ("bta_hf_client_rfc_acp_open: serv_handle = %d rfc.port_handle = %d", bta_hf_client_cb.scb.serv_handle, p_data->rfc.port_handle); /* get bd addr of peer */ if (PORT_SUCCESS != (status=PORT_CheckConnection(p_data->rfc.port_handle, dev_addr, &lcid))) { APPL_TRACE_DEBUG ("bta_hf_client_rfc_acp_open error PORT_CheckConnection returned status %d", status); } /* Collision Handling */ if (bta_hf_client_cb.scb.colli_tmr_on) { /* stop collision timer */ bta_hf_client_cb.scb.colli_tmr_on = FALSE; bta_sys_stop_timer (&bta_hf_client_cb.scb.colli_timer); if (bdcmp (dev_addr, bta_hf_client_cb.scb.peer_addr) == 0) { /* If incoming and outgoing device are same, nothing more to do. */ /* Outgoing conn will be aborted because we have successful incoming conn. */ } else { /* Resume outgoing connection. */ bta_hf_client_resume_open (); } } bdcpy (bta_hf_client_cb.scb.peer_addr, dev_addr); bta_hf_client_cb.scb.conn_handle = p_data->rfc.port_handle; /* do service discovery to get features */ bta_hf_client_do_disc(); /* continue with open processing */ bta_hf_client_rfc_open(p_data); }
/******************************************************************************* ** ** Function bta_dm_disable_pm ** ** Description Disable PM ** ** ** Returns void ** *******************************************************************************/ void bta_dm_disable_pm(void) { UINT8 i; bta_sys_pm_register(NULL); BTM_PmRegister( BTM_PM_DEREG, &bta_dm_cb.pm_id, NULL); /* Need to stop all active timers. */ for(i=0; i<BTA_DM_NUM_PM_TIMER; i++) { if(bta_dm_cb.pm_timer[i].in_use) { APPL_TRACE_DEBUG("stop dm_pm_timer:%d", i); bta_sys_stop_timer(&bta_dm_cb.pm_timer[i].timer); bta_dm_cb.pm_timer[i].in_use = FALSE; } } }
/******************************************************************************* ** ** Function bta_ag_rfc_acp_open ** ** Description Handle RFCOMM channel open when accepting connection. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_rfc_acp_open(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data) { UINT16 lcid; int i; tBTA_AG_SCB *ag_scb, *other_scb; BD_ADDR dev_addr; int status; /* set role */ p_scb->role = BTA_AG_ACP; APPL_TRACE_IMP ("bta_ag_rfc_acp_open: serv_handle0 = %d serv_handle1 = %d", p_scb->serv_handle[0], p_scb->serv_handle[1]); /* get bd addr of peer */ if (PORT_SUCCESS != (status=PORT_CheckConnection(p_data->rfc.port_handle, dev_addr, &lcid))) { APPL_TRACE_DEBUG ("bta_ag_rfc_acp_open error PORT_CheckConnection returned status %d", status); } /* Collision Handling */ for (i = 0, ag_scb = &bta_ag_cb.scb[0]; i < BTA_AG_NUM_SCB; i++, ag_scb++) { if ((ag_scb->in_use) && (ag_scb->colli_tmr_on)) { /* stop collision timer */ ag_scb->colli_tmr_on = FALSE; bta_sys_stop_timer (&ag_scb->colli_timer); if (bdcmp (dev_addr, ag_scb->peer_addr) == 0) { /* If incoming and outgoing device are same, nothing more to do. */ /* Outgoing conn will be aborted because we have successful incoming conn. */ } else { /* Resume outgoing connection. */ other_scb = bta_ag_get_other_idle_scb (p_scb); if (other_scb) { bdcpy(other_scb->peer_addr, ag_scb->peer_addr); other_scb->open_services = ag_scb->open_services; other_scb->cli_sec_mask = ag_scb->cli_sec_mask; bta_ag_resume_open (other_scb); } } break; } } bdcpy (p_scb->peer_addr, dev_addr); /* determine connected service from port handle */ for (i = 0; i < BTA_AG_NUM_IDX; i++) { APPL_TRACE_DEBUG ("bta_ag_rfc_acp_open: i = %d serv_handle = %d port_handle = %d", i, p_scb->serv_handle[i], p_data->rfc.port_handle); if (p_scb->serv_handle[i] == p_data->rfc.port_handle) { p_scb->conn_service = i; p_scb->conn_handle = p_data->rfc.port_handle; break; } } APPL_TRACE_IMP ("bta_ag_rfc_acp_open: conn_service = %d conn_handle = %d", p_scb->conn_service, p_scb->conn_handle); /* close any unopened server */ bta_ag_close_servers(p_scb, (p_scb->reg_services & ~bta_ag_svc_mask[p_scb->conn_service])); /* do service discovery to get features */ bta_ag_do_disc(p_scb, bta_ag_svc_mask[p_scb->conn_service]); /* continue with common open processing */ bta_ag_rfc_open(p_scb, p_data); }
/******************************************************************************* ** ** Function bta_ag_rfc_close ** ** Description RFCOMM connection closed. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_rfc_close(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data) { tBTA_AG_CLOSE close; tBTA_SERVICE_MASK services; int i, num_active_conn = 0; UNUSED(p_data); #ifdef _WIN32_WCE /* The BTE RFCOMM automatically removes the connection when closed, but BTW does not */ if (p_scb->conn_handle != 0) RFCOMM_RemoveConnection (p_scb->conn_handle); #endif /* reinitialize stuff */ p_scb->conn_service = 0; p_scb->peer_features = 0; #if (BTM_WBS_INCLUDED == TRUE ) p_scb->peer_codecs = BTA_AG_CODEC_NONE; p_scb->sco_codec = BTA_AG_CODEC_NONE; /* Clear these flags upon SLC teardown */ p_scb->codec_updated = FALSE; p_scb->codec_fallback = FALSE; p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2; #endif p_scb->role = 0; p_scb->post_sco = BTA_AG_POST_SCO_NONE; p_scb->svc_conn = FALSE; p_scb->hsp_version = HSP_VERSION_1_2; bta_ag_at_reinit(&p_scb->at_cb); /* stop timers */ bta_sys_stop_timer(&p_scb->act_timer); #if (BTM_WBS_INCLUDED == TRUE) bta_sys_stop_timer(&p_scb->cn_timer); #endif close.hdr.handle = bta_ag_scb_to_idx(p_scb); close.hdr.app_id = p_scb->app_id; bdcpy(close.bd_addr, p_scb->peer_addr); bta_sys_conn_close(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr); /* call close call-out */ bta_ag_co_data_close(close.hdr.handle); /* call close cback */ (*bta_ag_cb.p_cback)(BTA_AG_CLOSE_EVT, (tBTA_AG *) &close); /* if not deregistering (deallocating) reopen registered servers */ if (p_scb->dealloc == FALSE) { /* Clear peer bd_addr so instance can be reused */ bdcpy(p_scb->peer_addr, bd_addr_null); /* start only unopened server */ services = p_scb->reg_services; for (i = 0; i < BTA_AG_NUM_IDX && services != 0; i++) { if(p_scb->serv_handle[i]) services &= ~((tBTA_SERVICE_MASK)1 << (BTA_HSP_SERVICE_ID + i)); } bta_ag_start_servers(p_scb, services); p_scb->conn_handle = 0; /* Make sure SCO state is BTA_AG_SCO_SHUTDOWN_ST */ bta_ag_sco_shutdown(p_scb, NULL); /* Check if all the SLCs are down */ for (i = 0; i < BTA_AG_NUM_SCB; i++) { if (bta_ag_cb.scb[i].in_use && bta_ag_cb.scb[i].svc_conn) num_active_conn++; } if(!num_active_conn) { bta_sys_sco_unuse(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr); } } /* else close port and deallocate scb */ else { RFCOMM_RemoveServer(p_scb->conn_handle); bta_ag_scb_dealloc(p_scb); } }