有没有可靠的方法来确定RFID卡是Mifare Ultralight还是Mifare Ultralight C?区分Mifare Ultralight与Mifare Ultralight C
到目前为止,我发现的唯一方法是利用这两张卡的大小差异来发出一个读取命令超出较小的边界。 但它看起来像一个黑客,我假设如果卡使用Ultralight C身份验证机制读取命令可能会失败。
const char* mifare_ultralight_identification(const nfc_target_info_t nti)
{
byte_t abtCmd[2];
byte_t abtRx[265];
size_t szRxLen;
abtCmd[0] = 0x30; // MIFARE Ultralight READ command
abtCmd[1] = 0x10; // block address (1K=0x00..0x39, 4K=0x00..0xff)
if (!nfc_initiator_transceive_dep_bytes(pnd,abtCmd,2,abtRx,&szRxLen)) {
// READ command of 0x10 failed, we consider that Ultralight does have 0x10 address, so it's a "simple" Ultralight (i.e. not a Ultralight C)
// When a READ failed, the tag returns in HALT state, so we need to reselect tag
nfc_initiator_select_passive_target(pnd, NM_ISO14443A_106, nti.nai.abtUid, nti.nai.szUidLen, NULL);
return "";
}
return " C";
}
这也是我的第二个想法。但是,使用其中一个不存在的命令仍然是一种解决方法。但似乎没有干净的方式来做到这一点。 – mibollma 2012-08-10 11:12:58
是的,这是最简单可靠的方法。 – 2012-08-10 12:27:38