async void AttemptReconnect(Guid deviceId, CancellationToken token) { if (token.IsCancellationRequested) { return; } try { await AdapterBLE.ConnectToKnownDeviceAsync(deviceId); System.Diagnostics.Debug.WriteLine("Successfully Reconnected!"); } catch (TaskCanceledException) { //Do nothing, task was cancelled } catch (Exception) { AttemptReconnect(deviceId, token); } finally { //hide loading } }
public async void StopScanning() { if (AdapterBLE.IsScanning) { Debug.WriteLine("Still scanning, stopping the scan"); await AdapterBLE.StopScanningForDevicesAsync(); } }
public void DisconnectDevice() { if (BLEDevice != null) { AdapterBLE.DisconnectDeviceAsync(BLEDevice); BLEDevice.Dispose(); BLEDevice = null; } }
void StartScanning(Guid forService) { if (AdapterBLE.IsScanning) { AdapterBLE.StopScanningForDevicesAsync(); Debug.WriteLine("adapter.StopScanningForDevices()"); } else { DeviceList.Clear(); AdapterBLE.StartScanningForDevicesAsync(); Debug.WriteLine("adapter.StartScanningForDevices(" + forService + ")"); } }
void Adapter_ScanTimeoutElapsed(object sender, EventArgs e) { AdapterBLE.StopScanningForDevicesAsync(); Debug.WriteLine("Timeout", "Bluetooth scan timeout elapsed"); }