[FL-2714] New NFC info screens (#1605)
* nfc: add scroll element for info * widget: format lines for scroll text element * widget: fix new line generation * widget: finish element text scroll * nfc: rework ultralight and NTAG info scenes * nfc: rework mf classic info screens * nfc: rework nfca info scenes * nfc: fix mf ultralight navigation * widget: add documentation * nfc: rework bank card infO * nfc: rework device info scene * nfc: fix incorrect atqa order * mf ultralight: remove unused function * widget: add mutex for model protection * widget: fix memory leak * nfc: rework delete scene * nfc: fix selected item in saved menu scene * widget: fix naming in text scroll element * nfc: fix navigation from delete success * nfc: add dictionary icon * widget: fix memory leak
This commit is contained in:
@@ -11,3 +11,17 @@ NfcSupportedCard nfc_supported_card[NfcSupportedCardTypeEnd] = {
|
||||
.parse = troyka_parser_parse,
|
||||
},
|
||||
};
|
||||
|
||||
bool nfc_supported_card_verify_and_parse(NfcDeviceData* dev_data) {
|
||||
furi_assert(dev_data);
|
||||
|
||||
bool card_parsed = false;
|
||||
for(size_t i = 0; i < COUNT_OF(nfc_supported_card); i++) {
|
||||
if(nfc_supported_card[i].parse(dev_data)) {
|
||||
card_parsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return card_parsed;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <furi_hal_nfc.h>
|
||||
#include "../nfc_worker.h"
|
||||
#include "../nfc_device.h"
|
||||
|
||||
#include <m-string.h>
|
||||
|
||||
@@ -15,7 +16,7 @@ typedef bool (*NfcSupportedCardVerify)(NfcWorker* nfc_worker, FuriHalNfcTxRxCont
|
||||
|
||||
typedef bool (*NfcSupportedCardRead)(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx);
|
||||
|
||||
typedef bool (*NfcSupportedCardParse)(NfcWorker* nfc_worker);
|
||||
typedef bool (*NfcSupportedCardParse)(NfcDeviceData* dev_data);
|
||||
|
||||
typedef struct {
|
||||
NfcProtocol protocol;
|
||||
@@ -25,3 +26,5 @@ typedef struct {
|
||||
} NfcSupportedCard;
|
||||
|
||||
extern NfcSupportedCard nfc_supported_card[NfcSupportedCardTypeEnd];
|
||||
|
||||
bool nfc_supported_card_verify_and_parse(NfcDeviceData* dev_data);
|
||||
|
@@ -49,23 +49,31 @@ bool troyka_parser_read(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx) {
|
||||
return mf_classic_read_card(tx_rx, &reader, &nfc_worker->dev_data->mf_classic_data) == 16;
|
||||
}
|
||||
|
||||
bool troyka_parser_parse(NfcWorker* nfc_worker) {
|
||||
MfClassicData* data = &nfc_worker->dev_data->mf_classic_data;
|
||||
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
|
||||
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25;
|
||||
temp_ptr = &data->block[8 * 4].value[3];
|
||||
uint32_t number = 0;
|
||||
for(size_t i = 0; i < 4; i++) {
|
||||
number <<= 8;
|
||||
number |= temp_ptr[i];
|
||||
}
|
||||
number >>= 4;
|
||||
bool troyka_parser_parse(NfcDeviceData* dev_data) {
|
||||
MfClassicData* data = &dev_data->mf_classic_data;
|
||||
bool troyka_parsed = false;
|
||||
|
||||
string_printf(
|
||||
nfc_worker->dev_data->parsed_data,
|
||||
"Troyka Transport card\nNumber: %ld\nBalance: %d rub",
|
||||
number,
|
||||
balance);
|
||||
do {
|
||||
// Verify key
|
||||
MfClassicSectorTrailer* sec_tr = mf_classic_get_sector_trailer_by_sector(data, 8);
|
||||
uint64_t key = nfc_util_bytes2num(sec_tr->key_a, 6);
|
||||
if(key != troyka_keys[8].key_a) break;
|
||||
|
||||
return true;
|
||||
// Parse data
|
||||
uint8_t* temp_ptr = &data->block[8 * 4 + 1].value[5];
|
||||
uint16_t balance = ((temp_ptr[0] << 8) | temp_ptr[1]) / 25;
|
||||
temp_ptr = &data->block[8 * 4].value[3];
|
||||
uint32_t number = 0;
|
||||
for(size_t i = 0; i < 4; i++) {
|
||||
number <<= 8;
|
||||
number |= temp_ptr[i];
|
||||
}
|
||||
number >>= 4;
|
||||
|
||||
string_printf(
|
||||
dev_data->parsed_data, "\e#Troyka\nNum: %ld\nBalance: %d rur.", number, balance);
|
||||
troyka_parsed = true;
|
||||
} while(false);
|
||||
|
||||
return troyka_parsed;
|
||||
}
|
||||
|
@@ -6,4 +6,4 @@ bool troyka_parser_verify(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx);
|
||||
|
||||
bool troyka_parser_read(NfcWorker* nfc_worker, FuriHalNfcTxRxContext* tx_rx);
|
||||
|
||||
bool troyka_parser_parse(NfcWorker* nfc_worker);
|
||||
bool troyka_parser_parse(NfcDeviceData* dev_data);
|
||||
|
Reference in New Issue
Block a user