Exemplo n.º 1
0
        internal static BluezDeviceInfo CreateFromInquiry(BluezFactory fcty, Structs.inquiry_info cur)
        {
            var addr = BluezUtils.ToBluetoothAddress(cur.bdaddr);
            var bdi  = new BluezDeviceInfo(fcty, addr);

            bdi._cod = BluezUtils.ToClassOfDevice(cur.dev_class);
            // Note the devices here aren't 'created' by BlueZ so no ObjectPath.
            // We'll lookup/create the device later if required.
            //
            return(bdi);
        }
Exemplo n.º 2
0
        //----
        internal BluezRadio(BluezFactory fcty, int dd)
        {
            _dd = dd;
            Debug.Assert(fcty != null, "ArgNull");
            _fcty = fcty;
            BluezError ret;
            var        bdaddr = BluezUtils.FromBluetoothAddress(BluetoothAddress.None);

            ret = NativeMethods.hci_read_bd_addr(_dd, bdaddr, _fcty.StackTimeout);
            //TODO BluezUtils.CheckAndThrow(ret, "hci_read_bd_addr");
            BluezUtils.Assert(ret, "hci_read_bd_addr");
            if (BluezUtils.IsSuccess(ret))
            {
                _addr = BluezUtils.ToBluetoothAddress(bdaddr);
                Console.WriteLine("Radio SUCCESS, addr: " + _addr);
            }
            else
            {
                // NEVER used EXCEPT in the debugger if we skip the CheckandThrow above.
                _addr = BluetoothAddress.None;
                Console.WriteLine("Radio FAIL, addr: " + _addr);
            }
            _nameTmp = new byte[250];
            //
            // First find _objectPath. In the future we'll be passed this.
            var ax = _fcty.BluezDbus.FindAdapter(_addr, out _objectPath);

            Debug.Assert(_objectPath != null, "BluezRadio..ctor NOT _objectPath!=null");
            //--
            // Set Adapter.
            _adapter = GetAdapter(_objectPath);
            Console.WriteLine("Got adapter at .ctor.3.");
            //
            var    prop   = GetProperties();
            string addrDt = (string)prop[PropertyName.Address];
            var    addrD  = BluetoothAddress.Parse(addrDt);

            Utils.MiscUtils.AssertEquals(addrD, _addr);
            Console.WriteLine("Check DONE Radio..ctor. " + addrD + " vs " + _addr);
        }