[FL-1723, FL-1662, FL-1870] NFC bug fixes (#745)
* nfc: fix notifications in read EMV sequence * nfc: set focus on previously saved card * nfc: add incorrect file format message * mifare ultralight: increase size of max dump * elements: draw multiline text only until it fits screen * nfc: support variable PAN number length * nfc: change AID display * nfc: change worker custom event to prevent scene reenter * nfc: double check for PAN tag * nfc: fix edit card name appearance * Nfc: read EMV card without name if PDOL is present. * Desktop: increase unlock key press interval, switch to OS ticks instead of HAL. * Desktop: remove debug logging Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -111,7 +111,7 @@ void nfc_scene_device_info_on_enter(void* context) {
|
||||
NfcEmvData* emv_data = &nfc->dev.dev_data.emv_data;
|
||||
BankCard* bank_card = nfc->bank_card;
|
||||
bank_card_set_name(bank_card, emv_data->name);
|
||||
bank_card_set_number(bank_card, emv_data->number);
|
||||
bank_card_set_number(bank_card, emv_data->number, emv_data->number_len);
|
||||
bank_card_set_back_callback(bank_card, nfc_scene_device_info_bank_card_callback, nfc);
|
||||
if(emv_data->exp_mon) {
|
||||
bank_card_set_exp_date(bank_card, emv_data->exp_mon, emv_data->exp_year);
|
||||
|
@@ -33,6 +33,8 @@ bool nfc_scene_mifare_ul_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneMifareUlMenu, SubmenuIndexSave);
|
||||
nfc->dev.format = NfcDeviceSaveFormatMifareUl;
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEmulate) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define NFC_READ_CARD_CUSTOM_EVENT (0UL)
|
||||
#define NFC_READ_CARD_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_card_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
@@ -11,9 +11,6 @@ void nfc_scene_read_card_success_dialog_callback(DialogExResult result, void* co
|
||||
void nfc_scene_read_card_success_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
|
||||
// Send notification
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
|
||||
@@ -70,6 +67,8 @@ bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event
|
||||
if(event.event == DialogExResultLeft) {
|
||||
return scene_manager_previous_scene(nfc->scene_manager);
|
||||
} else if(event.event == DialogExResultRight) {
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneCardMenu);
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define NFC_READ_EMV_APP_CUSTOM_EVENT (0UL)
|
||||
#define NFC_READ_EMV_APP_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_emv_app_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
@@ -30,6 +30,8 @@ bool nfc_scene_read_emv_app_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_EMV_APP_CUSTOM_EVENT) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
|
||||
return true;
|
||||
}
|
||||
|
@@ -26,12 +26,13 @@ void nfc_scene_read_emv_app_success_on_enter(void* context) {
|
||||
bool aid_found = nfc_emv_parser_get_aid_name(emv_data->aid, emv_data->aid_len, aid);
|
||||
if(!aid_found) {
|
||||
for(uint8_t i = 0; i < emv_data->aid_len; i++) {
|
||||
string_cat_printf(aid, " %02X", emv_data->aid[i]);
|
||||
string_cat_printf(aid, "%02X", emv_data->aid[i]);
|
||||
}
|
||||
}
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
NFC_SCENE_READ_SUCCESS_SHIFT "UID: %02X %02X %02X %02X \n\n%s",
|
||||
NFC_SCENE_READ_SUCCESS_SHIFT "UID: %02X %02X %02X %02X \n" NFC_SCENE_READ_SUCCESS_SHIFT
|
||||
"Application:\n%s",
|
||||
nfc_data->uid[0],
|
||||
nfc_data->uid[1],
|
||||
nfc_data->uid[2],
|
||||
@@ -42,6 +43,14 @@ void nfc_scene_read_emv_app_success_on_enter(void* context) {
|
||||
dialog_ex_set_context(dialog_ex, nfc);
|
||||
dialog_ex_set_result_callback(dialog_ex, nfc_scene_read_emv_app_success_dialog_callback);
|
||||
|
||||
// Send notification
|
||||
if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadEmvAppSuccess) ==
|
||||
NFC_SEND_NOTIFICATION_TRUE) {
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_FALSE);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
|
||||
}
|
||||
|
||||
|
7
applications/nfc/scenes/nfc_scene_read_emv_data.c
Normal file → Executable file
7
applications/nfc/scenes/nfc_scene_read_emv_data.c
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define NFC_READ_EMV_DATA_CUSTOM_EVENT (0UL)
|
||||
#define NFC_READ_EMV_DATA_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_emv_data_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
@@ -32,6 +32,8 @@ bool nfc_scene_read_emv_data_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_EMV_DATA_CUSTOM_EVENT) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvDataSuccess, NFC_SEND_NOTIFICATION_TRUE);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvDataSuccess);
|
||||
return true;
|
||||
}
|
||||
@@ -48,9 +50,6 @@ void nfc_scene_read_emv_data_on_exit(void* context) {
|
||||
// Stop worker
|
||||
nfc_worker_stop(nfc->worker);
|
||||
|
||||
// Send notification
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
|
||||
// Clear view
|
||||
Popup* popup = nfc->popup;
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
|
@@ -16,9 +16,6 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) {
|
||||
NfcEmvData* emv_data = &nfc->dev.dev_data.emv_data;
|
||||
NfcDeviceCommonData* nfc_data = &nfc->dev.dev_data.nfc_data;
|
||||
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
|
||||
// Setup Custom Widget view
|
||||
// Add frame
|
||||
widget_add_frame_element(nfc->widget, 0, 0, 128, 64, 6);
|
||||
@@ -39,20 +36,15 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) {
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 3, AlignCenter, AlignTop, FontSecondary, nfc->dev.dev_data.emv_data.name);
|
||||
// Add cad number
|
||||
char pan_str[32];
|
||||
snprintf(
|
||||
pan_str,
|
||||
sizeof(pan_str),
|
||||
"%02X%02X %02X%02X %02X%02X %02X%02X",
|
||||
emv_data->number[0],
|
||||
emv_data->number[1],
|
||||
emv_data->number[2],
|
||||
emv_data->number[3],
|
||||
emv_data->number[4],
|
||||
emv_data->number[5],
|
||||
emv_data->number[6],
|
||||
emv_data->number[7]);
|
||||
widget_add_string_element(nfc->widget, 64, 13, AlignCenter, AlignTop, FontSecondary, pan_str);
|
||||
string_t pan_str;
|
||||
string_init(pan_str);
|
||||
for(uint8_t i = 0; i < emv_data->number_len; i += 2) {
|
||||
string_cat_printf(pan_str, "%02X%02X ", emv_data->number[i], emv_data->number[i + 1]);
|
||||
}
|
||||
string_strim(pan_str);
|
||||
widget_add_string_element(
|
||||
nfc->widget, 64, 13, AlignCenter, AlignTop, FontSecondary, string_get_cstr(pan_str));
|
||||
string_clear(pan_str);
|
||||
// Parse country code
|
||||
string_t country_name;
|
||||
string_init(country_name);
|
||||
@@ -110,6 +102,14 @@ void nfc_scene_read_emv_data_success_on_enter(void* context) {
|
||||
widget_add_string_element(nfc->widget, 7, 32, AlignLeft, AlignTop, FontSecondary, exp_str);
|
||||
}
|
||||
|
||||
// Send notification
|
||||
if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadEmvDataSuccess) ==
|
||||
NFC_SEND_NOTIFICATION_TRUE) {
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvDataSuccess, NFC_SEND_NOTIFICATION_FALSE);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ bool nfc_scene_read_emv_data_success_on_event(void* context, SceneManagerEvent e
|
||||
return scene_manager_search_and_switch_to_previous_scene(
|
||||
nfc->scene_manager, NfcSceneReadEmvAppSuccess);
|
||||
} else if(event.event == GuiButtonTypeRight) {
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
nfc->dev.format = NfcDeviceSaveFormatBankCard;
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
||||
return true;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define NFC_READ_MIFARE_UL_CUSTOM_EVENT (0UL)
|
||||
#define NFC_READ_MIFARE_UL_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_mifare_ul_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
@@ -23,9 +23,6 @@ void nfc_scene_read_mifare_ul_success_text_box_callback(void* context) {
|
||||
void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
|
||||
// Send notification
|
||||
notification_message(nfc->notifications, &sequence_success);
|
||||
|
||||
|
@@ -43,7 +43,7 @@ bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetUid)) {
|
||||
nfc->dev.dev_data.nfc_data = nfc->dev_edit_data;
|
||||
}
|
||||
memcpy(&nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store));
|
||||
strlcpy(nfc->dev.dev_name, nfc->text_store, strlen(nfc->text_store) + 1);
|
||||
if(nfc_device_save(&nfc->dev, nfc->text_store)) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
|
||||
return true;
|
||||
|
@@ -14,7 +14,8 @@ void nfc_scene_set_type_submenu_callback(void* context, uint32_t index) {
|
||||
void nfc_scene_set_type_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
Submenu* submenu = nfc->submenu;
|
||||
|
||||
// Clear device name
|
||||
nfc_device_set_name(&nfc->dev, "");
|
||||
submenu_add_item(
|
||||
submenu, "NFC-A 7-bytes UID", SubmenuIndexNFCA7, nfc_scene_set_type_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
|
Reference in New Issue
Block a user