From 38ca2aa1625bde869ecea2b90148aaa4a8823d11 Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Thu, 21 Jul 2022 10:32:00 -0600 Subject: [PATCH 1/2] nfc: Remove unnecessary init in MFUL emulation --- lib/nfc_protocols/mifare_ultralight.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/nfc_protocols/mifare_ultralight.c b/lib/nfc_protocols/mifare_ultralight.c index 3320f2dd162..102dc767c9e 100644 --- a/lib/nfc_protocols/mifare_ultralight.c +++ b/lib/nfc_protocols/mifare_ultralight.c @@ -1173,10 +1173,6 @@ void mf_ul_prepare_emulation(MfUltralightEmulator* emulator, MfUltralightData* d emulator->data_changed = false; emulator->comp_write_cmd_started = false; emulator->sector_select_cmd_started = false; - if(emulator->data.type == MfUltralightTypeNTAG203) { - // Clear holding counter - emulator->data.counter[0] = 0; - } mf_ul_reset_emulation(emulator, true); } From 3a0cb876277f430241ccec9fa7da79b4995f341d Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Thu, 21 Jul 2022 10:38:53 -0600 Subject: [PATCH 2/2] nfc: Add notes about MFUL type enum --- lib/nfc_protocols/mifare_ultralight.c | 3 +-- lib/nfc_protocols/mifare_ultralight.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/nfc_protocols/mifare_ultralight.c b/lib/nfc_protocols/mifare_ultralight.c index 102dc767c9e..9dcd1d6aacb 100644 --- a/lib/nfc_protocols/mifare_ultralight.c +++ b/lib/nfc_protocols/mifare_ultralight.c @@ -1235,8 +1235,7 @@ bool mf_ul_prepare_emulation_response( } else if(buff_rx_len >= 8) { uint8_t cmd = buff_rx[0]; if(cmd == MF_UL_GET_VERSION_CMD) { - if(emulator->data.type != MfUltralightTypeUnknown && - emulator->data.type != MfUltralightTypeNTAG203) { + if(emulator->data.type >= MfUltralightTypeUL11) { if(buff_rx_len == 1 * 8) { tx_bytes = sizeof(emulator->data.version); memcpy(buff_tx, &emulator->data.version, tx_bytes); diff --git a/lib/nfc_protocols/mifare_ultralight.h b/lib/nfc_protocols/mifare_ultralight.h index 2f6251bdabd..77dbd1e4e71 100644 --- a/lib/nfc_protocols/mifare_ultralight.h +++ b/lib/nfc_protocols/mifare_ultralight.h @@ -28,16 +28,21 @@ #define MF_UL_NTAG203_COUNTER_PAGE (41) +// Important: order matters; some features are based on positioning in this enum typedef enum { MfUltralightTypeUnknown, MfUltralightTypeNTAG203, + // Below have config pages and GET_VERSION support MfUltralightTypeUL11, MfUltralightTypeUL21, MfUltralightTypeNTAG213, MfUltralightTypeNTAG215, MfUltralightTypeNTAG216, + // Below also have sector select + // NTAG I2C's *does not* have regular config pages, so it's a bit of an odd duck MfUltralightTypeNTAGI2C1K, MfUltralightTypeNTAGI2C2K, + // NTAG I2C Plus has stucture expected from NTAG21x MfUltralightTypeNTAGI2CPlus1K, MfUltralightTypeNTAGI2CPlus2K,