void DoStartInquiry() { bool success = false; try { _handlerActive = true; bool ok = _fcty.GetAdapter().StartDiscovery(); if (!ok) throw new InvalidOperationException("Device Discovery failed; maybe Bluetooth is disabled."); success = true; } finally { if (!success) { _handlerActive = false; } }//finally }
protected override List <IBluetoothDeviceInfo> GetKnownRemoteDeviceEntries() { // "If Bluetooth state is not STATE_ON, this API will return an empty set." // "Returns: unmodifiable set of BluetoothDevice, or null on error" var knownDevs = _fcty.GetAdapter().BondedDevices; if (knownDevs == null) { throw new InvalidOperationException("Failed to get the known devices."); } var known = from x in knownDevs select(IBluetoothDeviceInfo) AndroidBthDeviceInfo.CreateFromBondedList(_fcty, x); return(known.ToList()); }
internal static AndroidBthDeviceInfo CreateFromGivenAddress( AndroidBthFactoryBase fcty, BluetoothAddress address, bool queryOrInternalOnly) { BluetoothAdapter a = fcty.GetAdapter(); var dev = a.GetRemoteDevice(AndroidBthUtils.FromBluetoothAddress(address)); var bdi = new AndroidBthDeviceInfo(fcty, dev); // if (queryOrInternalOnly) { bdi._rmbd = bdi._authd = (dev.BondState == Bond.Bonded); var cod = dev.BluetoothClass; if (cod != null) { bdi._cod = AndroidBthUtils.ConvertCoDs(cod); } } return(bdi); }
public void Start() { var svcName = ServiceName; Debug.Assert(_svcClassOrig != null, "NULL _svcClassOrig"); Debug.Assert(_svcClass != null, "NULL _svcClass"); var uuid = _svcClass; var a = _fcty.GetAdapter(); if (_auth || _encr) { _server = a.ListenUsingRfcommWithServiceRecord(svcName, uuid); } else { _server = a.ListenUsingInsecureRfcommWithServiceRecord(svcName, uuid); } _server.ToString(); // ensure non-null _active = true; }