Search code examples
androidnfcmifarendef

Unable to read miFare NTAG216 after authentication using miFareSDK


I am using the MiFareSDK Lite given on the NXP site. I was about to do some basic stuff like reading the tag etc.

I was also able to password protect the tag with the following code.

byte[] passwd= new byte[] {(byte)0xe0,(byte)0x4f,(byte)0xd0,(byte)0x20};
byte[] packpwd= new byte[] {(byte)0xe0,(byte)0x4f}; 
inTag213215216.programPWDPack(passwd,packpwd);
inTag213215216.enablePasswordProtection(true,inTag213215216.getFirstUserpage());

After which in another session I call

inTag213215216.authenticatePwd(passwd,packpwd);
INdefMessage message =  inTag213215216.readNDEF();

But the read fails with exception, it was working previously without authentication. What should I do after authenticatePwd to read/write/resetpwd?


Solution

  • I finally figured out what the problem was, when you authenticate and then try to read the NFC tag when doing a line by line debug(using android studio) the read fails, hence do NOT try this on debug mode with line by line debug.