Beispiel #1
0
        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
            }
        }
Beispiel #2
0
 public async void StopScanning()
 {
     if (AdapterBLE.IsScanning)
     {
         Debug.WriteLine("Still scanning, stopping the scan");
         await AdapterBLE.StopScanningForDevicesAsync();
     }
 }
Beispiel #3
0
 public void DisconnectDevice()
 {
     if (BLEDevice != null)
     {
         AdapterBLE.DisconnectDeviceAsync(BLEDevice);
         BLEDevice.Dispose();
         BLEDevice = null;
     }
 }
Beispiel #4
0
 void StartScanning(Guid forService)
 {
     if (AdapterBLE.IsScanning)
     {
         AdapterBLE.StopScanningForDevicesAsync();
         Debug.WriteLine("adapter.StopScanningForDevices()");
     }
     else
     {
         DeviceList.Clear();
         AdapterBLE.StartScanningForDevicesAsync();
         Debug.WriteLine("adapter.StartScanningForDevices(" + forService + ")");
     }
 }
Beispiel #5
0
 void Adapter_ScanTimeoutElapsed(object sender, EventArgs e)
 {
     AdapterBLE.StopScanningForDevicesAsync();
     Debug.WriteLine("Timeout", "Bluetooth scan timeout elapsed");
 }