void InitRadios() { if (_radioPrimary != null) { return; } // int idPrimary = NativeMethods.hci_get_route(IntPtr.Zero); /////////////////////////////// BluezUtils.CheckAndThrow((BluezError)idPrimary, "hci_get_route"); var dd = NativeMethods.hci_open_dev(idPrimary); Console.WriteLine("InitRadios idPrimary: {0}, dd: {1}", idPrimary, dd); _radioPrimary = new BluezRadio(this, dd); // int maxToTry = 10; var list = new List <IBluetoothRadio>(); for (int curId = 0; curId < maxToTry; ++curId) { var curDd = NativeMethods.hci_open_dev(curId); var ret = (BluezError)curDd; if (BluezUtils.IsSuccess(ret)) { Console.WriteLine("InitRadios curDd: {0}", curDd); var curR = new BluezRadio(this, curDd); list.Add(curR); } } _radioList = list; Debug.Assert(_radioList.Count >= 1); }
protected override IBluetoothRadio[] GetAllRadios() { var arr = new IBluetoothRadio[1]; arr[0] = GetPrimaryRadio(); return(arr); }
static StuffRadio Create_Radio_A(Params p) { var stuff = new StuffRadio(); //. const uint StackId = 1; var addrBytes = new byte[] { 0xA4, 0x24, 0x4C, 0x98, 0x24, 0x08 }; var ExpectedAddress = BluetoothAddress.Parse("08:24:98:4C:24:A4"); var nameBytes = new byte[] { (byte)'A', (byte)'b', (byte)'c', 0 }; var ExpectedName = "Abc"; var codStruct = (uint)0x20104; var ExpectedCod = new ClassOfDevice(0x20104); // BluetopiaTesting.InitMockery(stuff, StackId); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Local_BD_ADDR") .With(StackId, new byte[6]) .Will( FillArrayIndexedParameterAction.Fill(1, addrBytes, true), Return.Value(BluetopiaError.OK)); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Local_Device_Name") .With(StackId, 248, new byte[248]) .Will( FillArrayIndexedParameterAction.Fill(2, nameBytes, false), Return.Value(BluetopiaError.OK)); Expect.Once.On(stuff.MockedApi).Method("GAP_Query_Class_Of_Device") .With(StackId, Is.Out) .Will( new SetIndexedParameterAction(1, codStruct), Return.Value(BluetopiaError.OK)); if (p.AccessesVersionsOrManufacturer) { Expect.Once.On(stuff.MockedApi).Method("HCI_Read_Local_Version_Information") .With(StackId, Is.Out, Is.Out, Is.Out, Is.Out, Is.Out, Is.Out) .Will( new SetIndexedParameterAction(1, (StackConsts.HCI_ERROR_CODE) 0), new SetIndexedParameterAction(2, (HciVersion)0), new SetIndexedParameterAction(3, (UInt16)0), new SetIndexedParameterAction(4, (LmpVersion)0), new SetIndexedParameterAction(5, Manufacturer.Zeevo), new SetIndexedParameterAction(6, (UInt16)0), Return.Value(BluetopiaError.OK)); } //-- BluetopiaTesting.HackAllowShutdownCall(stuff.MockedApi); BluetopiaFactory fcty = new BluetopiaFactory(stuff.MockedApi); IBluetoothRadio r = stuff.Radio = fcty.DoGetPrimaryRadio(); Assert.AreEqual(Manufacturer.StonestreetOne, r.SoftwareManufacturer, "SoftwareManufacturer"); Assert.AreEqual(ExpectedAddress, r.LocalAddress, "LocalAddress"); Assert.AreEqual(ExpectedName, r.Name, "Name"); Assert.AreEqual(ExpectedCod, r.ClassOfDevice, "ClassOfDevice"); // return(stuff); }
//---------------------------------------------------------------------- private BluetoothRadio(BluetoothFactory factory, IBluetoothRadio impl) { Debug.Assert(impl != null); m_impl = impl; m_publicFactory = new BluetoothPublicFactory(factory); }