Lucy Lee
Lucy Lee

Reputation: 31

NFC Mifare Ultralight C authentication timeout using Android

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.

Upvotes: 1

Views: 1441

Answers (1)

NFC guy
NFC guy

Reputation: 10228

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.)

Upvotes: 2

Related Questions