Beispiel #1
0
        private void NCIStartDiscovery()
        {
            RFDiscoverCommand cmd = new RFDiscoverCommand(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);

            DiscoverConfiguration dc1 = new DiscoverConfiguration()
            {
                RFTechnologiesAndMode = RFTechnologiesAndModeEnum.NFC_A_PASSIVE_POLL_MODE, RFDiscoverFrequency = 0x01
            };
            DiscoverConfiguration dc2 = new DiscoverConfiguration()
            {
                RFTechnologiesAndMode = RFTechnologiesAndModeEnum.NFC_B_PASSIVE_POLL_MODE, RFDiscoverFrequency = 0x01
            };
            DiscoverConfiguration dc3 = new DiscoverConfiguration()
            {
                RFTechnologiesAndMode = RFTechnologiesAndModeEnum.NFC_F_PASSIVE_POLL_MODE, RFDiscoverFrequency = 0x01
            };

            cmd.DiscoverConfigurations    = new DiscoverConfiguration[3];
            cmd.DiscoverConfigurations[0] = dc1;
            cmd.DiscoverConfigurations[1] = dc2;
            cmd.DiscoverConfigurations[2] = dc3;

            RFDiscoverResponse resp = new RFDiscoverResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);

            SendCommand(cmd, resp);
            //if ((Answer[0] != 0x41) || (Answer[1] != 0x03) || (Answer[3] != 0x00)) return NXPNCI_ERROR;
            if (resp.Status != ReponseCode.STATUS_OK ||
                resp.OpcodeIdentifier != OpcodeRFIdentifierEnum.RF_DISCOVER_CMD ||
                resp.GroupIdentifier != GroupIdentifierEnum.RFMANAGEMENT ||
                resp.MessageType != PacketTypeEnum.ControlResponse ||
                resp.PacketBoundryFlag != PacketBoundryFlagEnum.CompleteMessageOrLastSegment)
            {
                throw new Exception("NCIStartDiscovery error:" + resp.Status);
            }
        }
 public override byte[] serialize()
 {
     payLoad = new byte[(DiscoverConfigurations.Length * DiscoverConfiguration.getSize()) + 1];
     for (int i = 0; i < DiscoverConfigurations.Length; i++)
     {
         DiscoverConfiguration mc = DiscoverConfigurations[i];
         byte[] ser = mc.serialize();
         Array.Copy(ser, 0, payLoad, (DiscoverConfiguration.getSize() * i) + 1, DiscoverConfiguration.getSize());
     }
     payLoad[0] = (byte)DiscoverConfigurations.Length;
     return(base.serialize());
 }
        public override void deserialize(byte[] packet)
        {
            base.deserialize(packet);

            byte noOfConfigurations = payLoad[0];

            DiscoverConfigurations = new DiscoverConfiguration[noOfConfigurations];
            byte pos = 1;

            for (int i = 0; i < noOfConfigurations; i++)
            {
                DiscoverConfiguration mc = new DiscoverConfiguration();
                pos = mc.deserialize(payLoad, pos);
                DiscoverConfigurations[i] = mc;
            }
        }