internal async Task <bool> ConnectAsync(RomeRemoteSystem selectedRemoteSystem) { //_socketService.StopBroadcasting(); _connectedRemoteSystem = selectedRemoteSystem; return(await _bluetoothService.ConnectAsync(selectedRemoteSystem)); //Command(RemoteCommands.MiriotConnect); }
public async Task <bool> ConnectAsync(string?macAddress = null, Models?model = null, bool noRetry = false) { /* Load from configuration */ if (macAddress == null && model == null) { if (RegisteredDeviceValid && ServiceUuid != null) { try { await _backend.ConnectAsync(SettingsProvider.Instance.RegisteredDevice.MacAddress, ServiceUuid.ToString() !, noRetry); return(true); } catch (BluetoothException ex) { OnBluetoothError(ex); return(false); } } else { Log.Error("BluetoothImpl: Connection attempt without valid cached device"); } } /* Update device registration */ else if (macAddress != null && model != null) { if (IsDeviceValid((Models)model, macAddress)) { SettingsProvider.Instance.RegisteredDevice.Model = (Models)model; SettingsProvider.Instance.RegisteredDevice.MacAddress = macAddress; /* Load from configuration this time */ return(await ConnectAsync()); } else { Log.Error("BluetoothImpl: Connection attempt without valid device"); return(false); } } else { throw new ArgumentException("Either all or none arguments must be null"); } return(false); }
public async Task DeviceSelectedAsync(string mac, string name) { IsBusy = true; var connected = await _bluetoothService.ConnectAsync(name, mac); if (connected) { await _userInteraction.DisplayAlertAsync("Info", "Connected to device!", "OK"); await _navigationService.PopToRootAsync(); } else { await _userInteraction.DisplayAlertAsync("Info", "You were not able to connect to the device!", "OK"); } IsBusy = false; }