Exemple #1
0
        public async Task <INukiReturnMessage> SendCalibrateRequest(UInt16 securityPin)
        {
            RecieveStatusCommand retCmd = null;

            try
            {
                using (var lockHandle = await Locker.Lock())
                {
                    if (lockHandle.Successfull && await Challenge())
                    {
                        retCmd = await m_UGDIO.Send <RecieveStatusCommand>(new SendRequestCalibrationCommand(this, securityPin));
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Update(new NukiCommandException(NukiCommandType.RequestCalibration, ex));
            }
            return(retCmd);
        }
Exemple #2
0
        public async Task <INukiReturnMessage> SendLockAction(NukiLockAction lockAction, NukiLockActionFlags flags = NukiLockActionFlags.None)
        {
            RecieveStatusCommand retCmd = null;

            try
            {
                using (var lockHandle = await Locker.Lock())
                {
                    if (lockHandle.Successfull && await Challenge())
                    {
                        Log.Debug("Send SendLockAction command...");
                        retCmd = await m_UGDIO.Send <RecieveStatusCommand>(new SendLockActionCommand(lockAction, flags, this));
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Update(new NukiCommandException(NukiCommandType.LockAction, ex));
            }
            return(retCmd);
        }
        public static RecieveBaseCommand Parse(IDataReader reader)
        {
            RecieveBaseCommand cmd = null;

            if (reader.UnconsumedBufferLength >= 2)
            {
                NukiCommandType cmdType = (NukiCommandType)reader.ReadUInt16();
                switch (cmdType)
                {
                case NukiCommandType.AuthorizationID:
                    cmd = new RecieveAuthorizationIDCommand();
                    break;

                case NukiCommandType.Challenge:
                    cmd = new RecieveChallengeCommand();
                    break;

                case NukiCommandType.ErrorReport:
                    cmd = new RecieveErrorReportCommand();
                    break;

                case NukiCommandType.PublicKey:
                    cmd = new RecievePublicKeyCommand();
                    break;

                case NukiCommandType.Status:
                    cmd = new RecieveStatusCommand();
                    break;

                case NukiCommandType.NukiStates:
                    cmd = new RecieveNukiStatesCommand();
                    break;

                case NukiCommandType.Config:
                    cmd = new RecieveConfigCommand();
                    break;

                case NukiCommandType.BatteryReport:
                    cmd = new RecieveBatteryReportCommand();
                    break;

                case NukiCommandType.LogEntryCount:
                    cmd = new RecieveLogEntryCountCommand();
                    break;

                case NukiCommandType.LogEntry:
                    cmd = new RecieveLogEntryCommand();
                    break;

                default:
                    Log.Error($"Command {cmdType} is not handelt!");
                    break;
                }
            }
            else
            {
                //not enough data...
            }

            return(cmd);
        }