void AvrcpSdpUtils::CreateServiceRecordL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TBool aTarget, TUint16 aProfileVersion) { if(!aTarget) { // New service record with service class attribute containing // 0x110e (for A/V Remote Control) CSdpAttrValueDES* serviceClassUuids = CSdpAttrValueDES::NewDESL(NULL); CleanupStack::PushL(serviceClassUuids); if(aProfileVersion == AvrcpSdp::KAvrcpProfileVersion13) { serviceClassUuids->StartListL() ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID))) ->EndListL(); } else { serviceClassUuids->StartListL() ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID))) ->BuildUUIDL(TUUID(TUint16(KAVRemoteControlControllerUUID))) ->EndListL(); } aSdpDatabase.CreateServiceRecordL(*serviceClassUuids, aRecHandle); CleanupStack::PopAndDestroy(serviceClassUuids); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, AvrcpSdp::KAvrcpControllerServiceName ); } else { // New service record with service class attribute containing // 0x110c (for A/V Remote Control Target) aSdpDatabase.CreateServiceRecordL(KAVRemoteControlTargetUUID, aRecHandle); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, AvrcpSdp::KAvrcpTargetServiceName ); } aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetProviderName, AvrcpSdp::KAvrcpProviderName ); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription, AvrcpSdp::KAvrcpServiceDescription ); }
void AvrcpSdpUtils::UpdateBrowseListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle) { CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildUUIDL(TUUID(TUint16(KPublicBrowseGroupUUID))) // Public browse group ->EndListL(); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES); CleanupStack::PopAndDestroy(attrValDES); }
void AvrcpSdpUtils::UpdateProfileDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProfileVersion) { CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildDESL()->StartListL() //In the profile descriptor list the Control UUID is used //for BOTH controller and target ->BuildUUIDL(KAVRemoteControlUUID) ->BuildUintL(TSdpIntBuf<TUint16>(aProfileVersion)) ->EndListL() ->EndListL(); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBluetoothProfileDescriptorList, *attrValDES); CleanupStack::PopAndDestroy(attrValDES); }
void AvrcpSdpUtils::UpdateAdditionalProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle) { CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildDESL()->StartListL() ->BuildUUIDL(TUUID(TUint16(KL2CAP))) // L2CAP ->BuildUintL(TSdpIntBuf<TUint16>(0x1b)) // PSM = AVCTP_browse ->EndListL() ->BuildDESL()->StartListL() ->BuildUUIDL(TUUID(TUint16(KAVCTP))) // AVCTP ->BuildUintL(TSdpIntBuf<TUint16>(AvrcpSdp::KAvctpProtocolVersion13))// 0x0103 ->EndListL() ->EndListL(); aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdAdditionalProtocolDescriptorList, *attrValDES); CleanupStack::PopAndDestroy(attrValDES); }
// ---------------------------------------------------------------------------- // QBtServiceAdvertiserPrivate::StartAdvertiser(const QBtService& service) // // start service advertiser on given channel. an entry to service discovery // database will be entered describing our advertised service. // ---------------------------------------------------------------------------- void QBtServiceAdvertiserPrivate::StartAdvertiser (const QBtService& service) { //localService = new QBtService(service); // open sdp session User::LeaveIfError(iSdp.Connect()); // open sdp database session User::LeaveIfError(iSdpDB.Open(iSdp)); // create a record of the correct service class //QBtUuid uuid = service.getClass(); TUUID uuid = QBtUuidToSymbianUuid (service.getClass() ); iSdpDB.CreateServiceRecordL (uuid, iRecord); // add a protocol to the record CSdpAttrValueDES* protocolDescriptorList = CSdpAttrValueDES::NewDESL(NULL); CleanupStack::PushL(protocolDescriptorList); TBuf8<1> channel; channel.Append((TChar)service.getPort()); // create protocol list for our service MSdpElementBuilder* e = protocolDescriptorList->StartListL(); QBtService::ProtocolList protocolList = service.getProtocols(); for (int i=0; i < protocolList.size(); i++) { e = e->BuildDESL(); e = e->StartListL(); TUUID u = QBtUuidToSymbianUuid (protocolList[i]); e = e->BuildUUIDL (u); if (u == TUUID (KRFCOMM) ) e = e->BuildUintL(channel); e = e->EndListL(); } e->EndListL(); // set protocol list to the record iSdpDB.UpdateAttributeL(iRecord, KSdpAttrIdProtocolDescriptorList, *protocolDescriptorList); CleanupStack::PopAndDestroy(protocolDescriptorList); // add a name to the record TPtrC16 servName(service.getName().utf16()); iSdpDB.UpdateAttributeL(iRecord, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, servName); // add a description to the record TPtrC16 servDescr(service.getDescription().utf16()); iSdpDB.UpdateAttributeL(iRecord, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription, servDescr); // set service available UpdateAvailability(ETrue); // notify QT_TRYCATCH_LEAVING (emit p_ptr->advertisingStarted(service) ); }
//Register it in the SDP database - determine attribs, construct the record and then add attribs to new record TInt CStatTransportBT::RegWithSDPDatabaseL( void ) { asserte( iBTTransportStatus == EConnectingRegisterMgr ); //Connect and open to the session and the DB //User::LeaveIfError( iSdpSession.Connect() ); TInt ret2; ret2 = iSdpSession.Connect(); if(ret2!=KErrNone) { User::Leave(ret2); } User::LeaveIfError( iSdpDatabaseSession.Open( iSdpSession ) ); TBuf8<STANDARDBUFVALUE> value1; TBuf8<STANDARDBUFVALUE> value2; CSdpAttrValue* attrVal = 0; CSdpAttrValueDES* attrValDES = 0; //initialise value1.FillZ(STANDARDBUFVALUE); value2.FillZ(STANDARDBUFVALUE); // Set Attr 1 (service class list) to list with UUID = 0x1101 (serial port) iSdpDatabaseSession.CreateServiceRecordL(TUUID(0x1101), iRecHandle); // Set Service name iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, _L("STATAPI") ); // Set Service description iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription, _L("Symbian Test Automation Tool using Serial BT") ); attrVal = CSdpAttrValueString::NewStringL( _L8( "Test Solutions Dept Symbian Ltd." ) ); CleanupStack::PushL(attrVal); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetProviderName, *attrVal); CleanupStack::PopAndDestroy(); //attrVal attrVal = 0; // Set Attr 2 (service record state) to 0 attrVal = CSdpAttrValueUint::NewUintL(value1); CleanupStack::PushL(attrVal); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceRecordState, *attrVal); CleanupStack::PopAndDestroy(); //attrVal attrVal = 0; // Set attr 4 (protocol list) to RFCOMM //initialise TBuf8<1> serverChannel; serverChannel.FillZ(1); serverChannel[0] = (unsigned char)iPort; attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildDESL()->StartListL() ->BuildUUIDL( TUUID( TUint16( 0x0003 ) ) ) // RFCOMM ->BuildUintL( serverChannel ) //Channel ID = 3 (listening port) ->EndListL() ->EndListL(); //update attr 4 iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES); CleanupStack::PopAndDestroy(); //attrValDES attrValDES = 0; // Set Attr 5 (browse group list) to list with one UUID // 0x1101 (serial port class) // this should be updated with other service classes when other services are added. attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildUUIDL( TUUID( 0x1002 ) ) ->EndListL(); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES); CleanupStack::PopAndDestroy(); attrValDES = 0; // Set Attr 0x006 (language base) value1.FillZ(4); value1[2] = 0x65; value1[3] = 0x6e; TBuf8<STANDARDBUFVALUE> val2; TBuf8<STANDARDBUFVALUE> val3; val2.FillZ(STANDARDBUFVALUE); val3.FillZ(STANDARDBUFVALUE); val2[3] = 0x6a; val3[2] = 0x01; attrValDES = CSdpAttrValueDES::NewDESL(0); CleanupStack::PushL(attrValDES); attrValDES->StartListL() ->BuildUintL( value1 ) // speka de english ->BuildUintL( val2 ) // UTF-8 ->BuildUintL( val3 ) // language base ->EndListL(); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdLanguageBaseAttributeIDList, *attrValDES); CleanupStack::PopAndDestroy(); attrValDES = 0; // Set Attr 0x007 (time to live) to 600 (0x258) seconds (10 minutes) //initialise buffer value1.FillZ(4); value1[2]=2; value1[3]=0x58; attrVal = CSdpAttrValueUint::NewUintL( value1 ); CleanupStack::PushL( attrVal ); iSdpDatabaseSession.UpdateAttributeL( iRecHandle, KSdpAttrIdServiceInfoTimeToLive, *attrVal ); CleanupStack::PopAndDestroy(); //attrVal attrVal = 0; //Set Attr 0x08 (availability) to 0xff - fully available - not in use //initialise TBuf8<1> val4; val4.FillZ(1); val4[0]=0xff; attrVal = CSdpAttrValueUint::NewUintL(val4); CleanupStack::PushL(attrVal); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdServiceAvailability, *attrVal); CleanupStack::PopAndDestroy(); //attrVal attrVal = 0; //Set Attr 0x201 (service database state) to 0 //initialise value1.FillZ(4); attrVal = CSdpAttrValueUint::NewUintL(value1); CleanupStack::PushL(attrVal); iSdpDatabaseSession.UpdateAttributeL(iRecHandle, KSdpAttrIdSdpServerServiceDatabaseState, *attrVal); CleanupStack::PopAndDestroy(); //attrVal attrVal = 0; return KSTErrSuccess; }