public async Task <BluetoothWriteResponse> WriteGpioConfig(GpioConfig gpioConfig)
        {
            try
            {
                JObject json          = JObject.FromObject(gpioConfig);
                byte[]  messageToSend = Encoding.UTF8.GetBytes(json.ToString());
                bool    result        = await bT.Write(configurationServiceGuid, writeGpioConfigGuid, messageToSend);

                if (result)
                {
                    string writeResult = await bT.Read(configurationServiceGuid, writeGpioConfigGuid);

                    return((BluetoothWriteResponse)writeResult);
                }
                else
                {
                    return(BluetoothWriteResponse.NO_RESPONSE);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                return(BluetoothWriteResponse.ERROR);
            }
        }
        public async Task <GpioConfig> ReadGpioConfig()
        {
            GpioConfig response = null;

            try
            {
                string result = await bT.Read(configurationServiceGuid, readGpioConfigGuid);

                response = JObject.Parse(result).ToObject <GpioConfig>();
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(response);
        }
        public async Task <bool> WriteGpioConfig()
        {
            Alert toSend = null;
            BluetoothWriteResponse status = await services.WriteGpioConfig(GpioConfig);

            if (status != BluetoothWriteResponse.OK)
            {
                toSend     = new Alert("Error al escribir config GPIO", "Ha ocurrido un error al escribir la configuracion GPIO, la misma no se ha guardado");
                GpioConfig = await ReadGpioConfig();
            }
            else
            {
                SendRequiresRestart(RequiresRestart.SOFT_RESTART);
                toSend = new Alert("Config GPIO guardada exitosamente", "Se ha guardado exitosamente la configuracion GPIO. Se requiere reinicio del indoor para que la misma surta efecto");
            }
            SendMessage(toSend);
            return(status == BluetoothWriteResponse.OK);
        }
 public GpioConfigViewModel()
 {
     WriteGpioConfigCommand = new Command(async() => await WriteGpioConfig());
     ReadGpioConfigCommand  = new Command(async() => GpioConfig = await ReadGpioConfig());
 }