Ejemplo n.º 1
0
        public override void deserialize(byte[] packet)
        {
            base.deserialize(packet);
            RFDiscoveryId         = payLoad[0];
            RFProtocol            = (RFProtocolEnum)EnumUtil.GetEnum(typeof(RFProtocolEnum), payLoad[1]);
            RFTechnologiesAndMode = (RFTechnologiesAndModeEnum)EnumUtil.GetEnum(typeof(RFTechnologiesAndModeEnum), payLoad[2]);
            byte techModeLength = payLoad[3];
            byte pos            = 4;

            if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCAPollMode();
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_B_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCBPollMode();
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_F_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCFPollMode();
            }
            else
            {
                throw new Exception("Invalid RFTechnologiesAndMode found in RFDiscoverNotification");
            }

            pos = TechSpecificParam.deserialize(payLoad, pos);

            DiscoverNotificationType = (DiscoverNotificationTypeEnum)EnumUtil.GetEnum(typeof(DiscoverNotificationTypeEnum), payLoad[pos]);
        }
Ejemplo n.º 2
0
        public override void deserialize(byte[] packet)
        {
            base.deserialize(packet);
            RFDiscoveryId            = payLoad[0];
            RFInterface              = (RFInterfaceEnum)EnumUtil.GetEnum(typeof(RFInterfaceEnum), payLoad[1]);
            RFProtocol               = (RFProtocolEnum)EnumUtil.GetEnum(typeof(RFProtocolEnum), payLoad[2]);
            RFTechnologiesAndMode    = (RFTechnologiesAndModeEnum)EnumUtil.GetEnum(typeof(RFTechnologiesAndModeEnum), payLoad[3]);
            MaxDataPacketPayloadSize = payLoad[4];
            InitialNoOfCredits       = payLoad[5];

            byte lengthOfTechModeParam = payLoad[6];
            byte pos = 7;

            if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCAPollMode();
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE)
            {
                TechSpecificParam = null;
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_B_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCBPollMode();
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_B_PASSIVE_LISTEN_MODE)
            {
                TechSpecificParam = null;
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_F_PASSIVE_POLL_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCFPollMode();
            }
            else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_F_PASSIVE_LISTEN_MODE)
            {
                TechSpecificParam = new TechSpecificParamsNFCFListenMode();
            }
            else if ((byte)RFTechnologiesAndMode >= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_START_LISTEN &&
                     (byte)RFTechnologiesAndMode <= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_END_LISTEN)
            {
                TechSpecificParam = null;
            }
            else
            {
                throw new Exception("Invalid RFTechnologiesAndMode found in RFDiscoverNotification");
            }

            if (TechSpecificParam != null)
            {
                pos = TechSpecificParam.deserialize(payLoad, pos);
            }
            else
            {
                pos = (byte)(pos + lengthOfTechModeParam);
            }

            DataExchangeRFTechAndMode = (RFTechnologiesAndModeEnum)EnumUtil.GetEnum(typeof(RFTechnologiesAndModeEnum), payLoad[pos]);
            pos++;
            DataExchangeTransmitBitRate = payLoad[pos];
            pos++;
            DataExchangeReceiveBitRate = payLoad[pos];
            pos++;

            if (RFInterface == RFInterfaceEnum.INTF_ISODEP)
            {
                if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_POLL_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCA_ISODEP_POLL();
                }
                else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_B_PASSIVE_POLL_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCB_ISODEP_POLL();
                }
                else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCA_ISODEP_LISTEN();
                }
                else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_B_PASSIVE_LISTEN_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCB_ISODEP_LISTEN();
                }
                else if ((byte)RFTechnologiesAndMode >= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_START_LISTEN &&
                         (byte)RFTechnologiesAndMode <= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_END_LISTEN)
                {
                    ActivationParameter = null;
                }
                else
                {
                    throw new Exception("Invalid RFTechnologiesAndMode found in RFDiscoverNotification");
                }
            }
            else if (RFInterface == RFInterfaceEnum.INTF_NFCDEP)
            {
                if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_POLL_MODE ||  //NFC-DEP Poll Mode
                    RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_F_PASSIVE_POLL_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCA_NFCF__DEP_POLL();
                }
                else if (RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_A_PASSIVE_LISTEN_MODE || // NFC-DEP Listen Mode
                         RFTechnologiesAndMode == RFTechnologiesAndModeEnum.NFC_F_PASSIVE_LISTEN_MODE)
                {
                    ActivationParameter = new ActivationParameterNFCA_NFCF__DEP_LISTEN();
                }
                else if ((byte)RFTechnologiesAndMode >= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_START_LISTEN &&
                         (byte)RFTechnologiesAndMode <= (byte)RFTechnologiesAndModeEnum.PROPRIETARY_END_LISTEN)
                {
                    ActivationParameter = null;
                }
                else
                {
                    throw new Exception("Invalid RFTechnologiesAndMode found in RFDiscoverNotification");
                }
            }

            if (ActivationParameter != null)
            {
                pos = ActivationParameter.deserialize(payLoad, pos);
            }
            else
            {
                byte lengthOfActivationParameter = payLoad[pos];
                pos = (byte)(pos + 1 + lengthOfActivationParameter);
            }
        }