protected override void AddCustomServiceRecord(ref ServiceRecord fullServiceRecord, int livePort) { var livePort16 = checked ((UInt16)livePort); ServiceRecordHelper.SetL2CapPsmNumber(fullServiceRecord, livePort16); m_sdpService = SdpService.CreateCustom(fullServiceRecord, m_factory); }
public static ISdpService CreateCustom(ServiceRecord record, WidcommBluetoothFactoryBase factory) { ISdpService sdpService = factory.GetWidcommSdpService(); WidcommSdpServiceCreator creator = new WidcommSdpServiceCreator(); creator.CreateServiceRecord(record, sdpService); return(sdpService); }
protected override void AddCustomServiceRecord(ref ServiceRecord fullServiceRecord, int livePort) { var livePortB = checked ((byte)livePort); ServiceRecordHelper.SetRfcommChannelNumber(fullServiceRecord, livePortB); m_sdpService = SdpService.CreateCustom(fullServiceRecord, m_factory); }
public void TestCreateAVariousRecord() { ServiceRecord record = CreateAVariousRecord(); #if false TestWcLsnrBluetoothFactory f = new TestWcLsnrBluetoothFactory(); BluetoothFactory.SetFactory(f); //---- int port = 19; ServiceRecordHelper.SetRfcommChannelNumber(record, port); // ISdpService x0 = SdpService.CreateCustom(record); TestSdpService2 x = (TestSdpService2)x0; #endif TestWcLsnrBluetoothFactory f = new TestWcLsnrBluetoothFactory(); TestLsnrRfCommIf commIf = new TestLsnrRfCommIf(); f.queueIRfCommIf.Enqueue(commIf); TestLsnrRfcommPort port0 = new TestLsnrRfcommPort(); f.queueIRfCommPort.Enqueue(port0); BluetoothFactory.SetFactory(f); // port0.SetOpenServerResult(PORT_RETURN_CODE.SUCCESS); BluetoothListener lsnr = new BluetoothListener(BluetoothService.VideoSource, record); lsnr.Start(); int port = lsnr.LocalEndPoint.Port; lsnr.Stop(); // TestSdpService2 x = f.GetTestSdpService(); x.AssertCalls( // Well-known "AddServiceClassIdList: <00001400-0000-1000-8000-00805f9b34fb>" + NewLine + "AddRFCommProtocolDescriptor: " + port + NewLine // Eeeeeeech, how to detect all possible LangOffset_WellKnown strings!!!! + "AddAttribute: id: 0x0006, dt: DATA_ELE_SEQ, len: 9, val: " + "09-65-6E-" + "09-00-6A-" + "09-01-00" + NewLine + "AddAttribute: id: 0x0100, dt: TEXT_STR, len: 4, val: 61-6C-61-6E" + NewLine + "AddAttribute: id: 0x0401, dt: DATA_ELE_ALT, len: 66, val: " + "35-2F-35-2D-25-0C-61-62-63-64-C3-A9-66-67-68-C4-" + "AD-6A-45-1A-68-74-74-70-3A-2F-2F-65-78-61-6D-70-" + "6C-65-2E-63-6F-6D-2F-66-6F-6F-2E-74-78-74-09-FE-" + "12-25-0C-61-62-63-64-C3-A9-66-67-68-C4-AD-6A-09-" + "12-34" + NewLine + "AddAttribute: id: 0x4015, dt: UINT, len: 1, val: 15" + NewLine + "AddAttribute: id: 0x4016, dt: UINT, len: 2, val: 00-16" + NewLine + "AddAttribute: id: 0x4017, dt: UINT, len: 4, val: 00-00-00-17" + NewLine + "AddAttribute: id: 0x401E, dt: TWO_COMP_INT, len: 1, val: 1E" + NewLine + "AddAttribute: id: 0x401F, dt: TWO_COMP_INT, len: 2, val: 00-1F" + NewLine + "AddAttribute: id: 0x4020, dt: TWO_COMP_INT, len: 4, val: 00-00-00-20" + NewLine + "AddAttribute: id: 0x4028, dt: UUID, len: 2, val: 00-28" + NewLine + "AddAttribute: id: 0x4029, dt: UUID, len: 4, val: 00-00-00-29" + NewLine + "AddAttribute: id: 0x402A, dt: UUID, len: 16, val: 00-00-00-2A-00-00-10-00-80-00-00-80-5F-9B-34-FB" + NewLine + "AddAttribute: id: 0x402C, dt: BOOLEAN, len: 1, val: 01" + NewLine ); }
//-------------------------- public void CreateServiceRecord(ServiceRecord record, ISdpService sdpService) { if (m_record != null) { throw new InvalidOperationException("One at a time please."); } System.Threading.Interlocked.Exchange(ref m_record, record); try { m_sdpSvc = sdpService; int count = base.CreateServiceRecord(record, s_dummy); } finally { System.Threading.Interlocked.Exchange(ref m_record, null); } }
protected override void AddSimpleServiceRecord(out ServiceRecord fullServiceRecord, int livePort, Guid serviceClass, string serviceName) { var livePortB = checked ((byte)livePort); m_sdpService = SdpService.CreateRfcomm( serviceClass, serviceName, livePortB, m_factory); ServiceRecordBuilder bldrDummy = new ServiceRecordBuilder(); bldrDummy.AddServiceClass(serviceClass); bldrDummy.ServiceName = serviceName; fullServiceRecord = bldrDummy.ServiceRecord; ServiceRecordHelper.SetRfcommChannelNumber(fullServiceRecord, livePortB); }
//-------- bool WriteWellKnownAttribute(ServiceAttribute attr, ISdpService sdpService) //, ServiceRecord record) { switch (attr.Id) { case UniversalAttributeId.ServiceClassIdList: sdpService.AddServiceClassIdList(ServiceRecordHelper_GetServiceClassIdList(attr)); return(true); case UniversalAttributeId.ProtocolDescriptorList: bool? isSimpleRfcomm; ServiceElement el = ServiceRecordHelper.GetChannelElement(attr, BluetoothProtocolDescriptorType.Rfcomm, out isSimpleRfcomm); if (el == null) { return(false); // Non-RFCOMM } int scn = ServiceRecordHelper.GetRfcommChannelNumber(el); const int NotFound = -1; if (scn == NotFound) { Debug.Fail("scn == -1 but non-RFCOMM case should be detected above!!?"); return(false); } else { Debug.Assert(isSimpleRfcomm.HasValue, "isRfcommPlusMore.HasValue"); if (isSimpleRfcomm == true) { sdpService.AddRFCommProtocolDescriptor(checked ((byte)scn)); } else { Debug.Assert(!isSimpleRfcomm.Value, "!isSimpleRfcomm"); // Need more layers (etc)! Could call AddProtocolList() with // three (or more) tSDP_PROTOCOL_ELEM. But just fall // back to raw dumping for now. return(false); } } return(true); default: return(false); } }
//-------- public static ISdpService CreateRfcomm( Guid serviceClass, string serviceName, byte scn, WidcommBluetoothFactoryBase factory) { if (scn < BluetoothEndPoint.MinScn || scn > BluetoothEndPoint.MaxScn) { throw new ArgumentOutOfRangeException("scn" #if !NETCF , scn, null #endif ); } ISdpService sdpService = factory.GetWidcommSdpService(); sdpService.AddServiceClassIdList(serviceClass); sdpService.AddRFCommProtocolDescriptor(scn); if (serviceName != null) { sdpService.AddServiceName(serviceName); } sdpService.CommitRecord(); return(sdpService); }