NTAG213 PWD_AUTH Android problem.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NTAG213 PWD_AUTH Android problem.

2,370 Views
dejancencelj
Contributor I

Hello!

I tried to implement password lock protection in my Android app. I was able to set the password and set the AUTH0 byte to 0.

But I'm not able to authenticate the tag. I always get Tag was lost exception. I tried both Android NfcA and MirafeUltralight from Android SDK... and got same result.

Code bellow is how I try to autheticate

   Tag tag = savedIntent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

   NfcNtag nfca = NfcNtag.get(tag);


   try {
     nfca.connect();
    
     byte[] pin = new byte[4];

     pin[0] = 97;
     pin[1] = 97;
     pin[2] = 97;
     pin[3] = 97;
     byte[] response = nfca.pwdAuth(pin);

   } catch (IOException e) {
     e.printStackTrace();
   }finally {
     if (nfca != null) {
       try {
         nfca.close();
       }
       catch (IOException e) {
         Log.e(TAG, "Error closing tag...", e);
       }
     }
   }

  public byte[] pwdAuth(byte[] password) {

    if (password == null) {
        return null;
    }
    if (password.length != 4) {
        return null;
    }

    byte[] req = new byte[5];
    byte[] resp;

    req[0] = NfcNtagOpcode.PWD_AUTH; //0x2B

    try {
        System.arraycopy(password, 0, req, 1, 4);
        resp = nfca.transceive(req);
    } catch (IOException ex) {
        ex.printStackTrace(); //Allways ends here
        resp = null;
    }
    return resp; // result will be the PACK
}

I used code from bellow

smartrac-sdk-java-android-nfc/NfcNtag.java at master · SMARTRACTECHNOLOGY-PUBLIC/smartrac-sdk-java-a... 

0 Kudos
Reply
1 Reply

1,433 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Dejan,

     According to your description, it seems that there is someting wrong with communications between NFC reader chip and NTAG, So suggest you should ask hardware engineer to check antenna circuits.


Have a great day,
TIC  Weidong sun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply