/****************************************************************************** ** ** Function AVRC_AddRecord ** ** Description This function is called to build an AVRCP SDP record. ** Prior to calling this function the application must ** call SDP_CreateRecord() to create an SDP record. ** ** Input Parameters: ** service_uuid: Indicates TG(UUID_SERVCLASS_AV_REM_CTRL_TARGET) ** or CT(UUID_SERVCLASS_AV_REMOTE_CONTROL) ** ** p_service_name: Pointer to a null-terminated character ** string containing the service name. ** If service name is not used set this to NULL. ** ** p_provider_name: Pointer to a null-terminated character ** string containing the provider name. ** If provider name is not used set this to NULL. ** ** categories: Supported categories. ** ** sdp_handle: SDP handle returned by SDP_CreateRecord(). ** ** Output Parameters: ** None. ** ** Returns AVRC_SUCCESS if successful. ** AVRC_NO_RESOURCES if not enough resources to build the SDP record. ** ******************************************************************************/ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name, UINT16 categories, UINT32 sdp_handle) { UINT16 browse_list[1]; BOOLEAN result = TRUE; UINT8 temp[8]; UINT8 *p; UINT16 count = 1; UINT16 class_list[2]; AVRC_TRACE_API1("AVRC_AddRecord uuid: %x", service_uuid); if( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL ) return AVRC_BAD_PARAM; /* add service class id list */ class_list[0] = service_uuid; result &= SDP_AddServiceClassIdList(sdp_handle, count, class_list); /* add protocol descriptor list */ result &= SDP_AddProtocolList(sdp_handle, AVRC_NUM_PROTO_ELEMS, (tSDP_PROTOCOL_ELEM *)avrc_proto_list); /* add profile descriptor list */ #if AVRC_METADATA_INCLUDED == TRUE result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_3); #else result &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_AV_REMOTE_CONTROL, AVRC_REV_1_0); #endif /* add supported categories */ p = temp; UINT16_TO_BE_STREAM(p, categories); result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, (UINT32)2, (UINT8*)temp); /* add provider name */ if (p_provider_name != NULL) { result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_provider_name)+1), (UINT8 *) p_provider_name); } /* add service name */ if (p_service_name != NULL) { result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_service_name)+1), (UINT8 *) p_service_name); } /* add browse group list */ browse_list[0] = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP; result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); return (result ? AVRC_SUCCESS : AVRC_FAIL); }
/******************************************************************************* ** ** Function bta_hl_add_sup_feature_list ** ** Description This function is called to add a protocol descriptor list to ** a record. This would be through the SDP database maintenance API. ** If the protocol list already exists in the record, it is replaced ** with the new list. ** ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ BOOLEAN bta_hl_add_sup_feature_list (UINT32 handle, UINT16 num_elem, const tBTA_HL_SUP_FEATURE_ELEM *p_elem_list) { UINT8 *p_buf; int offset; BOOLEAN result = FALSE; if ((p_buf = (UINT8 *)GKI_getbuf(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE)) != NULL) { offset = bta_hl_compose_supported_feature_list(p_buf, num_elem, p_elem_list); result = SDP_AddAttribute (handle, ATTR_ID_HDP_SUP_FEAT_LIST, DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buf); GKI_freebuf(p_buf); } return result; }
int SDP_AddNewAttribute( SDP_Description * description, const char * name, const char * value) { SDP_Attribute *attribute; SDP_AssertNotNull(description); attribute = SDP_NewAttribute(); if (attribute == NULL) return SDP_FAILURE; ENSURE_COPY_TO_STR(attribute->name, name); ENSURE_COPY_TO_STR(attribute->value, value); SDP_AddAttribute(description, attribute); return SDP_SUCCESS; }
/****************************************************************************** ** ** 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_ar_reg_avrc ** ** Description This function is called to register an SDP record for AVRCP. ** ** Returns void ** ******************************************************************************/ void bta_ar_reg_avrc(UINT16 service_uuid, char *service_name, char *provider_name, UINT16 categories, tBTA_SYS_ID sys_id) { UINT8 mask = bta_ar_id (sys_id); UINT8 temp[8], *p; if (!mask || !categories) { return; } if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { if (bta_ar_cb.sdp_tg_handle == 0) { bta_ar_cb.tg_registered = mask; bta_ar_cb.sdp_tg_handle = SDP_CreateRecord(); AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle); bta_sys_add_uuid(service_uuid); } /* only one TG is allowed (first-come, first-served). * If sdp_tg_handle is non-0, ignore this request */ } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL)) { bta_ar_cb.ct_categories [mask - 1] = categories; categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; if (bta_ar_cb.sdp_ct_handle == 0) { bta_ar_cb.sdp_ct_handle = SDP_CreateRecord(); AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle); bta_sys_add_uuid(service_uuid); } else { /* multiple CTs are allowed. * Change supported categories on the second 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_hl_sdp_register ** ** Purpose: Register an HDP application with SDP ** ** Parameters: p_cb - Pointer to MA instance control block ** p_service_name - MA server name ** inst_id - MAS instance ID ** msg_type - Supported message type(s) ** ** ** Returns: void ** *****************************************************************************/ tBTA_HL_STATUS bta_hl_sdp_register (UINT8 app_idx) { UINT16 svc_class_id_list[BTA_HL_NUM_SVC_ELEMS]; tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HL_NUM_PROTO_ELEMS]; tSDP_PROTO_LIST_ELEM add_proto_list; tBTA_HL_SUP_FEATURE_LIST_ELEM sup_feature_list; UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; UINT8 i,j, cnt,mdep_id, mdep_role; UINT8 data_exchange_spec = BTA_HL_SDP_IEEE_11073_20601; UINT8 mcap_sup_proc = BTA_HL_MCAP_SUP_PROC_MASK; UINT16 profile_uuid = UUID_SERVCLASS_HDP_PROFILE; UINT16 version = BTA_HL_VERSION_01_00; UINT8 num_services=1; tBTA_HL_APP_CB *p_cb = BTA_HL_GET_APP_CB_PTR(app_idx); BOOLEAN result = TRUE; tBTA_HL_STATUS status = BTA_HL_STATUS_OK; #if BTA_HL_DEBUG == TRUE APPL_TRACE_DEBUG("bta_hl_sdp_register app_idx=%d",app_idx); #endif if ((p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SOURCE) && (!p_cb->sup_feature.advertize_source_sdp)) { return BTA_HL_STATUS_OK; } if ((p_cb->sdp_handle = SDP_CreateRecord()) == 0) { return BTA_HL_STATUS_SDP_NO_RESOURCE; } num_services=1; svc_class_id_list[0]= UUID_SERVCLASS_HDP_SOURCE; if (p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SINK) { svc_class_id_list[0]= UUID_SERVCLASS_HDP_SINK; } else { if (p_cb->sup_feature.app_role_mask != BTA_HL_MDEP_ROLE_MASK_SOURCE) { /* dual role */ num_services=2; svc_class_id_list[1]= UUID_SERVCLASS_HDP_SINK; } } result &= SDP_AddServiceClassIdList(p_cb->sdp_handle, num_services, svc_class_id_list); if (result) { /* add the protocol element sequence */ proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; proto_elem_list[0].num_params = 1; proto_elem_list[0].params[0] = p_cb->ctrl_psm; proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_MCAP_CTRL; proto_elem_list[1].num_params = 1; proto_elem_list[1].params[0] = version; result &= SDP_AddProtocolList(p_cb->sdp_handle, BTA_HL_NUM_PROTO_ELEMS, proto_elem_list); result &= SDP_AddProfileDescriptorList(p_cb->sdp_handle, profile_uuid, version); } if (result) { add_proto_list.num_elems = BTA_HL_NUM_ADD_PROTO_ELEMS; add_proto_list.list_elem[0].protocol_uuid = UUID_PROTOCOL_L2CAP; add_proto_list.list_elem[0].num_params = 1; add_proto_list.list_elem[0].params[0] = p_cb->data_psm; add_proto_list.list_elem[1].protocol_uuid = UUID_PROTOCOL_MCAP_DATA; add_proto_list.list_elem[1].num_params = 0; result &= SDP_AddAdditionProtoLists(p_cb->sdp_handle, BTA_HL_NUM_ADD_PROTO_LISTS, (tSDP_PROTO_LIST_ELEM *)&add_proto_list); } if (result) { if (p_cb->srv_name[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_SERVICE_NAME, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->srv_name) + 1), (UINT8 *)p_cb->srv_name); } /* end of setting optional service name */ } if (result) { if (p_cb->srv_desp[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_SERVICE_DESCRIPTION, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->srv_desp) + 1), (UINT8 *)p_cb->srv_desp); } /* end of setting optional service description */ } if (result) { if (p_cb->provider_name[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_PROVIDER_NAME, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->provider_name) + 1), (UINT8 *)p_cb->provider_name); } /* end of setting optional provider name */ } /* add supported feture list */ if (result) { cnt=0; for (i=1; i<= p_cb->sup_feature.num_of_mdeps; i++) { mdep_id = (UINT8)p_cb->sup_feature.mdep[i].mdep_id; mdep_role = (UINT8)p_cb->sup_feature.mdep[i].mdep_cfg.mdep_role; for (j=0; j<p_cb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types; j++) { sup_feature_list.list_elem[cnt].mdep_id = mdep_id; sup_feature_list.list_elem[cnt].mdep_role = mdep_role; sup_feature_list.list_elem[cnt].data_type = p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].data_type; if (p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp[0] != '\0') { sup_feature_list.list_elem[cnt].p_mdep_desp = p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp; } else { sup_feature_list.list_elem[cnt].p_mdep_desp = NULL; } cnt++; if (cnt==BTA_HL_NUM_SUP_FEATURE_ELEMS) { result = FALSE; break; } } } sup_feature_list.num_elems = cnt; result &= bta_hl_add_sup_feature_list (p_cb->sdp_handle, sup_feature_list.num_elems, sup_feature_list.list_elem); } if (result) { result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_DATA_EXCH_SPEC, UINT_DESC_TYPE, (UINT32)1, (UINT8*)&data_exchange_spec); } if (result) { result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_MCAP_SUP_PROC, UINT_DESC_TYPE, (UINT32)1, (UINT8*)&mcap_sup_proc); } if (result) { result &= SDP_AddUuidSequence(p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); } if (result) { for(i=0; i < num_services; i++) { bta_sys_add_uuid(svc_class_id_list[i]); APPL_TRACE_DEBUG("dbg bta_sys_add_uuid i=%d uuid=0x%x", i, svc_class_id_list[i]); //todo } } else { if (p_cb->sdp_handle) { SDP_DeleteRecord(p_cb->sdp_handle); p_cb->sdp_handle = 0; } status = BTA_HL_STATUS_SDP_FAIL; } #if BTA_HL_DEBUG == TRUE APPL_TRACE_DEBUG("bta_hl_sdp_register status=%s", bta_hl_status_code(status)); #endif return status; }
/*********************************************************************** * * FUNCTION NAME: OBEX_RegisterSyncServer * DESCRIPTION: This function will send a PUSH command to the IrMC Client * KNOWN ISSUES: none. * * ***********************************************************************/ APIDECL1 t_api APIDECL2 OBEX_RegisterSyncServer(u_int8 channel, u_int8 supported_types) { u_int32 handle; u_int16 _16bit; u_int8 _8bit; t_SDP_serviceRecord *pRecord; t_SDP_dataElement e1,e2,e3,e4,e5; t_SDP_dataElement* list[4]; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ _16bit = SDP_SCLASS_UUID_IRMC_SYNC; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); SDP_AddAttribute(pRecord,SDP_AID_SERVICE_CLASS,&e3); /* protocol descriptor list */ _16bit = SDP_PROTOCOL_UUID_L2CAP; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); _16bit = SDP_PROTOCOL_UUID_RFCOMM; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); _8bit = channel; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3); list[0] = &e1; list[1] = &e3; SDP_CreateList(SDP_SEQUENCE,2,list,&e4); _16bit = SDP_PROTOCOL_UUID_OBEX; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); list[0] = &e2; list[1] = &e4; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e1); SDP_AddAttribute(pRecord,SDP_AID_PROTOCOL,&e1); /* profile - list */ _16bit = SDP_SCLASS_UUID_IRMC_SYNC; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,(u_int8*)&_16bit,&e2); list[0] = &e1; list[1] = &e2; SDP_CreateList(SDP_SEQUENCE,2,list,&e3); list[0] = &e3; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); SDP_AddAttribute(pRecord,SDP_AID_PROFILE_LIST,&e2); /* service name */ SDP_EncodeAttribute(SDP_TEXT,20,(u_int8 *)"IrMC Synchronisation",&e1); SDP_AddAttribute(pRecord,0x0100,&e1); /* supported formats */ _16bit = 0; if(supported_types & 0x01) { _8bit = 1; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e1); list[_16bit++] = &e1; } if(supported_types & 0x02) { _8bit = 3; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e2); list[_16bit++] = &e2; } if(supported_types & 0x04) { _8bit = 5; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3); list[_16bit++] = &e3; } if(supported_types & 0x08) { _8bit = 6; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e4); list[_16bit++] = &e4; } SDP_CreateList(SDP_SEQUENCE,_16bit,list,&e5); SDP_AddAttribute(pRecord,SDP_AID_DATA_STORES,&e5); _16bit = SDP_SCLASS_UUID_PUBLIC; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); SDP_AddAttribute(pRecord,SDP_AID_BROWSE_LIST,&e3); return BT_NOERROR; }
void sample_setup(int rfcomm_chan) { u_int8 channel; u_int32 handle; u_int16 serial_uuid,l2cap_uuid,rfcomm_uuid,language_id,language_encoding,language_base; t_SDP_serviceRecord *pRecord; t_SDP_dataElement SerialPortUUID,ServiceClassList,L2CAP_UUID,Protocol0,RFCOMM_UUID,RFCOMM_CHANNEL,Protocol1; t_SDP_dataElement ProtocolDescriptorList,Serial_Name,Lang_id,Lang_Enc,Lang_base,Lang_list_1,Lang_base_list; t_SDP_dataElement* list[10]; char* Service_name = "Serial_user_a"; handle = 16; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ serial_uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&serial_uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* protocol descriptor list */ /* construct the l2cap protocol entry */ l2cap_uuid = 0x0100; SDP_EncodeAttribute(SDP_UUID,2,&l2cap_uuid,&L2CAP_UUID); /* place l2cap uuid in a list */ list[0] = &L2CAP_UUID; SDP_CreateList(SDP_SEQUENCE,1,list,&Protocol0); /* construct the rfcomm entry */ rfcomm_uuid = 0x0003; SDP_EncodeAttribute(SDP_UUID,2,&rfcomm_uuid,&RFCOMM_UUID); channel = rfcomm_chan; /* setting of the RFCOMM channel number */ SDP_EncodeAttribute(SDP_UINT,1,&channel,&RFCOMM_CHANNEL); /* place rfcomm uuid and chanel number in a list */ list[0] = &RFCOMM_UUID; list[1] = &RFCOMM_CHANNEL; SDP_CreateList(SDP_SEQUENCE,2,list,&Protocol1); /* place protocol 0 and protocol 1 in a list */ list[0] = &Protocol0; list[1] = &Protocol1; SDP_CreateList(SDP_SEQUENCE,2,list,&ProtocolDescriptorList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0004,&ProtocolDescriptorList); /* language base list */ /* language identifier english */ language_id = ('e' << 8) + 'n'; SDP_EncodeAttribute(SDP_UINT,2,&language_id,&Lang_id); /* language encoding utf-8 */ language_encoding = 106; SDP_EncodeAttribute(SDP_UINT,2,&language_encoding,&Lang_Enc); /* language base */ language_base = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,&language_base,&Lang_base); /* place the entries in a list */ list[0] = &Lang_id; list[1] = &Lang_Enc; list[2] = &Lang_base; SDP_CreateList(SDP_SEQUENCE,3,list,&Lang_list_1); /* add this to the main list */ list[0] = &Lang_list_1; SDP_CreateList(SDP_SEQUENCE,1,list,&Lang_base_list); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0006,&Lang_base_list); /* service name */ SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,language_base + 0,&Serial_Name); }
/*********************************************************************** * * FUNCTION NAME: OBEX_RegisterFTPServer * DESCRIPTION: This function will send a PUSH command to the IrMC Client * KNOWN ISSUES: none. * * ***********************************************************************/ APIDECL1 t_api APIDECL2 OBEX_RegisterFTPServer(u_int8 channel) { u_int32 handle; u_int16 _16bit; u_int8 _8bit; t_SDP_serviceRecord *pRecord; t_SDP_dataElement e1,e2,e3,e4; t_SDP_dataElement* list[3]; if(!channel) return BT_INVALIDPARAM; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ _16bit = SDP_SCLASS_UUID_OBEX_FTP; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); SDP_AddAttribute(pRecord,SDP_AID_SERVICE_CLASS,&e3); /* protocol descriptor list */ _16bit = SDP_PROTOCOL_UUID_L2CAP; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); _16bit = SDP_PROTOCOL_UUID_RFCOMM; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); _8bit = channel; SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3); list[0] = &e1; list[1] = &e3; SDP_CreateList(SDP_SEQUENCE,2,list,&e4); _16bit = SDP_PROTOCOL_UUID_OBEX; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); list[0] = &e2; list[1] = &e4; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e1); SDP_AddAttribute(pRecord,SDP_AID_PROTOCOL,&e1); /* profile - list */ _16bit = SDP_SCLASS_UUID_OBEX_FTP; SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,(u_int8*)&_16bit,&e2); list[0] = &e1; list[1] = &e2; SDP_CreateList(SDP_SEQUENCE,2,list,&e3); list[0] = &e3; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); SDP_AddAttribute(pRecord,SDP_AID_PROFILE_LIST,&e2); /* service name */ SDP_EncodeAttribute(SDP_TEXT,18,(u_int8 *)"OBEX File Transfer",&e1); SDP_AddAttribute(pRecord,0x0100,&e1); return BT_NOERROR; }
/****************************************************************************** ** ** Function bta_hf_client_add_record ** ** Description This function is called by a server application to add ** HFP Client information to an SDP record. Prior to ** calling this function the application must call ** SDP_CreateRecord() to create an SDP record. ** ** Returns TRUE if function execution succeeded, ** FALSE if function execution failed. ** ******************************************************************************/ BOOLEAN bta_hf_client_add_record(char *p_service_name, UINT8 scn, tBTA_HF_CLIENT_FEAT features, UINT32 sdp_handle) { tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HF_CLIENT_NUM_PROTO_ELEMS]; UINT16 svc_class_id_list[BTA_HF_CLIENT_NUM_SVC_ELEMS]; UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; UINT16 version; UINT16 profile_uuid; BOOLEAN result = TRUE; UINT8 buf[2]; UINT16 sdp_features = 0; APPL_TRACE_DEBUG("bta_hf_client_add_record"); memset( proto_elem_list, 0 , BTA_HF_CLIENT_NUM_PROTO_ELEMS * sizeof(tSDP_PROTOCOL_ELEM)); /* add the protocol element sequence */ proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; proto_elem_list[0].num_params = 0; proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM; proto_elem_list[1].num_params = 1; proto_elem_list[1].params[0] = scn; result &= SDP_AddProtocolList(sdp_handle, BTA_HF_CLIENT_NUM_PROTO_ELEMS, proto_elem_list); /* add service class id list */ svc_class_id_list[0] = UUID_SERVCLASS_HF_HANDSFREE; svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO; result &= SDP_AddServiceClassIdList(sdp_handle, BTA_HF_CLIENT_NUM_SVC_ELEMS, svc_class_id_list); /* add profile descriptor list */ profile_uuid = UUID_SERVCLASS_HF_HANDSFREE; version = HFP_VERSION_1_6; result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version); /* add service name */ if (p_service_name != NULL && p_service_name[0] != 0) { result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name); } /* add features */ if (features & BTA_HF_CLIENT_FEAT_ECNR) { sdp_features |= BTA_HF_CLIENT_FEAT_ECNR; } if (features & BTA_HF_CLIENT_FEAT_3WAY) { sdp_features |= BTA_HF_CLIENT_FEAT_3WAY; } if (features & BTA_HF_CLIENT_FEAT_CLI) { sdp_features |= BTA_HF_CLIENT_FEAT_CLI; } if (features & BTA_HF_CLIENT_FEAT_VREC) { sdp_features |= BTA_HF_CLIENT_FEAT_VREC; } if (features & BTA_HF_CLIENT_FEAT_VOL) { sdp_features |= BTA_HF_CLIENT_FEAT_VOL; } /* Codec bit position is different in SDP (bit 5) and in BRSF (bit 7) */ if (features & BTA_HF_CLIENT_FEAT_CODEC) { sdp_features |= 0x0020; } UINT16_TO_BE_FIELD(buf, sdp_features); result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, 2, buf); /* add browse group list */ result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); return result; }
void create_browse_tree(void) { /* see page 339 of spec. */ u_int32 handle; u_int16 uuid; t_SDP_serviceRecord *pRecord; t_SDP_dataElement SerialPortUUID,BrowseGroupList,ServiceClassList,BGL1; t_SDP_dataElement Serial_Name; t_SDP_dataElement* list[10]; char* Service_name[20]; strcpy(Service_name,"Entertainment"); handle = 200; handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1001; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0x1002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"News"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1001; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0x1002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ uuid = 0xe002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Reference"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1001; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0x1002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ uuid = 0xe003; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Games"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1001; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ uuid = 0xe004; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Movies"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1001; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ uuid = 0xe005; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Starcraft"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe004; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"A Bug's Life"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe005; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Dictionary"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe003; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Encyclopedia"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe003; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"New York Times"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"Limerick Post"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); strcpy(Service_name,"London Times"); handle++; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ uuid = 0x1101; /* serial port uuid */ SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID); /* place the uuid in a list */ list[0] = &SerialPortUUID; SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0001,&ServiceClassList); /* browse group list */ uuid = 0xe002; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); /* uuid = 0x1001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); */ list[0] = &BGL1; SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList); SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList); /* browse group descriptor */ /* uuid = 0xe001; SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1); SDP_AddAttribute(pRecord,0x0200,&BGL1); */ /* service name */ SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name); /* add this as an attribute to the service record */ SDP_AddAttribute(pRecord,0x0100,&Serial_Name); }
void upf_3_obex(void) { u_int32 handle; u_int16 _16bit; u_int8 _8bit; t_SDP_serviceRecord *pRecord; t_SDP_dataElement e1,e2,e3,e4; t_SDP_dataElement* list[10]; char Service_name[] = "OBEX Object Push"; handle = 0x00010002; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ _16bit = 0x1105; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); SDP_AddAttribute(pRecord,0x0001,&e3); /* protocol descriptor list */ _16bit = 0x0100; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); _16bit = 0x0003; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); _8bit = 0x01; SDP_EncodeAttribute(SDP_UINT,1,&_16bit,&e3); list[0] = &e1; list[1] = &e3; SDP_CreateList(SDP_SEQUENCE,2,list,&e4); _16bit = 0x0008; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); list[0] = &e2; list[1] = &e4; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e1); SDP_AddAttribute(pRecord,0x0004,&e1); /* browse group */ _16bit = 0x1002; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); SDP_AddAttribute(pRecord,0x0005,&e2); /* language base */ _16bit = ('e' << 8) + 'n'; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e1); _16bit = 106; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e3); list[0] = &e1; list[1] = &e2; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e4); SDP_AddAttribute(pRecord,0x0006,&e4); /* profile - list */ _16bit = 0x1105; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2); list[0] = &e1; list[1] = &e2; SDP_CreateList(SDP_SEQUENCE,2,list,&e3); list[0] = &e3; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); SDP_AddAttribute(pRecord,0x0009,&e2); /* service name */ SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name) -1,Service_name,&e1); SDP_AddAttribute(pRecord,0x0100,&e1); }
void test_db_api_sample_4(void) { u_int32 handle; u_int16 _16bit; u_int8 _8bit; t_SDP_serviceRecord *pRecord; t_SDP_dataElement e1,e2,e3,e4; t_SDP_dataElement* list[10]; char Service_name[] = "A sample database"; handle = 0x00010002; /* Create a Service Record */ SDP_CreateRecord(&handle,&pRecord); /* service class list */ _16bit = 0x2323; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); SDP_AddAttribute(pRecord,0x0001,&e3); /* protocol descriptor list */ _16bit = 0x0100; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); _16bit = 0x0003; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); _8bit = 0x01; SDP_EncodeAttribute(SDP_UINT,1,&_16bit,&e3); list[0] = &e1; list[1] = &e3; SDP_CreateList(SDP_SEQUENCE,2,list,&e4); _16bit = 0x0008; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e3); list[0] = &e2; list[1] = &e4; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e1); SDP_AddAttribute(pRecord,0x0004,&e1); /* browse group */ _16bit = 0x1002; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); list[0] = &e1; SDP_CreateList(SDP_SEQUENCE,1,list,&e2); SDP_AddAttribute(pRecord,0x0005,&e2); /* language base */ _16bit = ('e' << 8) + 'n'; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e1); _16bit = 106; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e3); list[0] = &e1; list[1] = &e2; list[2] = &e3; SDP_CreateList(SDP_SEQUENCE,3,list,&e4); SDP_AddAttribute(pRecord,0x0006,&e4); /* profile - list */ _16bit = 0x1105; SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1); _16bit = 0x0100; SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2); list[0] = &e1; list[1] = &e2; SDP_CreateList(SDP_SEQUENCE,2,list,&e3); SDP_AddAttribute(pRecord,0x0009,&e3); /* service name */ SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name) -1,Service_name,&e1); SDP_AddAttribute(pRecord,0x0100,&e1); handle = 0; /* now to get the next one from the list */ SDP_GetNextRecord(0x00010002,&handle); }
/****************************************************************************** ** ** Function bta_ag_add_record ** ** Description This function is called by a server application to add ** HSP or HFP information to an SDP record. Prior to ** calling this function the application must call ** SDP_CreateRecord() to create an SDP record. ** ** Returns TRUE if function execution succeeded, ** FALSE if function execution failed. ** ******************************************************************************/ BOOLEAN bta_ag_add_record(UINT16 service_uuid, char *p_service_name, UINT8 scn, tBTA_AG_FEAT features, UINT32 sdp_handle) { tSDP_PROTOCOL_ELEM proto_elem_list[BTA_AG_NUM_PROTO_ELEMS]; UINT16 svc_class_id_list[BTA_AG_NUM_SVC_ELEMS]; UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; UINT16 version; UINT16 profile_uuid; UINT8 network; BOOLEAN result = TRUE; BOOLEAN codec_supported = FALSE; UINT8 buf[2]; APPL_TRACE_DEBUG1("bta_ag_add_record uuid: %x", service_uuid); memset( proto_elem_list, 0 , BTA_AG_NUM_PROTO_ELEMS*sizeof(tSDP_PROTOCOL_ELEM)); /* add the protocol element sequence */ proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; proto_elem_list[0].num_params = 0; proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM; proto_elem_list[1].num_params = 1; proto_elem_list[1].params[0] = scn; result &= SDP_AddProtocolList(sdp_handle, BTA_AG_NUM_PROTO_ELEMS, proto_elem_list); /* add service class id list */ svc_class_id_list[0] = service_uuid; svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO; result &= SDP_AddServiceClassIdList(sdp_handle, BTA_AG_NUM_SVC_ELEMS, svc_class_id_list); /* add profile descriptor list */ if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) { profile_uuid = UUID_SERVCLASS_HF_HANDSFREE; version = HFP_VERSION_1_6; } else { profile_uuid = UUID_SERVCLASS_HEADSET; version = HSP_VERSION_1_2; } result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version); /* add service name */ if (p_service_name != NULL && p_service_name[0] != 0) { result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_service_name)+1), (UINT8 *) p_service_name); } /* add features and network */ if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) { network = (features & BTA_AG_FEAT_REJECT) ? 1 : 0; result &= SDP_AddAttribute(sdp_handle, ATTR_ID_DATA_STORES_OR_NETWORK, UINT_DESC_TYPE, 1, &network); if (features & BTA_AG_FEAT_CODEC) codec_supported = TRUE; features &= BTA_AG_SDP_FEAT_SPEC; /* Codec bit position is different in SDP and in BRSF */ if (codec_supported) features |= 0x0020; UINT16_TO_BE_FIELD(buf, features); result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, 2, buf); } /* add browse group list */ result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); return result; }
/******************************************************************************* ** ** Function pan_register_with_sdp ** ** Description ** ** Returns ** *******************************************************************************/ UINT32 pan_register_with_sdp (UINT16 uuid, UINT8 sec_mask, char *p_name, char *p_desc) { UINT32 sdp_handle; UINT16 browse_list = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP; UINT16 security = 0; UINT8 availability; UINT32 proto_len = (UINT32)pan_proto_elem_data[1]; /* Create a record */ sdp_handle = SDP_CreateRecord (); if (sdp_handle == 0) { PAN_TRACE_ERROR0 ("PAN_SetRole - could not create SDP record"); return 0; } /* Service Class ID List */ SDP_AddServiceClassIdList (sdp_handle, 1, &uuid); /* Add protocol element sequence from the constant string */ SDP_AddAttribute (sdp_handle, ATTR_ID_PROTOCOL_DESC_LIST, DATA_ELE_SEQ_DESC_TYPE, proto_len, (UINT8 *)(pan_proto_elem_data+2)); // btla-specific ++ #if 0 availability = 0xFF; SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_AVAILABILITY, UINT_DESC_TYPE, 1, &availability); #endif // btla-specific -- /* Language base */ SDP_AddLanguageBaseAttrIDList (sdp_handle, LANG_ID_CODE_ENGLISH, LANG_ID_CHAR_ENCODE_UTF8, LANGUAGE_BASE_ID); /* Profile descriptor list */ SDP_AddProfileDescriptorList (sdp_handle, uuid, PAN_PROFILE_VERSION); /* Service Name */ SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE, (UINT8) (strlen(p_name) + 1), (UINT8 *)p_name); /* Service description */ SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_DESCRIPTION, TEXT_STR_DESC_TYPE, (UINT8) (strlen(p_desc) + 1), (UINT8 *)p_desc); /* Security description */ if (sec_mask) { UINT16_TO_BE_FIELD(&security, 0x0001); } SDP_AddAttribute (sdp_handle, ATTR_ID_SECURITY_DESCRIPTION, UINT_DESC_TYPE, 2, (UINT8 *)&security); #if (defined (PAN_SUPPORTS_ROLE_NAP) && PAN_SUPPORTS_ROLE_NAP == TRUE) if (uuid == UUID_SERVCLASS_NAP) { UINT16 NetAccessType = 0x0005; /* Ethernet */ UINT32 NetAccessRate = 0x0001312D0; /* 10Mb/sec */ UINT8 array[10], *p; /* Net access type. */ p = array; UINT16_TO_BE_STREAM (p, NetAccessType); SDP_AddAttribute (sdp_handle, ATTR_ID_NET_ACCESS_TYPE, UINT_DESC_TYPE, 2, array); /* Net access rate. */ p = array; UINT32_TO_BE_STREAM (p, NetAccessRate); SDP_AddAttribute (sdp_handle, ATTR_ID_MAX_NET_ACCESS_RATE, UINT_DESC_TYPE, 4, array); /* Register with Security Manager for the specific security level */ if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_NAP, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_NAP)) || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_NAP, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_NAP))) { PAN_TRACE_ERROR0 ("PAN Security Registration failed for PANU"); } } #endif #if (defined (PAN_SUPPORTS_ROLE_GN) && PAN_SUPPORTS_ROLE_GN == TRUE) if (uuid == UUID_SERVCLASS_GN) { if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_GN, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_GN)) || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_GN, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_GN))) { PAN_TRACE_ERROR0 ("PAN Security Registration failed for GN"); } } #endif #if (defined (PAN_SUPPORTS_ROLE_PANU) && PAN_SUPPORTS_ROLE_PANU == TRUE) if (uuid == UUID_SERVCLASS_PANU) { if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_PANU, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_PANU)) || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_PANU, sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_PANU))) { PAN_TRACE_ERROR0 ("PAN Security Registration failed for PANU"); } } #endif /* Make the service browsable */ SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse_list); return sdp_handle; }