public async Task <bool> UpdateAvailableDevice() { DeviceSelectionViewModel.ClearCachedDevices(); try { DeviceSelectionViewModel.ClearCachedDevices(); var result = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate)); if (result.Count > 0) { foreach (var device in result) { var ble = await BluetoothLEDevice.FromIdAsync(device.Id) as BluetoothLEDevice; DeviceSelectionViewModel.AddBLEDevice(ble); } } else { if (!await DeviceSelectionViewModel.IsBluetoothSettingOn()) { ShowErrorMessage(); } } return(true); } catch (Exception) { return(false); } }
public async Task <bool> UpdateAvailableDevice() { try { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { DeviceSelectionViewModel.ClearCachedDevices(); }); var result = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(ToolboxIdentifications.GattServiceUuids.DeviceFirmwareUpdate)); if (result.Count > 0) { foreach (var device in result) { var ble = await BluetoothLEDevice.FromIdAsync(device.Id) as BluetoothLEDevice; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { DeviceSelectionViewModel.AddBLEDevice(ble); }); } } else { if (!await DeviceSelectionViewModel.IsBluetoothSettingOn()) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ShowBluetoothOffErrorMessage(); }); } } return(true); } catch (Exception) { return(false); } }