private async Task <bool> Save()
        {
            ServerConfig.queueName = ServerConfig.queueName.Contains("-") ? ServerConfig.queueName.Split('-')[1] : ServerConfig.queueName;
            BluetoothWriteResponse status = await services.WriteServerConfig(ServerConfig);

            Alert toSend = null;

            if (status == BluetoothWriteResponse.OK || status == BluetoothWriteResponse.HARD_RESET)
            {
                if (status == BluetoothWriteResponse.HARD_RESET)
                {
                    SendRequiresRestart(RequiresRestart.HARD_RESTART);
                }
                else
                {
                    SendRequiresRestart(RequiresRestart.SOFT_RESTART);
                }
                toSend = new Alert("Configuracion de indoor guardada exitosamente", "Se ha guardado exitosamente la configuracion del indoor. Se requiere reinicio del indoor para que la misma surta efecto");
            }
            else
            {
                toSend = new Alert("Error al escribir configuracion del indoor ", "Ha ocurrido un error al escribir la configuracion del indoor, la misma no se ha guardado");
            }
            SendMessage(toSend);
            return(status == BluetoothWriteResponse.OK || status == BluetoothWriteResponse.HARD_RESET);
        }
Esempio n. 2
0
        private async Task StartStop()
        {
            Alert toSend = null;
            BluetoothWriteResponse status = BluetoothWriteResponse.ERROR;

            if (IsStarted)
            {
                status = await services.StartStopReboot(StartStopReboot.STOP);

                if (status == BluetoothWriteResponse.OK)
                {
                    toSend = new Alert("Indoor parado exitosamente", "Se ha detenido exitosamente el indoor");
                }
                else
                {
                    toSend = new Alert("Error al detener indoor", "Ha ocurrido un error al detener el indoor el mismo se encuentra corriendo");
                }
            }
            else
            {
                status = await services.StartStopReboot(StartStopReboot.START);

                if (status == BluetoothWriteResponse.OK)
                {
                    toSend = new Alert("Indoor inciado correctamente", "Se ha iniciado correctamente el indoor. El mismo podria demorar unos segundos para encontrarse listo");
                }
                else
                {
                    toSend = new Alert("Error al inciar indoor", "Ha ocurrido un error al iniciar el indoor");
                }
            }
            await Status();

            SendMessage(toSend);
        }
        private async Task <bool> WriteUsers()
        {
            Alert toSend = null;
            BluetoothWriteResponse status = BluetoothWriteResponse.ERROR;

            if (!string.IsNullOrEmpty(NewUser) && !string.IsNullOrEmpty(NewPassword))
            {
                User toAdd = new User(NewUser, NewPassword);
                Usuarios.Add(toAdd);
                status = await btServices.WriteUserConfig(Usuarios);

                if (status != BluetoothWriteResponse.OK)
                {
                    Usuarios.Remove(toAdd);
                    toSend = new Alert("Error al guardar usuarios", "Ha ocurrido un error al guardar los usuarios del indoor");
                }
                else
                {
                    SendRequiresRestart(RequiresRestart.SOFT_RESTART);
                    NewUser     = "";
                    NewPassword = "";
                    toSend      = new Alert("Usuarios guardos exitosamente", "Se han guardado exitosamente los usuarios del indoor. Se requiere reinicio del indoor para que los mismos se encuentren disponibles");
                }
            }
            else
            {
                toSend = new Alert("Complete todos los campos", "Debe completar tanto el usuario como el password");
            }
            SendMessage(toSend);
            return(status == BluetoothWriteResponse.OK);
        }
Esempio n. 4
0
        private async Task HardRestartServer()
        {
            Alert toSend = null;
            BluetoothWriteResponse status = await services.StartStopReboot(StartStopReboot.HARD_REBOOT);

            if (status == BluetoothWriteResponse.OK)
            {
                toSend = new Alert("Indoor reiniciado completamente", "Se ha reiniciado completamente el indoor. El mismo podria demorar hasta un minuto para encontrarse listo");
            }
            else
            {
                toSend = new Alert("Error al reiniciar completamente el indoor", "Ha ocurrido un error al reiniciar completamente el indoor");
            }
            SendMessage(toSend);
        }
Esempio n. 5
0
        private async Task RestartServer()
        {
            Alert toSend = null;
            BluetoothWriteResponse status = await services.StartStopReboot(StartStopReboot.REBOOT);

            if (status == BluetoothWriteResponse.OK)
            {
                toSend = new Alert("Indoor reiniciado correctamente", "Se ha reiniciado correctamente el indoor. El mismo podria demorar unos segundos para encontrarse listo");
            }
            else
            {
                toSend = new Alert("Error al reiniciar indoor", "Ha ocurrido un error al reiniciar el indoor");
            }
            await Status();

            SendMessage(toSend);
        }
        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);
        }
        private async Task ConnectToNetwork()
        {
            if (this.SelectedNetwork != null)
            {
                BluetoothWriteResponse result = await this.btServices.ConnectToWifi(SelectedNetwork.Ssid, SelectedNetwork.Password);

                Alert alert = null;
                if (result == BluetoothWriteResponse.HARD_RESET)
                {
                    SendRequiresRestart(RequiresRestart.HARD_RESTART);
                    alert = new Alert("Conexion exitosa", "El indoor se ha conectado exitosamente a la red wifi " + SelectedNetwork.Ssid + ". Debe reiniciar el indoor");
                }
                else
                {
                    alert = new Alert("Error al conectarse", "Ocurrio un error al conectarse a la red wifi");
                }
                SendMessage(alert);
            }
        }