Reply To: Problem authenticating a MIFARE Ultralight EV1 tag

Forum MIFARE SDK Problem authenticating a MIFARE Ultralight EV1 tag Reply To: Problem authenticating a MIFARE Ultralight EV1 tag

Re: Problem authenticating a MIFARE Ultralight EV1 tag

10. February 2017 at 13:55
Hi Zhaoyu,

the code I had had since before I asked the question is something along this lines:


try {
// Connect to the tag
IUltralightEV1 ultralightEV1 = ...

try {
// Try to authenticate
ultralightEV1.authenticatePwd(myKey);
}
catch(NxpNfcLibException e) {
if(e.getMessage().equals("Tag was lost")) {
// It is likely, but in no way sure, that this is an authentication error so handle it like one.
// For this to be acceptable you need to use a really small timeout to make it unlikely that the user removes the tag while this command is running.
handleAuthenticationError();
}
}
}
catch(NxpNfcLibException e) {
// Handle other errors including the user removed the tag
}


This is of course an ugly workaround and I was hoping to find a better solution, especially since there is still the possibility to confuse an error caused by a wrong password with an error caused by losing the tag, but it seems this is the best we can do. Do note that this workaround just makes it more unlikely to confuse those errors since we are limiting the possible confusion to the authenticatePwd instruction and we are using a small timeout to force this instruction to end as fast as possible, but it is still possible to confuse these two errors when removing the tag just at the right moment.

Do note however that, if the taplinx team is right, there is nothing we can do to tell them apart. The hardware behaves in exactly the same way in these two cases so there is nothing we can do. Out of curiosity, I will implement this command using the android native NFC API when I have some free time to see if these two scenarios have the same behavior in hardware, but I don’t expect to find anything different to what the taplinx team said.

Regards
Jorge Sanmiguel
+ 0  |  - 0