public async Task <string> CommandGetVariable(string propertyName)
        {
            if (_UARTService == null || !_UARTService.IsDeviceReady)
            {
                return(string.Empty);
            }

            //Generate package
            DataPacket packetToSend = new GetPropertyDataPacket(propertyName);

            //Timeout handling
            TaskCompletionSource <DataPacket> signalEventPoke = new TaskCompletionSource <DataPacket>();
            UARTPacketEventHandler            handler         = null;

            handler += (sender, e) =>
            {
                if (e.ResponsePacket.MessageId == packetToSend.MessageId)
                {
                    signalEventPoke.SetResult(e.ResponsePacket);
                    _UARTService.UARTPacketReceived -= handler;
                }
            };
            _UARTService.UARTPacketReceived += handler;

            if (await _UARTService.SendPacket(packetToSend))
            {
                SendPropertyDataPacket reception = await TimeoutAsyncEvent.TimeoutAfter(signalEventPoke.Task, TIMEOUT_UART_ANSWER) as SendPropertyDataPacket;

                _UARTService.UARTPacketReceived -= handler;

                if (reception != null)
                {
                    await CommandConfirmVariable(reception.MessageId, reception.PropertyName);
                }
                return(reception?.PropertyValue);
            }
            else
            {
                //TODO LOG Log.Error("PokeAliveCommand failed.");
                _UARTService.UARTPacketReceived -= handler;
            }
            return(string.Empty);
        }
        public async Task <bool> CommandLaunchAction(string actionName, string parametersJson)
        {
            if (_UARTService == null || !_UARTService.IsDeviceReady)
            {
                return(false);
            }

            //Generate package
            DataPacket packetToSend = new LaunchActionDataPacket(actionName, parametersJson);

            //Timeout handling
            TaskCompletionSource <DataPacket> signalEventPoke = new TaskCompletionSource <DataPacket>();
            UARTPacketEventHandler            handler         = null;

            handler += (sender, e) =>
            {
                if (e.ResponsePacket.MessageId == packetToSend.MessageId)
                {
                    signalEventPoke.SetResult(e.ResponsePacket);
                    _UARTService.UARTPacketReceived -= handler;
                }
            };
            _UARTService.UARTPacketReceived += handler;

            if (await _UARTService.SendPacket(packetToSend))
            {
                DataPacket reception = await TimeoutAsyncEvent.TimeoutAfter(signalEventPoke.Task, TIMEOUT_UART_ANSWER);

                _UARTService.UARTPacketReceived -= handler;

                return(reception != null);
            }
            else
            {
                //TODO LOG Log.Error("PokeAliveCommand failed.");
                _UARTService.UARTPacketReceived -= handler;
            }
            return(false);
        }
        /// <summary>
        /// Command CFGS to set the connection string in the chip appconfig store.
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns>True if the connection string was successfully set.</returns>
        public async Task <bool> SetConfigOnChip(string connectionString)
        {
            if (_UARTService == null)
            {
                return(false);
            }

            TaskCompletionSource <FourByFourReception> signalEventPoke = new TaskCompletionSource <FourByFourReception>();

            UARTPacketEventHandler handler = null;

            handler += (sender, e) =>
            {
                if (e.ResponsePacket.Command == FourByFourConstants.CMD_SET_CONFIG)
                {
                    signalEventPoke.SetResult(e.ResponsePacket);
                    _UARTService.UARTPacketReceived -= handler;
                }
            };
            _UARTService.UARTPacketReceived += handler;


            if (_UARTService.SendPacket(new SetConfigCommand(connectionString)))
            {
                FourByFourReception reception = await TimeoutAsyncEvent.TimeoutAfter(signalEventPoke.Task, TIMEOUT);

                _UARTService.UARTPacketReceived -= handler;

                return(reception.State == ReceptionState.Success);
            }
            else
            {
                Log.Error("SetConfigCommand failed.");
                _UARTService.UARTPacketReceived -= handler;
            }
            return(false);
        }
        /// <summary>
        /// Command CFGG to retrieve the current connection string saved in the chip.
        /// </summary>
        /// <returns>Connection String</returns>
        public async Task <string> GetConnectionStringFromChip()
        {
            if (_UARTService == null)
            {
                return(string.Empty);
            }

            TaskCompletionSource <FourByFourReception> signalEventPoke = new TaskCompletionSource <FourByFourReception>();

            UARTPacketEventHandler handler = null;

            handler += (sender, e) =>
            {
                if (e.ResponsePacket.Command == FourByFourConstants.CMD_GET_CONFIG)
                {
                    signalEventPoke.SetResult(e.ResponsePacket);
                    _UARTService.UARTPacketReceived -= handler;
                }
            };
            _UARTService.UARTPacketReceived += handler;


            if (_UARTService.SendPacket(new GetConfigCommand()))
            {
                FourByFourReception reception = await TimeoutAsyncEvent.TimeoutAfter(signalEventPoke.Task, TIMEOUT);

                _UARTService.UARTPacketReceived -= handler;

                return(((GetConfigReception)reception).ConnectionString);
            }
            else
            {
                Log.Error("GetConfigCommand failed.");
                _UARTService.UARTPacketReceived -= handler;
            }
            return(string.Empty);
        }