我正在使用NFCA.transceive
写入 NTAG213 并且可以成功写入位置 28h,当标签为空时,该位置持有动态锁而不会出现任何问题。但是当我尝试将其写回默认状态时,我得到一个 TAG_LOST 异常。所有其他字段都可以重置,例如密码、AUTH0 等。
在规范中说 NTAG213 具有对特定内存内容的“撕裂”受保护的写操作,并提到 28h。这和它有关系吗?我不明白“撕裂”这个词。
我应该提到,在我更新之前,我使用了身份验证,这必须工作正常,因为除了这个页面/位置之外的所有内容都会变回来。我玩弄了写顺序没有效果。
相关代码:
public String resetBDtag(Tag tag) {
NfcA nfca = NfcA.get(tag);
String resultString = "";
byte[] result;
try {
nfca.connect();
try {
result = nfca.transceive(new byte[]{
(byte)0x1B, // Command: password Auth
(byte)0x93, (byte)0xD0, (byte)0x55, (byte)0xB7
});} catch (IOException e) {
Log.e(TAG, "IOException while authenticating :" + resultString, e );
resultString = "Error authenticating"+ e.toString();
}
try {
result = nfca.transceive(new byte[]{
(byte) 0xA2, // Command: WRITE
(byte) 0x29, // Address: page 0x29 (2)
(byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0xFF // CF
});
} catch (IOException e) {
Log.e(TAG, "IOException while resting Auth0 requirement :" + resultString, e );
resultString = "Error removing Authentication requirement"+ e.toString();;
}
try {
result = nfca.transceive(new byte[]{
(byte) 0xA2, // Command: WRITE
(byte) 0x2B, // Address: page 0x2B (2)
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF // Password
});
} catch (IOException e) {
Log.e(TAG, "IOException while clearing password :" + resultString, e );
resultString = "Error clearing password"+ e.toString();;
}
try {
result = nfca.transceive(new byte[]{
(byte) 0xA2, // Command: WRITE
(byte) 0x10, // Address: page 0x10 (2)
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 // Status / Count
});
} catch (IOException e) {
Log.e(TAG, "IOException while clearing the status data :" + resultString, e );
resultString = "Error clearing status data"+ e.toString();;
}
try {
// This does not work!
result = nfca.transceive(new byte[]{
(byte) 0xA2, // Command: WRITE
(byte) 0x28, // CFG1
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xBD // reset CFG1
});
} catch (IOException e) {
Log.e(TAG, "IOException while removing locked pages 18-19 :" + resultString, e );
resultString = "Error removing locks"+ e.toString();;
}
} catch (IOException e) {
Log.e(TAG, "IOException while writing MifareUltralight :" + resultString, e );
resultString = "Can not speak to the tag!";
} finally {
if (nfca != null) {
try {
nfca.close();
Log.d("finally","isoDep closed");
}
catch (IOException e) {
Log.e(TAG, "Error closing tag...", e);
resultString = "Can not close the connection to the tag!";
}
}
}
return resultString;
}