public void NCIProcessReaderMode(RFProtocolEnum protocol, NxpNciRWOperationEnum operation) { switch (operation) { case (NxpNciRWOperationEnum.PRESENCE_CHECK): NCIPresenceCheck(protocol); break; } }
private void NCIPresenceCheck(RFProtocolEnum protocol) { Packet cmd; Packet resp; DataPacket dataPacket; NotificationPacket notificationPacket; switch (protocol) { case RFProtocolEnum.PROT_T1T: cmd = new CorePresenceCheckDataRequest(PacketBoundryFlagEnum.CompleteMessageOrLastSegment, new byte[] { 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); resp = new CorePresenceCheckDataResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment, 0x00); do { Task.Delay(TimeSpan.FromMilliseconds(500)).Wait(); SendCommand(cmd, resp); try { dataPacket = WaitForDataPacket(100); } catch (TMLTimeoutException te) { break; //ok to timeout, means card was removed } } //while ((Answer[0] == 0x00) && (Answer[1] == 0x00)); while (dataPacket.MessageType == PacketTypeEnum.Data && dataPacket.PacketBoundryFlag == PacketBoundryFlagEnum.CompleteMessageOrLastSegment && dataPacket.ConnIdentifier == 0x00); //RFU (1) = 0x00); break; case RFProtocolEnum.PROT_T2T: cmd = new CorePresenceCheckDataRequest(PacketBoundryFlagEnum.CompleteMessageOrLastSegment, new byte[] { 0x30, 0x00 }); resp = new CorePresenceCheckDataResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment, 0x00); do { Task.Delay(TimeSpan.FromMilliseconds(500)).Wait(); SendCommand(cmd, resp); try { dataPacket = WaitForDataPacket(100); } catch (TMLTimeoutException te) { break; //ok to timeout, means card was removed } } // while ((Answer[0] == 0x00) && (Answer[1] == 0x00) && (Answer[2] == 0x11)); while (dataPacket.MessageType == PacketTypeEnum.Data && dataPacket.PacketBoundryFlag == PacketBoundryFlagEnum.CompleteMessageOrLastSegment && dataPacket.ConnIdentifier == 0x00 && //RFU (1) = 0x00 dataPacket.getPLL() == 0x11); break; case RFProtocolEnum.PROT_T3T: cmd = new RFT3TPollingCommand(PacketBoundryFlagEnum.CompleteMessageOrLastSegment); resp = new RFT3TPollingResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment); // { 0x12, 0xFC, 0x00, 0x01 }; ((RFT3TPollingCommand)cmd).SensFReqParams[0] = 0x12; ((RFT3TPollingCommand)cmd).SensFReqParams[1] = 0xFC; ((RFT3TPollingCommand)cmd).SensFReqParams[2] = 0x00; ((RFT3TPollingCommand)cmd).SensFReqParams[3] = 0x01; do { Task.Delay(TimeSpan.FromMilliseconds(500)).Wait(); SendCommand(cmd, resp); try { notificationPacket = WaitForNotification(100); } catch (TMLTimeoutException te) { break; //ok to timeout, means card was removed } } //while ((Answer[0] == 0x61) && (Answer[1] == 0x08) && (Answer[3] == 0x00)); while (notificationPacket.MessageType == PacketTypeEnum.ControlNotification && notificationPacket.PacketBoundryFlag == PacketBoundryFlagEnum.CompleteMessageOrLastSegment && notificationPacket.GroupIdentifier == GroupIdentifierEnum.RFMANAGEMENT && notificationPacket.OpcodeIdentifier == (byte)OpcodeRFIdentifierEnum.RF_T3T_POLLING_CMD && notificationPacket.getPLL() == 0x00); break; case RFProtocolEnum.PROT_ISODEP: cmd = new PresenceCheckISODepCommand(PacketBoundryFlagEnum.CompleteMessageOrLastSegment); resp = new PresenceCheckISODepResponse(PacketBoundryFlagEnum.CompleteMessageOrLastSegment); do { Task.Delay(TimeSpan.FromMilliseconds(500)).Wait(); SendCommand(cmd, resp); try { notificationPacket = WaitForNotification(100); } catch (TMLTimeoutException te) { break; //ok to timeout, means card was removed } } //while ((Answer[0] == 0x6F) && (Answer[1] == 0x11) && (Answer[2] == 0x01) && (Answer[3] == 0x01)); while (resp.MessageType == PacketTypeEnum.ControlNotification && resp.PacketBoundryFlag == PacketBoundryFlagEnum.CompleteMessageOrLastSegment && notificationPacket.GroupIdentifier == GroupIdentifierEnum.PROPRIETARY && notificationPacket.OpcodeIdentifier == (byte)OpcodeProprietaryExtensionsEnum.NCI_PROPRIETARY_ISO_DEP_CHECK_CMD && notificationPacket.getPLL() == 0x01 && notificationPacket.getPayLoad()[0] == 0x01); break; } }