0

I am currently developing an NFC application for a very, very customized Linux kernel running in a POS device such as this TPS300 for contact-less NFC cards. It has inbuilt libraries for communicating with NFC cards. I have researched on NFC and have learnt about the NFC reset command, which is supposed to respond with an Answer to Reset. My question is, is that command carried out via the normal APDU command-respond method or is the reset a hardware-based command? Am asking this because the libraries mentioned above have no explicit reset command method for cards, or a program either, and I (up to this moment) have found no APDU command for resetting the NFC card. I only know of the hardware method, via a signal to the reset terminal of the NFC card. Is there an explicit APDU command for resetting the card or does the customized OS take care of the resetting for me? If the command exists, what is it? And how is it applied to contact-less NFC cards?

Peter
  • 648
  • 7
  • 26

2 Answers2

0

In general, switching OFF the RF field and switching it ON should 'reset' the card. But, if you want more specific reset mechanism, then that will depend on the type of card supported in the OS, and the card in question. ISO14443-Part3 should help you out there.

Joseph
  • 261
  • 2
  • 7
  • While switching the field off and on again surely does the job, this is quite a big hammer affecting all cards currently in the field. I remember some standardization discussion, that the pair deselect/reselect is considered sufficient, but due to my knowledge this is not yet standardized, which is somewhat difficult, since a general solution would require changes beyond ISO 14443, e. g. ISO 15693 and 18092 too. – guidot Oct 31 '14 at 15:12
  • Thanks to all the replies. I have been able to apply the answer by grundyoso to what I am doing andit has helped, like ALOT!!! – Peter Nov 04 '14 at 07:20
0

The ATR (Answer to Reset) is typically sought by issuing special commands to the NFC controller (reader). APDU is a term that's used to refer to command/response exchanges with the NFC card itself (PICC). To give you something to compare against check out the documentation of the ACR122U, one of the popular USB readers on the market. It leverages a PCSC USB driver (CCID) that's common to most operating systems (evolved from interfacing with Smart Card controllers) which makes it easy to use on Windows, Mac, or Linux. Here's a flowchart of it:

Communication flowchart of ACR122U

The PCSC interface has several commands, but it all starts with a reader API connect. For contact Smart Cards, this equates to setting a RESET line high. For contactless (NFC) cards, this equates to turning on the NFC field (RF energy pulse). If there is a card present, the connect call will return an ATR response.

Looking beneath the PCSC layer and into the CCID driver, you can see how the reader API connect call is constructed. Here's a snippet of code from the nfcpy project, an open source stack for NFC:

def reset_mode(self):
    if (self.ic, self.fw) == ("PN533", "1.48"):
        self.command(0x18, [1])
        self.write(array("B", [0, 0, 255, 0, 255, 0])) # ack
        time.sleep(0.010)

The PN533 is the NFC controller (from NXP) inside the ACR122U reader. Command 0x18 instructs the NFC controller to turn on the RF field and attempt to get an ATR response from any tag present. Once an ATR is found, then APDU exchanges can begin. Such as interrogating the card for its description info:

 rsp = self.dev.in_list_passive_target("106A", "");  // for NFC-A type cards

So to answer your questions explicitly:

  1. Is there an explicit APDU command for resetting the card or does the customized OS take care of the resetting for me? - In the case of PCSC, this is a reader API connect call. Talking directly to the NFC controller, there might be an instruction to do this like the in_list_passive_target command for the PN533.
  2. If the command exists, what is it? - Search through the Linux setup in your POS and see if there's a CCID driver or PCSC daemon running. If not, you'll need to find what driver is being used to talk to the POS NFC controller. With that you should be able to determine the equivalent command to power on the RF field.
  3. And how is it applied to contact-less NFC cards? - There are many types of NFC cards but getting an ATR is common across them all.
grundyoso
  • 2,329
  • 1
  • 15
  • 13
  • Your answer is a bit blurry in the distinction of a command APDU and an API call like *connect* or even controller register modification. To get this clear: there is no command APDU for reset, since this is no service delivered by the card, but an action the addressed reader has to initiate. – guidot Oct 31 '14 at 15:19
  • Thanks!!! This has helped quite alot. And, as a BTW, how do you close a question as answered? – Peter Nov 04 '14 at 07:21
  • @Peter: You change the status of the question (closing is a different process for invalid questions) by accepting one of the answers (which receives a green tick mark). – guidot Nov 04 '14 at 09:52