Skip to content

Commit

Permalink
MF1_DETECT_SUPPORT: remove redundant data
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Sep 23, 2023
1 parent 867ee7b commit 941d425
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
8 changes: 2 additions & 6 deletions firmware/application/src/app_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,8 @@ static data_frame_tx_t *cmd_processor_hf14a_scan(uint16_t cmd, uint16_t status,
}

static data_frame_tx_t *cmd_processor_mf1_detect_support(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
uint8_t support;
status = check_std_mifare_nt_support((bool *)&support);
if (status != HF_TAG_OK) {
return data_frame_make(cmd, status, 0, NULL);
}
return data_frame_make(cmd, HF_TAG_OK, sizeof(support), &support);
status = check_std_mifare_nt_support();
return data_frame_make(cmd, status, 0, NULL);
}

static data_frame_tx_t *cmd_processor_mf1_detect_prng(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
Expand Down
11 changes: 3 additions & 8 deletions firmware/application/src/rfid/reader/hf/mf1_toolbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,21 +609,16 @@ uint8_t check_tag_response_nt(picc_14a_tag_t *tag, uint32_t *nt) {
* Lost card hf_tag_no and wrong status hf_errstat
*
*/
uint8_t check_std_mifare_nt_support(bool *support) {
uint8_t check_std_mifare_nt_support(void) {
uint32_t nt1 = 0;

// Find card, search on the field
if (pcd_14a_reader_scan_auto(p_tag_info) != HF_TAG_OK) {
return HF_TAG_NO;
}

// Get NT
uint8_t status = check_tag_response_nt(p_tag_info, &nt1);
if (status == HF_TAG_NO) {
return HF_TAG_NO;
}
*support = status == HF_TAG_OK;
return HF_TAG_OK;
// Get NT and return status
return check_tag_response_nt(p_tag_info, &nt1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/src/rfid/reader/hf/mf1_toolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint8_t nested_recover_key(NESTED_CORE_PARAM_DEF, mf1_nested_core_t ncs[SETS_NR]
uint8_t static_nested_recover_key(NESTED_CORE_PARAM_DEF, mf1_static_nested_core_t *sncs);

uint8_t check_prng_type(mf1_prng_type_t *type);
uint8_t check_std_mifare_nt_support(bool *support);
uint8_t check_std_mifare_nt_support();
void antenna_switch_delay(uint32_t delay_ms);
uint8_t auth_key_use_522_hw(uint8_t block, uint8_t type, uint8_t *key);

Expand Down
5 changes: 1 addition & 4 deletions software/script/chameleon_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,13 @@ def hf14a_scan(self):
resp.data = data
return resp

@expect_response(chameleon_status.Device.HF_TAG_OK)
def mf1_detect_support(self):
"""
Detect whether it is mifare classic tag
:return:
"""
resp = self.device.send_cmd_sync(DATA_CMD_MF1_DETECT_SUPPORT)
if resp.status == chameleon_status.Device.HF_TAG_OK:
resp.data, = struct.unpack('!?', resp.data)
return resp
return resp.status == chameleon_status.Device.HF_TAG_OK

@expect_response(chameleon_status.Device.HF_TAG_OK)
def mf1_detect_prng(self):
Expand Down

0 comments on commit 941d425

Please sign in to comment.