[FL-2369] NFC refactoring (#1095)

* nfc: clean up scenes
* nfc worker: remove field on from worker
* nfc worker: move full data exchange to furi hal
* nfc_device: check UID length
* nfc protocol: introduce mifare common API
* nfc: move common data to furi hal nfc
* nfc: rename emv_decoder -> emv
* nfc: move emv data structure to emv lib
* nfc: remove deactivate after detection
* nfc: rework furi hal nfc detect
* nfc: clean up CLI commands and type
* nfc: remove unused includes and function
* nfc: add TxRxType enum
* nfc: read mifare ultralight refactoring
* nfc: refactore mifare ultralight start
* rfal: fix custom data exchange
* nfc: refactor read bank card
* nfc: refactor read emv application
* nfc: refactor emv test emulation
* nfc: refactor uid emulation
* nfc: add limit to uid emulation logger
* fix source formatting
* furi_hal_nfc: fix data exchange full
* nfc: fix mifare ultralight type load

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2022-04-19 18:23:58 +03:00
committed by GitHub
parent e55d1572da
commit 956788c09b
58 changed files with 1349 additions and 1601 deletions

View File

@@ -7,13 +7,15 @@ void nfc_scene_read_card_success_widget_callback(
void* context) {
furi_assert(context);
Nfc* nfc = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
}
}
void nfc_scene_read_card_success_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
Nfc* nfc = context;
string_t data_str;
string_t uid_str;
string_init(data_str);
@@ -24,9 +26,9 @@ void nfc_scene_read_card_success_on_enter(void* context) {
notification_message(nfc->notifications, &sequence_success);
// Setup view
NfcDeviceCommonData* data = &nfc->dev->dev_data.nfc_data;
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
Widget* widget = nfc->widget;
string_set_str(data_str, nfc_get_dev_type(data->device));
string_set_str(data_str, nfc_get_dev_type(data->type));
string_set_str(uid_str, "UID:");
for(uint8_t i = 0; i < data->uid_len; i++) {
string_cat_printf(uid_str, " %02X", data->uid[i]);
@@ -34,7 +36,7 @@ void nfc_scene_read_card_success_on_enter(void* context) {
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_card_success_widget_callback, nfc);
if(data->device == NfcDeviceNfca) {
if(data->type == FuriHalNfcTypeA) {
widget_add_button_element(
widget, GuiButtonTypeRight, "More", nfc_scene_read_card_success_widget_callback, nfc);
widget_add_icon_element(widget, 8, 13, &I_Medium_chip_22x21);
@@ -44,7 +46,7 @@ void nfc_scene_read_card_success_on_enter(void* context) {
string_printf(
data_str,
"%s\nATQA: %02X%02X SAK: %02X",
nfc_guess_protocol(data->protocol),
nfc_guess_protocol(nfc->dev->dev_data.protocol),
data->atqa[0],
data->atqa[1],
data->sak);
@@ -66,14 +68,14 @@ void nfc_scene_read_card_success_on_enter(void* context) {
}
bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
NfcDeviceCommonData* data = &nfc->dev->dev_data.nfc_data;
Nfc* nfc = context;
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc->scene_manager);
} else if(data->device == NfcDeviceNfca && event.event == GuiButtonTypeRight) {
} else if(data->type == FuriHalNfcTypeA && event.event == GuiButtonTypeRight) {
// Clear device name
nfc_device_set_name(nfc->dev, "");
scene_manager_next_scene(nfc->scene_manager, NfcSceneCardMenu);
@@ -84,6 +86,8 @@ bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event
}
void nfc_scene_read_card_success_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
Nfc* nfc = context;
// Clear view
widget_reset(nfc->widget);
}