示例#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]);
        }
示例#2
0
        public override byte[] serialize()
        {
            byte pos = 4;

            byte[] ser = TechSpecificParam.serialize();
            payLoad = new byte[pos + ser.Length + 1];

            payLoad[0] = RFDiscoveryId;
            payLoad[1] = (byte)RFProtocol;
            payLoad[2] = (byte)RFTechnologiesAndMode;
            payLoad[3] = (byte)(ser.Length + 1);
            Array.Copy(ser, 0, payLoad, pos, ser.Length);
            pos          = (byte)(pos + ser.Length);
            payLoad[pos] = (byte)DiscoverNotificationType;

            return(base.serialize());
        }
示例#3
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(MessageType + " with " + PacketBoundryFlag + " on GID " + GroupIdentifier + " and OID " + OpcodeIdentifier);
            sb.AppendLine("[" + getPLL() + "] HEX[" + BitConverter.ToString(payLoad, 0) + "]");
            sb.AppendLine("RFDiscoveryId: " + RFDiscoveryId);
            sb.AppendLine("RFProtocol: " + RFProtocol);
            sb.AppendLine("RFTechnologiesAndMode: " + RFTechnologiesAndMode);
            sb.AppendLine("---TechSpecificParam---");
            if (TechSpecificParam != null)
            {
                sb.Append(TechSpecificParam.ToString());
            }
            else
            {
                sb.AppendLine("NULL");
            }
            sb.AppendLine("---");
            return(sb.ToString());
        }
示例#4
0
        public override byte[] serialize()
        {
            byte pos = 7;

            byte[] ser  = new byte[0];
            byte[] ser2 = new byte[0];
            if (TechSpecificParam != null)
            {
                ser = TechSpecificParam.serialize();
            }
            if (ActivationParameter != null)
            {
                ser2 = ActivationParameter.serialize();
            }

            payLoad = new byte[pos + ser.Length + 3 + ser2.Length];

            payLoad[0] = RFDiscoveryId;
            payLoad[1] = (byte)RFInterface;
            payLoad[2] = (byte)RFProtocol;
            payLoad[3] = (byte)RFTechnologiesAndMode;
            payLoad[4] = MaxDataPacketPayloadSize;
            payLoad[5] = InitialNoOfCredits;
            payLoad[6] = (byte)ser.Length;
            Array.Copy(ser, 0, payLoad, pos, ser.Length);
            pos          = (byte)(pos + ser.Length);
            payLoad[pos] = (byte)DataExchangeRFTechAndMode;
            pos++;
            payLoad[pos] = DataExchangeTransmitBitRate;
            pos++;
            payLoad[pos] = DataExchangeReceiveBitRate;
            pos++;
            Array.Copy(ser2, 0, payLoad, pos, ser2.Length);
            pos = (byte)(pos + ser2.Length);
            return(base.serialize());
        }
示例#5
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);
            }
        }