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
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!
-----------------------------------------------------------------------------------------------------------------------