Merge pull request #274 from unkernet/acl

Fix state machine behavior and access bits verification in MF1 emulation
This commit is contained in:
GameTec-live
2026-07-04 13:14:59 +02:00
committed by GitHub
6 changed files with 260 additions and 105 deletions
+1
View File
@@ -24,6 +24,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Fix Windows build (@suut)
- Added `hf 14a config` to deal with badly configured cards (@azuwis)
- New Symmetrical LED Animation Mode and Improved Minimal Mode (@WillyJL)
- Fix MF1 state reset logic and access control conditions (@unkernet)
## [v2.1.0][2025-09-02]
- Added UV, formatter and linter. Contribution guidelines. (@GameTec-live)
@@ -377,6 +377,11 @@ void nfc_tag_14a_data_process(uint8_t *p_data) {
// The trigger conditions are: REQA response in non -Halt mode
// Temporary through: Wupa response in non -choice state, no matter what state is in the state, you can use the Wupa instruction to wake up
if ((szDataBits == 7) && ((isREQA && m_tag_state_14a != NFC_TAG_STATE_14A_HALTED) || isWUPA)) {
// Received 7-bit command (REQA or WUPA) while the tag is active — reset state machine
if (m_tag_state_14a != NFC_TAG_STATE_14A_IDLE && m_tag_state_14a != NFC_TAG_STATE_14A_HALTED) {
m_tag_state_14a = NFC_TAG_STATE_14A_IDLE;
return;
}
// The receiver of the 14A communication is notified, the internal state machine is reset
if (m_tag_handler.cb_reset != NULL) {
m_tag_handler.cb_reset();
@@ -576,8 +581,16 @@ void nfc_tag_14a_data_process(uint8_t *p_data) {
// No processing is successful, it may be some other data. You need to re-post processing
if (m_tag_handler.cb_state != NULL) { //Activation status, transfer the message to other registered processor processing
m_tag_handler.cb_state(p_data, szDataBits);
break;
}
break;
}
case NFC_TAG_STATE_14A_PROPRIETARY: {
if (m_tag_handler.cb_state != NULL) {
m_tag_handler.cb_state(p_data, szDataBits);
} else {
m_tag_state_14a = NFC_TAG_STATE_14A_IDLE;
}
break;
}
}
}
@@ -36,10 +36,11 @@
// ISO14443-A Universal state machine
typedef enum {
NFC_TAG_STATE_14A_IDLE, // Leisure, you can wait for any instructions
NFC_TAG_STATE_14A_READY, // Select card status, currently the standard 14A anti -rushing collision
NFC_TAG_STATE_14A_ACTIVE, // Select cards or other instructions to enter the working status, which can receive all data
NFC_TAG_STATE_14A_HALTED, // The label stops working status and can only be awakened by Halt or other special instructions (non -labels)
NFC_TAG_STATE_14A_IDLE, // Leisure, you can wait for any instructions
NFC_TAG_STATE_14A_READY, // Select card status, currently the standard 14A anti -rushing collision
NFC_TAG_STATE_14A_ACTIVE, // Select cards or other instructions to enter the working status, which can receive all data
NFC_TAG_STATE_14A_HALTED, // The label stops working status and can only be awakened by Halt or other special instructions (non -labels)
NFC_TAG_STATE_14A_PROPRIETARY, // Card is in proprietary state; all commands handled only by state_handler
} nfc_tag_14a_state_t;
// UID of the length in the enumeration specification
File diff suppressed because it is too large Load Diff
@@ -149,6 +149,7 @@ typedef struct {
nfc_tag_mf1_auth_log_t *mf1_get_auth_log(uint32_t *count);
void nfc_tag_mf1_reset_handler();
int nfc_tag_mf1_data_loadcb(tag_specific_type_t type, tag_data_buffer_t *buffer);
int nfc_tag_mf1_data_savecb(tag_specific_type_t type, tag_data_buffer_t *buffer);
bool nfc_tag_mf1_data_factory(uint8_t slot, tag_specific_type_t tag_type);
+3
View File
@@ -287,6 +287,9 @@ void rgb_marquee_slot_switch(uint8_t led_down, uint8_t color_led_down, uint8_t l
light_level --;
}
}
for (uint8_t i = 0; i < RGB_LIST_NUM; i++) {
nrf_gpio_pin_clear(led_pins[i]);
}
if (led_up >= 0 && led_up <= 7) {
//Treatment
pwm_config.output_pins[0] = led_pins[led_up];