private void DoTest(string expectedDump, ServiceRecordBuilder bldr) { ServiceRecord rcd = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(rcd); Assert.AreEqual(expectedDump, dump); }
internal static void DoTestSmart_RecordStaticMethod(String expected, byte[] recordBytes, params Type[] attributeIdEnumDefiningTypes) { ServiceRecord record = ServiceRecord.CreateServiceRecordFromBytes(recordBytes); // string result = ServiceRecordUtilities.Dump(record, attributeIdEnumDefiningTypes); Assert.AreEqual(expected, result); }
public void L2capOne() { String url = "btl2cap://localhost:3B9FA89520078C303355AAA694238F08"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.FooL2CapOne, dump); }
public void L2capTwoWithName() { String url = "btl2cap://localhost:12af51a9030c4b2937407f8c9ecb238a;name=Aserv"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.FooL2CapTwoWithName, dump); }
public void RfcommOneNameSurrounded() { String url = "btspp://localhost:102030405060708090A1B1C1D1D1E100;auth=false;name=SPPEx;encrypt=false"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.FooRfcommOne, dump); }
public void GeopOne() { String url = "btgoep://localhost:12AF51A9030C4B2937407F8C9ECB238A"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.FooGoepOne, dump); }
public void One() { String url = "btspp://localhost:0000110100001000800000805F9B34FB"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.One, dump); }
public void FancyNameFollowed() { String url = "btspp://localhost:102030405060708090A1B1C1D1D1E100" + ";name=aa-bb_cc dd1234;encrypt=false"; ServiceRecordBuilder bldr = ServiceRecordBuilder.FromJsr82ServerUri(url); ServiceRecord record = bldr.ServiceRecord; String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ServiceRecordBuilderTests_Data.FooRfcommOneWithFancyName, dump); }
internal static void DoTestRaw(String expected, byte[] recordBytes) { ServiceRecordParser parser = new ServiceRecordParser(); parser.SkipUnhandledElementTypes = true; ServiceRecord record = parser.Parse(recordBytes); // string result = ServiceRecordUtilities.DumpRaw(record); Assert.AreEqual(expected, result); }
internal static void DoTestSmart_NotSkip(String expected, byte[] recordBytes, params Type[] attributeIdEnumDefiningTypes) { ServiceRecordParser parser = new ServiceRecordParser(); parser.SkipUnhandledElementTypes = false; ServiceRecord record = parser.Parse(recordBytes); // string result = ServiceRecordUtilities.Dump(record, attributeIdEnumDefiningTypes); Assert.AreEqual(expected, result); }
public void SonyEricsson_Hid_Record() { // This should the normal test of binary record to dump, but we don't have the binary... ServiceRecord rcd = Data_CompleteThirdPartyRecords.SonyEricsson_Hid_Record; String expectedDump = Data_CompleteThirdPartyRecords.SonyEricsson_Hid_Record_Dump; String dump = ServiceRecordUtilities.Dump(rcd); Assert.AreEqual(expectedDump, dump, "dump"); //DoTest(/*!!!SonyEricsson_Hid_Record*/InTheHand.Net.Tests.Sdp2.Data_CompleteThirdPartyRecords.BluetoothListener_DefaultRecord_ChatSample, // Data_SdpCreator_CompleteRecords.SonyEricsson_Hid_Record); }
public void CreateL2Cap() { ServiceElement element = ServiceRecordHelper.CreateL2CapProtocolDescriptorList(); // List_ServiceAttribute attrs = new List_ServiceAttribute(); attrs.Add(new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList, element)); ServiceRecord record = new ServiceRecord(attrs); String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ExpectedL2CapDump, dump, "L2CAP ProtoDL dump"); }
static void Documentation_SRB_Simple() { ServiceRecord r = Documentation_SRB_Simple_(); ServiceRecordUtilities.Dump(Console.Out, r); ServiceRecordCreator ctr = new ServiceRecordCreator(); byte[] bs = ctr.CreateServiceRecord(r); ServiceRecordParser psr = new ServiceRecordParser(); ServiceRecord r2 = psr.Parse(bs); ServiceRecordUtilities.Dump(Console.Out, r2); }
public void OneNoExtAttr() { var mocks = new Mockery(); var hackApi = mocks.NewMock <IBluesoleilApi>(); SetupNoSearchAppExtSPPService(hackApi); Expect.Never.On(hackApi).Method("Btsdk_FreeMemory"); // byte[] setSvcName = { (byte)'a', /* \u00E4 */ 0xC3, 0xA4, (byte)'b', (byte)'b', (byte)'c', (byte)'c', (byte)'d', (byte)'d' }; var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, 0x1112, setSvcName, IntPtr.Zero); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1112 -- HeadsetAudioGateway" + NewLine + NewLine + "AttrId: 0x0006 -- LanguageBaseAttributeIdList" + NewLine + "ElementSequence" + NewLine + " UInt16: 0x656E" + NewLine + " UInt16: 0x6A" + NewLine + " UInt16: 0x100" + NewLine + NewLine + "AttrId: 0x0100 -- ServiceName" + NewLine + "TextString: [en] 'a\u00E4bbccdd'" + NewLine + NewLine + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1112, svcC, "svcC"); // string sn = sr.GetPrimaryMultiLanguageStringAttributeById(UniversalAttributeId.ServiceName); Assert.AreEqual("a\u00E4bbccdd", sn, "sn"); //---- mocks.VerifyAllExpectationsHaveBeenMet(); }
public void OneNoExtAttr_ManualMock() { var hackApi = new TestSdBluesoleilApi(); byte[] setSvcName = Encoding.UTF8.GetBytes("aabbccdd"); var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, 0x1112, setSvcName, IntPtr.Zero); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1112 -- HeadsetAudioGateway" + NewLine + NewLine + "AttrId: 0x0006 -- LanguageBaseAttributeIdList" + NewLine + "ElementSequence" + NewLine + " UInt16: 0x656E" + NewLine + " UInt16: 0x6A" + NewLine + " UInt16: 0x100" + NewLine + NewLine + "AttrId: 0x0100 -- ServiceName" + NewLine + "TextString: [en] 'aabbccdd'" + NewLine + NewLine + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1112, svcC, "svcC"); // string sn = sr.GetPrimaryMultiLanguageStringAttributeById(UniversalAttributeId.ServiceName); Assert.AreEqual("aabbccdd", sn, "sn"); //---- hackApi.AssertActionsNoMore(); }
public void CreateL2CapNapEmptyNetProtoList() { var netProtoList = new ServiceElement(ElementType.ElementSequence ); var layer1 = new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.Uuid16, Uuid16_BnepProto), ServiceElement.CreateNumericalServiceElement(ElementType.UInt16, 0x0100), //v1.0 netProtoList ); ServiceElement element = ServiceRecordHelper.CreateL2CapProtocolDescriptorListWithUpperLayers( layer1); // List_ServiceAttribute attrs = new List_ServiceAttribute(); attrs.Add(new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList, element)); ServiceRecord record = new ServiceRecord(attrs); String dump = ServiceRecordUtilities.Dump(record); Assert.AreEqual(ExpectedL2CapNapDumpEmptyNetProtoList, dump, "L2CAP NAP ProtoDL dump"); }
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { BluetoothDeviceInfo device = (sender as ListView).SelectedItem as BluetoothDeviceInfo; if (device != null) { if (device.InstalledServices.Length > 0) { Task.Factory.StartNew(() => { Dispatcher.Invoke(new Action(() => { IsGatheringInformation = true; TextBoxInfo.Clear(); })); try { foreach (var guid in device.InstalledServices) { ServiceRecord[] serviceRecords = device.GetServiceRecords(guid); Dispatcher.Invoke(new Action(() => { TextBoxInfo.Text += string.Format("=========== Service: {0} ({1}) ==========={2}{2}", BluetoothService.GetName(guid), guid, Environment.NewLine); foreach (var serviceRecord in serviceRecords) { TextBoxInfo.Text += ServiceRecordUtilities.Dump(serviceRecord) + Environment.NewLine; } })); } } catch { Dispatcher.Invoke(new Action(() => { TextBoxInfo.Text = string.Format("No available information for '{0}'. Try to connect/turn-on the device.", device.DeviceName); })); } }).ContinueWith((Task task) => { Dispatcher.Invoke(new Action(() => { IsGatheringInformation = false; })); }); } else { TextBoxInfo.Text = "No installed services."; } } }
static void Documentation_SRB_ToByteArray_Pbap() { ServiceRecordBuilder bldr = new ServiceRecordBuilder(); bldr.AddServiceClass(BluetoothService.PhonebookAccessPse); bldr.ServiceName = "Phonebook Access PSE"; bldr.AddBluetoothProfileDescriptor(BluetoothService.PhonebookAccess, 1, 0); // v1.0 const ushort SupportedRepositories = 0x0314; bldr.AddCustomAttribute(new ServiceAttribute(SupportedRepositories, ServiceElement.CreateNumericalServiceElement(ElementType.UInt8, 0x03))); // ServiceRecord record = bldr.ServiceRecord; // var txt = ServiceRecordUtilities.Dump(record); Console.WriteLine(txt); // var byteArr = record.ToByteArray(); var txtBA = BitConverter.ToString(byteArr); Console.WriteLine(txtBA); }
static void SetL2CapPort_(int psm, string expectedPsmAsString1, string expectedPsmAsString2) { var layer0 = new ServiceElement(ElementType.ElementSequence, new ServiceElement(ElementType.Uuid16, Uuid16_L2CapProto), ServiceElement.CreateNumericalServiceElement(ElementType.UInt16, 0) ); ServiceRecord rcd = new ServiceRecord( new ServiceAttribute(UniversalAttributeId.ProtocolDescriptorList, new ServiceElement(ElementType.ElementSequence, layer0))); ServiceRecordHelper.SetL2CapPsmNumber(rcd, psm); string expected = "AttrId: 0x0004 -- ProtocolDescriptorList" + CrLf + "ElementSequence" + CrLf + " ElementSequence" + CrLf + " Uuid16: 0x100 -- L2CapProtocol" + CrLf + " UInt16: " + expectedPsmAsString1 + CrLf + "( ( L2Cap, PSM=" + expectedPsmAsString2 + " ) )" + CrLf ; var dump = ServiceRecordUtilities.Dump(rcd); Assert.AreEqual(expected, dump); }
public void DeviceIdExtAttr_NoServiceName() { var mocks = new Mockery(); var hackApi = mocks.NewMock <IBluesoleilApi>(); SetupNoSearchAppExtSPPService(hackApi); // var ext = new Structs.BtSdkRmtDISvcExtAttrStru(1, 2, 3, 4, true, 6, 0); IntPtr pExt = Marshal.AllocHGlobal(Marshal.SizeOf(ext)); Marshal.StructureToPtr(ext, pExt, false); Expect.Once.On(hackApi).Method("Btsdk_FreeMemory").With(pExt); // byte[] setSvcName = new byte[0]; const int SvcClassPnp = 0x1200; var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, SvcClassPnp, setSvcName, pExt); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1200 -- PnPInformation" + NewLine + NewLine // + "AttrId: 0x0200 -- SpecificationId" + NewLine + "UInt16: 0x1" + NewLine + NewLine + "AttrId: 0x0201 -- VendorId" + NewLine + "UInt16: 0x2" + NewLine + NewLine + "AttrId: 0x0202 -- ProductId" + NewLine + "UInt16: 0x3" + NewLine + NewLine + "AttrId: 0x0203 -- Version" + NewLine + "UInt16: 0x4" + NewLine + NewLine + "AttrId: 0x0204 -- PrimaryRecord" + NewLine + "Boolean: True" + NewLine + NewLine + "AttrId: 0x0205 -- VendorIdSource" + NewLine + "UInt16: 0x6" + NewLine + NewLine // + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr, typeof(DeviceIdProfileAttributeId)); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1200, svcC, "svcC"); // //---- mocks.VerifyAllExpectationsHaveBeenMet(); }
internal static void DoTestSmart(String expected, ServiceRecord record, params Type[] attributeIdEnumDefiningTypes) { string result = ServiceRecordUtilities.Dump(record, attributeIdEnumDefiningTypes); Assert.AreEqual(expected, result); }
public void OneSppExtAttr_ManualMock() { var hackApi = new TestSdBluesoleilApi(); // const byte Port = 23; var ext = new Structs.BtSdkRmtSPPSvcExtAttrStru(Port); IntPtr pExt = Marshal.AllocHGlobal(Marshal.SizeOf(ext)); Marshal.StructureToPtr(ext, pExt, false); // byte[] setSvcName = Encoding.UTF8.GetBytes("aabbccdd"); var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, 0x1112, setSvcName, pExt); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1112 -- HeadsetAudioGateway" + NewLine + NewLine + "AttrId: 0x0004 -- ProtocolDescriptorList" + NewLine + "ElementSequence" + NewLine + " ElementSequence" + NewLine + " Uuid16: 0x100 -- L2CapProtocol" + NewLine + " ElementSequence" + NewLine + " Uuid16: 0x3 -- RFCommProtocol" + NewLine + " UInt8: 0x17" + NewLine + "( ( L2Cap ), ( Rfcomm, ChannelNumber=23 ) )" + NewLine + NewLine + "AttrId: 0x0006 -- LanguageBaseAttributeIdList" + NewLine + "ElementSequence" + NewLine + " UInt16: 0x656E" + NewLine + " UInt16: 0x6A" + NewLine + " UInt16: 0x100" + NewLine + NewLine + "AttrId: 0x0100 -- ServiceName" + NewLine + "TextString: [en] 'aabbccdd'" + NewLine + NewLine + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1112, svcC, "svcC"); // e = sr.GetAttributeById(UniversalAttributeId.ProtocolDescriptorList).Value; ServiceElement listRfcomm = e.GetValueAsElementArray()[1]; ServiceElement eScn = listRfcomm.GetValueAsElementArray()[1]; byte scn = (byte)eScn.Value; Assert.AreEqual(Port, scn, "scn"); // string sn = sr.GetPrimaryMultiLanguageStringAttributeById(UniversalAttributeId.ServiceName); Assert.AreEqual("aabbccdd", sn, "sn"); //---- hackApi.AssertActionsInOrder("Btsdk_FreeMemory", pExt); hackApi.AssertActionsNoMore(); }
public void OneSppExtAttr_FullLenServiceName() { var mocks = new Mockery(); var hackApi = mocks.NewMock <IBluesoleilApi>(); SetupNoSearchAppExtSPPService(hackApi); // const byte Port = 23; var ext = new Structs.BtSdkRmtSPPSvcExtAttrStru(Port); IntPtr pExt = Marshal.AllocHGlobal(Marshal.SizeOf(ext)); Marshal.StructureToPtr(ext, pExt, false); Expect.Once.On(hackApi).Method("Btsdk_FreeMemory").With(pExt); // Debug.Assert(80 == StackConsts.BTSDK_SERVICENAME_MAXLENGTH, "BTSDK_SERVICENAME_MAXLENGTH: " + StackConsts.BTSDK_SERVICENAME_MAXLENGTH); byte[] setSvcName = new byte[StackConsts.BTSDK_SERVICENAME_MAXLENGTH]; for (int i = 0; i < (setSvcName.Length - 1); ++i) { setSvcName[i] = (byte)'a'; } setSvcName[setSvcName.Length - 1] = (byte)'b'; var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, 0x1112, setSvcName, pExt); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1112 -- HeadsetAudioGateway" + NewLine + NewLine + "AttrId: 0x0004 -- ProtocolDescriptorList" + NewLine + "ElementSequence" + NewLine + " ElementSequence" + NewLine + " Uuid16: 0x100 -- L2CapProtocol" + NewLine + " ElementSequence" + NewLine + " Uuid16: 0x3 -- RFCommProtocol" + NewLine + " UInt8: 0x17" + NewLine + "( ( L2Cap ), ( Rfcomm, ChannelNumber=23 ) )" + NewLine + NewLine + "AttrId: 0x0006 -- LanguageBaseAttributeIdList" + NewLine + "ElementSequence" + NewLine + " UInt16: 0x656E" + NewLine + " UInt16: 0x6A" + NewLine + " UInt16: 0x100" + NewLine + NewLine + "AttrId: 0x0100 -- ServiceName" + NewLine + "TextString: [en] 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab'" + NewLine + NewLine + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1112, svcC, "svcC"); // e = sr.GetAttributeById(UniversalAttributeId.ProtocolDescriptorList).Value; ServiceElement listRfcomm = e.GetValueAsElementArray()[1]; ServiceElement eScn = listRfcomm.GetValueAsElementArray()[1]; byte scn = (byte)eScn.Value; Assert.AreEqual(Port, scn, "scn"); // string sn = sr.GetPrimaryMultiLanguageStringAttributeById(UniversalAttributeId.ServiceName); Assert.AreEqual("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", sn, "sn"); //---- mocks.VerifyAllExpectationsHaveBeenMet(); }
//Not supported! Can't tell between little-endian and big-endian Unicode! //[TestMethod] public void OneNoExtAttr_PanuBeUnicodeSvcName() { var mocks = new Mockery(); var hackApi = mocks.NewMock <IBluesoleilApi>(); SetupNoSearchAppExtSPPService(hackApi); Expect.Never.On(hackApi).Method("Btsdk_FreeMemory"); // byte[] setSvcName = { 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x73, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x20, 0x00, 0x41, 0x00, 0x64, 0x00, 0x2D, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x20, 0x00, 0x55, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x53, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x69, 0x00, 0x63, 0x00, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ushort SvcClassPanu = 0x1115; var attrs = new Structs.BtSdkRemoteServiceAttrStru(0, SvcClassPanu, setSvcName, IntPtr.Zero); ServiceRecord sr = BluesoleilDeviceInfo.CreateServiceRecord(ref attrs, hackApi); // const string NewLine = "\r\n"; const string expectedDump = "AttrId: 0x0001 -- ServiceClassIdList" + NewLine + "ElementSequence" + NewLine + " Uuid16: 0x1115 -- Panu" + NewLine + NewLine + "AttrId: 0x0006 -- LanguageBaseAttributeIdList" + NewLine + "ElementSequence" + NewLine + " UInt16: 0x656E" + NewLine + " UInt16: 0x6A" + NewLine + " UInt16: 0x100" + NewLine + NewLine + "AttrId: 0x0100 -- ServiceName" + NewLine + "TextString: [en] 'Personal Ad-hoc User Service'" + NewLine + NewLine + "AttrId: 0xFFFF" + NewLine + "TextString (guessing UTF-8): '<partial BlueSoleil decode>'" + NewLine ; string dump = ServiceRecordUtilities.Dump(sr); Assert.AreEqual(expectedDump, dump, "dump"); // ServiceElement e; // e = sr.GetAttributeById(UniversalAttributeId.ServiceClassIdList).Value; ServiceElement eSvcClass = e.GetValueAsElementArray()[0]; UInt16 svcC = (UInt16)eSvcClass.Value; Assert.AreEqual(0x1115, svcC, "svcC"); // string sn = sr.GetPrimaryMultiLanguageStringAttributeById(UniversalAttributeId.ServiceName); Assert.AreEqual("Personal Ad-hoc User Service", sn, "sn"); //---- mocks.VerifyAllExpectationsHaveBeenMet(); }
public void Utils_DumpRaw_NullWriter() { ServiceRecord rec = new ServiceRecord(new List_ServiceAttribute()); ServiceRecordUtilities.DumpRaw(null, rec); }
public void Utils_DumpRaw_NullRecord() { ServiceRecordUtilities.DumpRaw(new System.IO.StringWriter(), null); }
static void Parse() { byte[] raw = { 0x35, 0x3b, 0x09, 0x00, 0x01, 0x35, 0x06, 0x19, 0x11, 0x12, 0x19, 0x12, 0x03, 0x09, 0x00, 0x04, 0x35, 0x0c, 0x35, 0x03, 0x19, 0x01, 0x00, 0x35, 0x05, 0x19, 0x00, 0x03, 0x08, 0x0a, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x08, 0x09, 0x01, 0x00, 0x09, 0x01, 0x00, 0x25, 0x0d, 0x56, 0x6f, 0x69, 0x63, 0x65, 0x20, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79 }; //==== byte jPortNo = 99; byte[] rgbSdpRecord = { 0x35, 0x00,// Note: The size is filled below. 0x09, // ServiceClassIDList 0x00, 0x01, // Service Classes 0x35, 0x03,// 3 bytes // OBEXObjectPush 0x1105 0x19, 0x11, 0x05, 0x09, // ProtocolDescriptorList 0x00, 0x04, // Protocol ID List 0x35, 0x11, // 17 bytes // L2CAP (0x0100) 0x35, 0x03, // 3 bytes 0x19, 0x01, 0x00, // RFCOMM (0x0003) 0x35, 0x05, // 5 bytes 0x19, 0x00, 0x03, // ID 0x08, jPortNo, //0x05, // Channel Number is (5) // OBEX (0x0008) 0x35, 0x03,// 3 bytes 0x19, 0x00, 0x08, 0x09, // BluetoothProfileDescriptorList 0x00, 0x09, 0x35, 0x08, // 8 bytes 0x35, 0x06, // 6 bytes 0x19, 0x11, 0x05, // OBEXObjectPush 0x09, 0x01, 0x00, // Version 0x09, // Service Name 0x01, 0x00, 0x25, 0x13,// Type - String, size - 19 bytes (Object Push Profile) 0x4f, 0x62, 0x6a,0x65, 0x63, 0x74, 0x20, 0x50, 0x75, 0x73, 0x68, 0x20, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x09, // Supported Format List 0x03, 0x03, 0x35, 0x0e, // 14 bytes 0x08, 0x01, // vCard 2.1 0x08, 0x02, // vCard 3.0 0x08, 0x03, // vCard 1.0 0x08, 0x04, // iCal 2.0 0x08, 0x05, // vNote 0x08, 0x06, // vMessage 0x08, 0xff // Any type of object }; //const size_t iRecSize = sizeof(rgbSdpRecord) / sizeof(BYTE); int iRecSize = rgbSdpRecord.Length; rgbSdpRecord[1] = checked ((byte)(iRecSize - 2)); // -2 for excluding first 2 bytes //==== ServiceRecordParser psr = new ServiceRecordParser(); ServiceRecord sr = psr.Parse(rgbSdpRecord); string txt = ServiceRecordUtilities.Dump(sr); }