Skip to content

Instantly share code, notes, and snippets.

@marqzosvaldo
Created December 13, 2019 05:00
Show Gist options
  • Save marqzosvaldo/0168b81b919ce93daee47af483cfb34e to your computer and use it in GitHub Desktop.
Save marqzosvaldo/0168b81b919ce93daee47af483cfb34e to your computer and use it in GitHub Desktop.
CommandDesconectarDispositivo
private ICommand _desconnectCommand;
public ICommand DesconnectCommand => _desconnectCommand ?? (_desconnectCommand = new Command(async (item) => {
var device = item as IDevice;
try {
if(device.State == Plugin.BLE.Abstractions.DeviceState.Disconnected) {
throw new System.ArgumentException("Dispositivo no puede estar desconectado", "devicel.state");
}
await _adapter.DisconnectDeviceAsync(device);
await page.DisplayAlert("Desconectado", $"Status {device.State}", "Ok");
} catch (Exception ex) {
await page.DisplayAlert("El Dispositivo aun no ha sido conectado", $"Status {device.State}", "Ok");
Debug.WriteLine(ex);
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment