1

I am trying to follow the steps and authenticate an Mifare Ultralight C tag using Android phone (Samsung Galaxy Nexus). The authentication works fine if there is no delay in between the steps. But if there is a delay, for example, wait for 200ms before the response message, an IOException is thrown.

I tried the setTimeout method provided by Android API, but it doesn't seem to make a difference.

I don't think it is the Tag problem, as I can authenticate it using a different reader connected to my Macbook, even with some delays. (Actually I was able to step through the code and the tag didn't complain).

Is this an Android API limitation? Any workarounds? Does the setTimeout method supposed to be used in this case? I suspect I might use the method incorrectly.

Thanks in advance.

Lucy Lee
  • 31
  • 4

1 Answers1

2

Whenever you are not communicating with a tag, Android will continuously check for the presence of the tag. How it does that depends on the tag's technology (NfcA/B/F/V or IsoDep), but in case of a MIFARE Ultralight, this will be done by re-selecting the tag. This essentially resets it, so any authentication context will be lost and the tag will not be able to continue with the authentication.

This behaviour is quite different form what a typical desktop reader would do. So you need to be aware of this in cases such as this. The best thing to do is to prevent the automatic presence checking from starting by continuously communicating with the tag. (Presence checking will also start when you single-step through your code in the debugger, BTW.)

NFC guy
  • 10,151
  • 3
  • 27
  • 58
  • Thanks for the response. Do you mean there is no workaround if I have to introduce some delay in the authentication steps? – Lucy Lee Oct 09 '12 at 20:44
  • I don't think `setTimeout()` helps here, because the tag will have answered before a time-out has occurred. I am not aware of any Ultralight or NfcA commands that could be sent right in the middle of an authentication while not affecting the tag's state. You should not have this problem with e.g. MIFARE DESfire, because the `IsoDep` presence check is an ISO 14443-4 "R(NAK)" message, which does not influence the tag's state (I have not tested this, though). – NFC guy Oct 09 '12 at 20:53
  • @NFC guy: Dear NFC guy, could you please look at my question: http://stackoverflow.com/questions/18824879/mifare-authentication. You seem to be quite competent in this area, and not many people looked at my question so far.. Thank you. –  Sep 16 '13 at 10:17