/******************************************************************************* ** ** Function bta_pan_disable ** ** Description ** ** ** ** Returns void ** *******************************************************************************/ void bta_pan_disable(void) { BT_HDR *p_buf; tBTA_PAN_SCB *p_scb = &bta_pan_cb.scb[0]; UINT8 i; /* close all connections */ PAN_SetRole (0, NULL, NULL, NULL, NULL); #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE) bta_sys_remove_uuid(UUID_SERVCLASS_NAP); bta_sys_remove_uuid(UUID_SERVCLASS_GN); bta_sys_remove_uuid(UUID_SERVCLASS_PANU); #endif /* free all queued up data buffers */ for (i = 0; i < BTA_PAN_NUM_CONN; i++, p_scb++) { if (p_scb->in_use) { while((p_buf = (BT_HDR *)GKI_dequeue(&p_scb->data_queue)) != NULL) GKI_freebuf(p_buf); bta_pan_co_close(p_scb->handle, p_scb->app_id); } } PAN_Deregister(); }
/******************************************************************************* ** ** Function bta_hf_client_del_record ** ** Description Delete SDP record for registered service. ** ** ** Returns void ** *******************************************************************************/ void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data) { UNUSED(p_data); APPL_TRACE_DEBUG("bta_hf_client_del_record"); if (bta_hf_client_cb.sdp_handle != 0) { SDP_DeleteRecord(bta_hf_client_cb.sdp_handle); bta_hf_client_cb.sdp_handle = 0; BTM_FreeSCN(bta_hf_client_cb.scn); BTM_SecClrService(BTM_SEC_SERVICE_HF_HANDSFREE); bta_sys_remove_uuid(UUID_SERVCLASS_HF_HANDSFREE); } }
/****************************************************************************** ** ** Function bta_ar_dereg_avrc ** ** Description This function is called to de-register/delete an SDP record for AVRCP. ** ** Returns void ** ******************************************************************************/ void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id) { UINT8 mask = bta_ar_id (sys_id); UINT16 categories = 0; UINT8 temp[8], *p; if (!mask) { return; } if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) { bta_ar_cb.tg_registered = 0; SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle); bta_ar_cb.sdp_tg_handle = 0; bta_sys_remove_uuid(service_uuid); } } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) { if (bta_ar_cb.sdp_ct_handle) { bta_ar_cb.ct_categories [mask - 1] = 0; categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; if (!categories) { /* no CT is still registered - cleaup */ SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle); bta_ar_cb.sdp_ct_handle = 0; bta_sys_remove_uuid(service_uuid); } else { /* change supported categories to the remaning one */ p = temp; UINT16_TO_BE_STREAM(p, categories); SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, (UINT32)2, (UINT8 *)temp); } } } }
/******************************************************************************* ** ** Function bta_pan_set_role ** ** Description ** ** Returns void ** *******************************************************************************/ void bta_pan_set_role(tBTA_PAN_DATA *p_data) { tPAN_RESULT status; tBTA_PAN_SET_ROLE set_role; UINT8 sec[3]; bta_pan_cb.app_id[0] = p_data->api_set_role.user_app_id; bta_pan_cb.app_id[1] = p_data->api_set_role.gn_app_id; bta_pan_cb.app_id[2] = p_data->api_set_role.nap_app_id; sec[0] = p_data->api_set_role.user_sec_mask; sec[1] = p_data->api_set_role.gn_sec_mask; sec[2] = p_data->api_set_role.nap_sec_mask; /* set security correctly in api and here */ status = PAN_SetRole(p_data->api_set_role.role, sec, p_data->api_set_role.user_name, p_data->api_set_role.gn_name, p_data->api_set_role.nap_name); set_role.role = p_data->api_set_role.role; if(status == PAN_SUCCESS) { if(p_data->api_set_role.role & PAN_ROLE_NAP_SERVER ) bta_sys_add_uuid(UUID_SERVCLASS_NAP); else bta_sys_remove_uuid(UUID_SERVCLASS_NAP); if(p_data->api_set_role.role & PAN_ROLE_GN_SERVER ) bta_sys_add_uuid(UUID_SERVCLASS_GN); else bta_sys_remove_uuid(UUID_SERVCLASS_GN); if(p_data->api_set_role.role & PAN_ROLE_CLIENT ) bta_sys_add_uuid(UUID_SERVCLASS_PANU); else bta_sys_remove_uuid(UUID_SERVCLASS_PANU); set_role.status = BTA_PAN_SUCCESS; } /* if status is not success clear everything */ else { PAN_SetRole(0, 0, NULL, NULL, NULL); bta_sys_remove_uuid(UUID_SERVCLASS_NAP); bta_sys_remove_uuid(UUID_SERVCLASS_GN); bta_sys_remove_uuid(UUID_SERVCLASS_PANU); set_role.status = BTA_PAN_FAIL; } bta_pan_cb.p_cback(BTA_PAN_SET_ROLE_EVT, (tBTA_PAN *)&set_role); }
/******************************************************************************* ** ** Function bta_ag_del_records ** ** Description Delete SDP records for any registered services. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_del_records(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data) { tBTA_AG_SCB *p = &bta_ag_cb.scb[0]; tBTA_SERVICE_MASK services; tBTA_SERVICE_MASK others = 0; int i; UNUSED(p_data); /* get services of all other registered servers */ for (i = 0; i < BTA_AG_NUM_IDX; i++, p++) { if (p_scb == p) { continue; } if (p->in_use && p->dealloc == FALSE) { others |= p->reg_services; } } others >>= BTA_HSP_SERVICE_ID; services = p_scb->reg_services >> BTA_HSP_SERVICE_ID; for (i = 0; i < BTA_AG_NUM_IDX && services != 0; i++, services >>= 1, others >>= 1) { /* if service registered for this scb and not registered for any other scb */ if (((services & 1) == 1) && ((others & 1) == 0)) { APPL_TRACE_DEBUG("bta_ag_del_records %d", i); if (bta_ag_cb.profile[i].sdp_handle != 0) { SDP_DeleteRecord(bta_ag_cb.profile[i].sdp_handle); bta_ag_cb.profile[i].sdp_handle = 0; } BTM_FreeSCN(bta_ag_cb.profile[i].scn); BTM_SecClrService(bta_ag_sec_id[i]); bta_sys_remove_uuid(bta_ag_uuid[i]); } } }
/******************************************************************************* ** ** Function PAN_SetRole ** ** Description This function is called by the application to set the PAN ** profile role. This should be called after PAN_Register. ** This can be called any time to change the PAN role ** ** Parameters: role - is bit map of roles to be active ** PAN_ROLE_CLIENT is for PANU role ** PAN_ROLE_GN_SERVER is for GN role ** PAN_ROLE_NAP_SERVER is for NAP role ** sec_mask - Security mask for different roles ** It is array of UINT8. The byte represent the ** security for roles PANU, GN and NAP in order ** p_user_name - Service name for PANU role ** p_gn_name - Service name for GN role ** p_nap_name - Service name for NAP role ** Can be NULL if user wants it to be default ** ** Returns PAN_SUCCESS - if the role is set successfully ** PAN_FAILURE - if the role is not valid ** *******************************************************************************/ tPAN_RESULT PAN_SetRole (UINT8 role, UINT8 *sec_mask, char *p_user_name, char *p_gn_name, char *p_nap_name) { char *p_desc; UINT8 security[3] = {PAN_PANU_SECURITY_LEVEL, PAN_GN_SECURITY_LEVEL, PAN_NAP_SECURITY_LEVEL}; UINT8 *p_sec; /* If the role is not a valid combination reject it */ if ((!(role & (PAN_ROLE_CLIENT | PAN_ROLE_GN_SERVER | PAN_ROLE_NAP_SERVER))) && role != PAN_ROLE_INACTIVE) { PAN_TRACE_ERROR1 ("PAN role %d is invalid", role); return PAN_FAILURE; } /* If the current active role is same as the role being set do nothing */ if (pan_cb.role == role) { PAN_TRACE_EVENT1 ("PAN role already was set to: %d", role); return PAN_SUCCESS; } if (!sec_mask) p_sec = security; else p_sec = sec_mask; /* Register all the roles with SDP */ PAN_TRACE_API1 ("PAN_SetRole() called with role 0x%x", role); #if (defined (PAN_SUPPORTS_ROLE_NAP) && PAN_SUPPORTS_ROLE_NAP == TRUE) /* Check the service name */ if ((p_nap_name == NULL) || (*p_nap_name == 0)) p_nap_name = PAN_NAP_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_NAP_SERVER) { /* Registering for NAP service with SDP */ p_desc = PAN_NAP_DEFAULT_DESCRIPTION; if (pan_cb.pan_nap_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_nap_sdp_handle); pan_cb.pan_nap_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_NAP, p_sec[2], p_nap_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_NAP); // btla-specific -- } /* If the NAP role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_NAP_SERVER) { if (pan_cb.pan_nap_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_nap_sdp_handle); pan_cb.pan_nap_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_NAP); // btla-specific -- } } #endif #if (defined (PAN_SUPPORTS_ROLE_GN) && PAN_SUPPORTS_ROLE_GN == TRUE) /* Check the service name */ if ((p_gn_name == NULL) || (*p_gn_name == 0)) p_gn_name = PAN_GN_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_GN_SERVER) { /* Registering for GN service with SDP */ p_desc = PAN_GN_DEFAULT_DESCRIPTION; if (pan_cb.pan_gn_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_gn_sdp_handle); pan_cb.pan_gn_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_GN, p_sec[1], p_gn_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_GN); // btla-specific -- } /* If the GN role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_GN_SERVER) { if (pan_cb.pan_gn_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_gn_sdp_handle); pan_cb.pan_gn_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_GN); // btla-specific -- } } #endif #if (defined (PAN_SUPPORTS_ROLE_PANU) && PAN_SUPPORTS_ROLE_PANU == TRUE) /* Check the service name */ if ((p_user_name == NULL) || (*p_user_name == 0)) p_user_name = PAN_PANU_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_CLIENT) { /* Registering for PANU service with SDP */ p_desc = PAN_PANU_DEFAULT_DESCRIPTION; if (pan_cb.pan_user_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_user_sdp_handle); pan_cb.pan_user_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_PANU, p_sec[0], p_user_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_PANU); // btla-specific -- } /* If the PANU role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_CLIENT) { if (pan_cb.pan_user_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_user_sdp_handle); pan_cb.pan_user_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_PANU); // btla-specific -- } } #endif /* Check if it is a shutdown request */ if (role == PAN_ROLE_INACTIVE) pan_close_all_connections (); pan_cb.role = role; PAN_TRACE_EVENT1 ("PAN role set to: %d", role); return PAN_SUCCESS; }