示例#1
0
        private static void EnsureHasObjectPath(BluezDeviceInfo bdi)
        {
            // A device from discovery (D-Bus or HCI) isn't 'created' by BlueZ
            // so no ObjectPath. So we have to lookup/create the device now.
            if (bdi._dbusPath != null)
            {
                return;
            }
            var pd = bdi._fcty.BluezDbus.FindDeviceProperties_OnDefaultAdapter(bdi._addr, out bdi._dbusPath);

            Debug.Assert((pd == null) == (bdi._dbusPath == null), "Xor! "
                         + Utils.MiscUtils.ToStringQuotedOrNull(pd) + " vs "
                         + Utils.MiscUtils.ToStringQuotedOrNull(bdi._dbusPath));
            if (pd == null)
            {
                // Doesn't exist, so have to create the device now.
                var a = bdi._fcty.BluezDbus.GetDefaultAdapter();
                bdi._dbusPath = a.CreateDevice(BluezUtils.FromBluetoothAddressToDbus(bdi._addr));
            }
            Debug.Assert(bdi._dbusPath != null, "NOT _dbusPath!=null after EnsureHasObjectPath.");
            Console.WriteLine("EnsureHasObjectPath after: "
                              + Utils.MiscUtils.ToStringQuotedOrNull(bdi._dbusPath));
        }
 //--------
 static string FromBluetoothAddress(BluetoothAddress address)
 {
     return(BluezUtils.FromBluetoothAddressToDbus(address));
 }