예제 #1
0
        /// <summary>
        /// constructor for message received (upstream)
        /// </summary>
        /// <param name="input"></param>
        public MacCommandHolder(byte[] input)
        {
            int pointer = 0;

            macCommand = new List <GenericMACCommand>();

            while (pointer < input.Length)
            {
                CidEnum cid = (CidEnum)input[pointer];
                switch (cid)
                {
                case CidEnum.LinkCheckCmd:
                    Logger.Log("mac command detected : LinkCheckCmd", Logger.LoggingLevel.Info);
                    LinkCheckCmd linkCheck = new LinkCheckCmd();
                    pointer += linkCheck.Length;
                    macCommand.Add(linkCheck);
                    break;

                case CidEnum.LinkADRCmd:
                    Logger.Log("mac command detected : LinkADRCmd", Logger.LoggingLevel.Info);
                    break;

                case CidEnum.DutyCycleCmd:
                    Logger.Log("mac command detected : DutyCycleCmd", Logger.LoggingLevel.Info);
                    DutyCycleCmd dutyCycle = new DutyCycleCmd();
                    pointer += dutyCycle.Length;
                    macCommand.Add(dutyCycle);
                    break;

                case CidEnum.RXParamCmd:
                    Logger.Log("mac command detected : RXParamCmd", Logger.LoggingLevel.Info);
                    break;

                case CidEnum.DevStatusCmd:
                    Logger.Log("mac command detected : DevStatusCmd", Logger.LoggingLevel.Info);
                    DevStatusCmd devStatus = new DevStatusCmd(input[pointer + 1], input[pointer + 2]);
                    pointer += devStatus.Length;
                    macCommand.Add(devStatus);
                    break;

                case CidEnum.NewChannelCmd:
                    Logger.Log("mac command detected : NewChannelCmd", Logger.LoggingLevel.Info);
                    NewChannelAns newChannel = new NewChannelAns(Convert.ToBoolean(input[pointer + 1] & 1), Convert.ToBoolean(input[pointer + 1] & 2));
                    pointer += newChannel.Length;
                    macCommand.Add(newChannel);
                    break;

                case CidEnum.RXTimingCmd:
                    Logger.Log("mac command detected : RXTimingCmd", Logger.LoggingLevel.Info);
                    RXTimingSetupCmd rXTimingSetup = new RXTimingSetupCmd();
                    pointer += rXTimingSetup.Length;
                    macCommand.Add(rXTimingSetup);
                    break;
                }
            }
        }
예제 #2
0
        public MacCommandHolder(byte input)
        {
            macCommand = new List <GenericMACCommand>();

            CidEnum cid = (CidEnum)input;

            switch (cid)
            {
            case CidEnum.LinkCheckCmd:
                LinkCheckCmd linkCheck = new LinkCheckCmd();
                macCommand.Add(linkCheck);
                break;

            case CidEnum.LinkADRCmd:
                Logger.Log("mac command detected : LinkADRCmd", Logger.LoggingLevel.Info);
                break;

            case CidEnum.DutyCycleCmd:
                DutyCycleCmd dutyCycle = new DutyCycleCmd();
                macCommand.Add(dutyCycle);
                break;

            case CidEnum.RXParamCmd:
                Logger.Log("mac command detected : RXParamCmd", Logger.LoggingLevel.Info);
                break;

            case CidEnum.DevStatusCmd:
                Logger.Log("mac command detected : DevStatusCmd", Logger.LoggingLevel.Info);
                DevStatusCmd devStatus = new DevStatusCmd();
                macCommand.Add(devStatus);
                break;

            case CidEnum.NewChannelCmd:
                //NewChannelReq newChannel = new NewChannelReq();
                //macCommand.Add(newChannel);
                break;

            case CidEnum.RXTimingCmd:
                RXTimingSetupCmd rXTimingSetup = new RXTimingSetupCmd();
                macCommand.Add(rXTimingSetup);
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MacCommandHolder"/> class.
        /// constructor for message received (upstream)
        /// </summary>
        public MacCommandHolder(byte[] input)
        {
            int pointer = 0;

            this.MacCommand = new List <GenericMACCommand>();

            while (pointer < input.Length)
            {
                CidEnum cid = (CidEnum)input[pointer];
                switch (cid)
                {
                case CidEnum.LinkCheckCmd:
                    Logger.Log("mac command detected : LinkCheckCmd", LogLevel.Information);
                    LinkCheckCmd linkCheck = new LinkCheckCmd();
                    pointer += linkCheck.Length;
                    this.MacCommand.Add(linkCheck);
                    break;

                case CidEnum.LinkADRCmd:
                    LinkADRCmd linkADRCmd = new LinkADRCmd();
                    pointer += linkADRCmd.Length;
                    this.MacCommand.Add(linkADRCmd);
                    Logger.Log("mac command detected : LinkADRCmd", LogLevel.Information);
                    break;

                case CidEnum.DutyCycleCmd:
                    Logger.Log("mac command detected : DutyCycleCmd", LogLevel.Information);
                    DutyCycleCmd dutyCycle = new DutyCycleCmd();
                    pointer += dutyCycle.Length;
                    this.MacCommand.Add(dutyCycle);
                    break;

                case CidEnum.RXParamCmd:
                    Logger.Log("mac command detected : RXParamCmd", LogLevel.Information);
                    RXParamSetupCmd rxParamSetupCmd = new RXParamSetupCmd();
                    pointer += rxParamSetupCmd.Length;
                    this.MacCommand.Add(rxParamSetupCmd);
                    break;

                case CidEnum.DevStatusCmd:
                    Logger.Log("mac command detected : DevStatusCmd", LogLevel.Information);
                    DevStatusCmd devStatus = new DevStatusCmd(input[pointer + 1], input[pointer + 2]);
                    pointer += devStatus.Length;
                    this.MacCommand.Add(devStatus);
                    break;

                case CidEnum.NewChannelCmd:
                    Logger.Log("mac command detected : NewChannelCmd", LogLevel.Information);
                    NewChannelAns newChannel = new NewChannelAns(Convert.ToBoolean(input[pointer + 1] & 1), Convert.ToBoolean(input[pointer + 1] & 2));
                    pointer += newChannel.Length;
                    this.MacCommand.Add(newChannel);
                    break;

                case CidEnum.RXTimingCmd:
                    Logger.Log("mac command detected : RXTimingCmd", LogLevel.Information);
                    RXTimingSetupCmd rXTimingSetup = new RXTimingSetupCmd();
                    pointer += rXTimingSetup.Length;
                    this.MacCommand.Add(rXTimingSetup);
                    break;

                default:
                    Logger.Log($"value {input[pointer]} as MAC command type is not recognized, aborting Mac command parsing", LogLevel.Error);
                    return;
                }
            }
        }