gpt4 book ai didi

Android:在 NFC NTAG213 上重置动态锁时出错(28 小时)

转载 作者:行者123 更新时间:2023-11-29 20:32:37 25 4
gpt4 key购买 nike

我正在使用 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;
}

最佳答案

关于动态锁定位的写命令

您尝试写入字节 3(即字节 3 在您的写入命令中的值不是 0x00)。你不应该那样做。数据表明确指出您应该将所有 RFUI 位设置为 0(这适用于字节 3,以及字节 1 和 2 中的某些位)。

写命令如何用于一次性可编程内存区域,如动态锁定位

写命令将在页面的当前值和写命令参数中发送的新值之间进行逻辑或。例如,如果页面当前设置为 FF 0F 00 BD 而您尝试写入 00 00 3F 00,则页面的新值将为 FF 0F 3F BD。因此,您只能在动态锁定位中设置位(= 设置为 1),但您不能永远将它们重置为零。

为什么你的写命令失败

您在写入命令中将 RFUI 字节(字节 3)设置为 0xBD。这是不允许的。

什么是“撕裂”保护?

撕裂是指您在写入操作期间(无意或有意)从阅读器上移除标签。写入期间的这种删除可能会导致页面的部分写入,这会使内存处于未定义状态。撕裂保护意味着标签要么完全完成写入,要么根本不执行写入。因此,内存不会进入任何意外状态。

关于Android:在 NFC NTAG213 上重置动态锁时出错(28 小时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31734059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com