/// <summary> /// Indicates whether the system can use Bluetooth. /// </summary> /// <returns>True or false if Bluetooth is available</returns> public async Task <bool> GetBluetoothIsEnabledAsync() { BluetoothAdapter btAdapter = await BluetoothAdapter.GetDefaultAsync(); if (btAdapter == null || !btAdapter.IsLowEnergySupported || !btAdapter.IsCentralRoleSupported) { return(false); } var radios = await Radio.GetRadiosAsync(); if (radios.Count <= 0) { return(false); } var bluetoothRadio = radios.Where(r => r.Kind == RadioKind.Bluetooth).FirstOrDefault(); return(bluetoothRadio != null && bluetoothRadio.State == RadioState.On); }
/// <summary> /// Get the BluetoothAdapter object. /// </summary> /// <returns>instance of BluetoothAdapter</returns> public async Task <BluetoothAdapter> GetBluetoothAdapter() { BluetoothAdapter btAdapter = await BluetoothAdapter.GetDefaultAsync(); if (btAdapter == null) { return(null); } var radios = await Radio.GetRadiosAsync(); if (radios.Count <= 0) { return(null); } var bluetoothRadio = radios.Where(r => r.Kind == RadioKind.Bluetooth).FirstOrDefault(); if (bluetoothRadio != null && bluetoothRadio.State == RadioState.On) { return(btAdapter); } return(null); }