Exemple #1
0
        private void NCIConfigureMode(DeviceModeEnum mode)
        {
            if (mode == 0)
            {
                return;
            }

            /* Enable Proprietary interface for T4T card presence check procedure */
            if (mode == DeviceModeEnum.NXPNCI_MODE_RW)
            {
                EnableProprietaryExtensionsCommand  cmd  = new EnableProprietaryExtensionsCommand(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);
                EnableProprietaryExtensionsResponse resp = new EnableProprietaryExtensionsResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);
                SendCommand(cmd, resp);
                //if ((Answer[0] != 0x4F) || (Answer[1] != 0x02) || (Answer[3] != 0x00)) return NXPNCI_ERROR;
                if (resp.Status != ReponseCode.STATUS_OK ||
                    resp.OpcodeIdentifier != OpcodeProprietaryExtensionsEnum.NCI_PROPRIETARY_ACT_CMD ||
                    resp.GroupIdentifier != GroupIdentifierEnum.PROPRIETARY ||
                    resp.MessageType != PacketTypeEnum.ControlResponse ||
                    resp.PacketBoundryFlag != PacketBoundryFlagEnum.CompleteMessageOrLastSegment)
                {
                    throw new Exception("EnableProprietaryExtensionsResponse error:" + resp.Status);
                }

                /* Building Discovery Map command */
                RFDiscoverMapCommand  cmd2  = new RFDiscoverMapCommand(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);
                RFDiscoverMapResponse resp2 = new RFDiscoverMapResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment);

                MappingConfiguration mc1 = new MappingConfiguration()
                {
                    RFProtocol = RFProtocolEnum.PROT_T1T, RFMode = RFModeEnum.MODE_POLL, RFInterface = RFInterfaceEnum.INTF_FRAME
                };
                MappingConfiguration mc2 = new MappingConfiguration()
                {
                    RFProtocol = RFProtocolEnum.PROT_T2T, RFMode = RFModeEnum.MODE_POLL, RFInterface = RFInterfaceEnum.INTF_FRAME
                };
                MappingConfiguration mc3 = new MappingConfiguration()
                {
                    RFProtocol = RFProtocolEnum.PROT_T3T, RFMode = RFModeEnum.MODE_POLL, RFInterface = RFInterfaceEnum.INTF_FRAME
                };
                MappingConfiguration mc4 = new MappingConfiguration()
                {
                    RFProtocol = RFProtocolEnum.PROT_ISODEP, RFMode = RFModeEnum.MODE_POLL, RFInterface = RFInterfaceEnum.INTF_ISODEP
                };
                MappingConfiguration mc5 = new MappingConfiguration()
                {
                    RFProtocol = RFProtocolEnum.PROT_MIFARE, RFMode = RFModeEnum.MODE_POLL, RFInterface = RFInterfaceEnum.PROPRIETARY_START
                };

                cmd2.MappingConfigurations    = new MappingConfiguration[5];
                cmd2.MappingConfigurations[0] = mc1;
                cmd2.MappingConfigurations[1] = mc2;
                cmd2.MappingConfigurations[2] = mc3;
                cmd2.MappingConfigurations[3] = mc4;
                cmd2.MappingConfigurations[4] = mc5;

                SendCommand(cmd2, resp2);
                //if ((Answer[0] != 0x41) || (Answer[1] != 0x00) || (Answer[3] != 0x00)) return NXPNCI_ERROR;
                if (resp2.Status != ReponseCode.STATUS_OK ||
                    resp2.OpcodeIdentifier != OpcodeRFIdentifierEnum.RF_DISCOVER_MAP_CMD ||
                    resp2.GroupIdentifier != GroupIdentifierEnum.RFMANAGEMENT ||
                    resp2.MessageType != PacketTypeEnum.ControlResponse ||
                    resp2.PacketBoundryFlag != PacketBoundryFlagEnum.CompleteMessageOrLastSegment)
                {
                    throw new Exception("RFDiscoverMapResponse error:" + resp2.Status);
                }
            }
        }