[FL-1920] Fix NTAG emulation (#776)

* mifare ultralight: fix read signature command
* nfc_worker: read signature before pages
This commit is contained in:
gornekich 2021-10-21 15:46:47 +03:00 committed by GitHub
parent 2751440193
commit af1fd0c46d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -509,6 +509,14 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) {
"Mifare Ultralight Type: %d, Pages: %d", "Mifare Ultralight Type: %d, Pages: %d",
mf_ul_read.type, mf_ul_read.type,
mf_ul_read.pages_to_read); mf_ul_read.pages_to_read);
FURI_LOG_I(NFC_WORKER_TAG, "Reading signature ...");
tx_len = mf_ul_prepare_read_signature(tx_buff);
if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) {
FURI_LOG_W(NFC_WORKER_TAG, "Failed reading signature");
memset(mf_ul_read.data.signature, 0, sizeof(mf_ul_read.data.signature));
} else {
mf_ul_parse_read_signature_response(rx_buff, &mf_ul_read);
}
} else if(err == ERR_TIMEOUT) { } else if(err == ERR_TIMEOUT) {
FURI_LOG_W( FURI_LOG_W(
NFC_WORKER_TAG, NFC_WORKER_TAG,
@ -540,15 +548,6 @@ void nfc_worker_read_mifare_ul(NfcWorker* nfc_worker) {
rx_buff, 0x00, mf_ul_read.pages_to_read - 1, &mf_ul_read); rx_buff, 0x00, mf_ul_read.pages_to_read - 1, &mf_ul_read);
} }
FURI_LOG_I(NFC_WORKER_TAG, "Reading signature ...");
tx_len = mf_ul_prepare_read_signature(tx_buff);
if(furi_hal_nfc_data_exchange(tx_buff, tx_len, &rx_buff, &rx_len, false)) {
FURI_LOG_W(NFC_WORKER_TAG, "Failed reading signature");
memset(mf_ul_read.data.signature, 0, sizeof(mf_ul_read.data.signature));
} else {
mf_ul_parse_read_signature_response(rx_buff, &mf_ul_read);
}
FURI_LOG_I(NFC_WORKER_TAG, "Reading 3 counters ..."); FURI_LOG_I(NFC_WORKER_TAG, "Reading 3 counters ...");
for(uint8_t i = 0; i < 3; i++) { for(uint8_t i = 0; i < 3; i++) {
tx_len = mf_ul_prepare_read_cnt(tx_buff, i); tx_len = mf_ul_prepare_read_cnt(tx_buff, i);

View File

@ -72,7 +72,7 @@ void mf_ul_parse_fast_read_response(uint8_t* buff, uint8_t start_page, uint8_t e
} }
uint16_t mf_ul_prepare_read_signature(uint8_t* dest) { uint16_t mf_ul_prepare_read_signature(uint8_t* dest) {
dest[0] = MF_UL_CHECK_TEARING; dest[0] = MF_UL_READ_SIG;
dest[1] = 0; dest[1] = 0;
return 2; return 2;
} }