Is there any way to do this? Can I also check Bluetooth and Bluetooth Low Energy separately?
What do you mean by βdeviceβ, is it the device on which the application is running, or the device on which the Bluetooth service is installed, to which the application must have access?
As far as I know, there is no API in UWP to check if Bluetooth is enabled on the device.
On a Windows Mobile device, you can use the following method as a workaround.
private async void FindPaired() {
On a Windows PC, I suggest you check the availability of services at the Bluetooth service level as a workaround.
For non-BLE services, such as RFCOMM, you can get the number of devices with a specific service identifier. If Bluetooth is disabled at the hardware level, the counter will be 0.
rfcommServiceInfoCollection = await DeviceInformation.FindAllAsync( RfcommDeviceService.GetDeviceSelector(RfcommServiceId.ObexObjectPush));
For BLE services, you can use the BluetoothLEAdvertisementWatcher class to receive BLE ads. If Bluetooth is disabled at the hardware level, ads will not be accepted.
watcher = new BluetoothLEAdvertisementWatcher(); watcher.Received += OnAdvertisementReceived; private async void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs eventArgs) { var address = eventArgs.BluetoothAddress; BluetoothLEDevice device = await BluetoothLEDevice.FromBluetoothAddressAsync(address); var cnt =device.GattServices.Count; watcher.Stop(); }
source share