public RecieveErrorReportCommand(NukiErrorCode errorCode, NukiCommandType failedCommand)
     : base(NukiCommandType.ErrorReport, new FieldParserBase[]
 {
     new FieldParser <NukiErrorCode>(nameof(ErrorCode), sizeof(NukiErrorCode), (b, s, l) => errorCode),
     new FieldParser <NukiCommandType>(nameof(FailedCommand), sizeof(NukiCommandType), (b, s, l) => failedCommand)
 })
 {
 }
Exemple #2
0
        private RecieveBaseCommand(NukiCommandType type, FieldParserBase[] fields)
            : base(type, fields.Length)
        {
            m_fields = fields;
            int nBytesCount = 0;

            foreach (var field in fields)
            {
                nBytesCount += field.ByteLength;
            }
            m_byData = new byte[nBytesCount];
        }
Exemple #3
0
 public NukiCommandFailed(NukiCommandType requestedCmd, NukiErrorCode statusCode)
 {
     FailedCommand = requestedCmd;
     ErrorCode     = statusCode;
 }
Exemple #4
0
 public SendBaseCommandWithContext(NukiCommandType type, IConnectionContext connectionContext, int nNumberOfFields)
     : base(type, nNumberOfFields)
 {
     ConnectionContext = connectionContext;
 }
 protected RecieveBaseCommandAuthenticated(NukiCommandType type, IEnumerable <FieldParserBase> fields)
     : base(type, InitFields(fields))
 {
 }
Exemple #6
0
 public BaseCommand(NukiCommandType type, int nNumberOfFields)
 {
     m_mapByPostion = new DataField[nNumberOfFields + 1];
     AddField(nameof(CommandType), type, FieldFlags.PartOfMessage);
 }
Exemple #7
0
 /// <summary>
 /// Request Data (0x0001) 
 /// </summary>
 /// <param name="requestedCommand">The identifier of the command to be executed by the NukiSmartlock.</param>
 public SendRequestDataCommand(NukiCommandType requestedCommand)
     : base(NukiCommandType.RequestData, 1)
 {
     AddField(nameof(ReqestedCommand), requestedCommand);
 }
Exemple #8
0
 protected RecieveBaseCommand(NukiCommandType type, IEnumerable <FieldParserBase> fields)
     : this(type, AddCRCField(fields))
 {
 }
Exemple #9
0
 public NukiCommandException(NukiCommandType failedCommand, Exception ex)
 {
     FailedCommand = failedCommand;
     Exception     = ex;
 }
Exemple #10
0
        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);
        }
Exemple #11
0
 public NukiCommandTimeout(NukiCommandType failedCommand, int nTimeoutTime)
 {
     FailedCommand = failedCommand;
     TimeoutTime   = nTimeoutTime;
 }
Exemple #12
0
 public SendBaseCommand(NukiCommandType type, int nNumberOfFields)
     : base(type, nNumberOfFields)
 {
 }
 public SendBaseCommandAuthenticated(NukiCommandType type, IConnectionContext connectionContext, int nNumberOfFields)
     : base(type, connectionContext, nNumberOfFields + 1)
 {
     AddField(nameof(Authenticator), CalculateAuthenticator, 32, FieldFlags.PartOfMessage);
 }