//---- public override IBluetoothDeviceInfo[] DiscoverDevices( int maxDevices, bool authenticated, bool remembered, bool unknown, bool discoverableOnly, BluetoothClient.LiveDiscoveryCallback liveDiscoHandler, object liveDiscoState) { Console.WriteLine("DiscoverDevices"); BluezDbus bus = null; Action <IBluetoothDeviceInfo> removeDlgt = null; if (liveDiscoHandler != null || liveDiscoState != null) { Console.WriteLine("Gonna AddInquiryEvents 2"); bus = _fcty.BluezDbus; Action <IBluetoothDeviceInfo> dlgt = delegate(IBluetoothDeviceInfo bdi) { liveDiscoHandler(bdi, liveDiscoState); }; bus.LiveDisco += dlgt; removeDlgt = dlgt; } try { return(DoDiscoverDevices( maxDevices, authenticated, remembered, unknown, discoverableOnly, liveDiscoHandler, liveDiscoState)); } finally { if (removeDlgt != null) { bus.LiveDisco -= removeDlgt; } } }
//---- public BluezFactory() { var platformStr = Environment.OSVersion.Platform.ToString(); if (platformStr.StartsWith("Win", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Linux only, NOT Windows."); } Console.WriteLine("BluezFactory platform: {0} = 0x{0:x}", Environment.OSVersion.Platform); _busBluez = new BluezDbus(this); #if !ONE_RADIO InitRadios(); #endif GetPrimaryRadio(); // bool hackOnWindows = false; if (hackOnWindows) { _radioList = new List <IBluetoothRadio>(); _radioList.Add(new NullBluetoothFactory.NullRadio()); } Console.WriteLine("Done BluezFactory init."); }