[FL-2198], [FL-2161] NFC emulation refactoring (#968)
* rfal: add state changed callback * furi_hal_nfc: add NFC-A emulation API * nfc: add emulation logger, refactor scenes * elements: fix text_box element * gui: fix text box module * nfc: remove unnecessary buffers * nfc: introduce emulation callback concept * nfc: format sources * bt settings: fix incorrect scene switch * bt settings: format sources * Debug: fix x2d import for python 3 * Gui: rename method name widget_clear to widget_reset * nfc: add nfca emulation handler * nfc: add global custom events enum * nfc: UID emulation Data -> Log * furi_hal_nfc: fix incorrect timings * u2f, badusb: widget_clear() -> widget_reset() Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -88,5 +88,5 @@ bool nfc_scene_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
void nfc_scene_delete_on_exit(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
widget_clear(nfc->widget);
|
||||
widget_reset(nfc->widget);
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_delete_success_popup_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SAVE_SUCCESS_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
|
||||
void nfc_scene_delete_success_on_enter(void* context) {
|
||||
@@ -25,7 +23,7 @@ bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventViewExit) {
|
||||
return scene_manager_search_and_switch_to_previous_scene(
|
||||
nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
#include "../nfc_i.h"
|
||||
#include "../helpers/nfc_emv_parser.h"
|
||||
|
||||
#define NFC_SCENE_DEVICE_INFO_BACK_EVENT (0UL)
|
||||
|
||||
enum {
|
||||
NfcSceneDeviceInfoUid,
|
||||
NfcSceneDeviceInfoData,
|
||||
@@ -17,18 +15,15 @@ void nfc_scene_device_info_widget_callback(GuiButtonType result, InputType type,
|
||||
|
||||
void nfc_scene_device_info_dialog_callback(DialogExResult result, void* context) {
|
||||
Nfc* nfc = context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void nfc_scene_device_info_text_box_callback(void* context) {
|
||||
Nfc* nfc = context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_SCENE_DEVICE_INFO_BACK_EVENT);
|
||||
if(result == DialogExResultLeft) {
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_scene_device_info_bank_card_callback(GuiButtonType result, InputType type, void* context) {
|
||||
Nfc* nfc = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_SCENE_DEVICE_INFO_BACK_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +92,6 @@ void nfc_scene_device_info_on_enter(void* context) {
|
||||
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
|
||||
MifareUlData* mf_ul_data = &nfc->dev->dev_data.mf_ul_data;
|
||||
TextBox* text_box = nfc->text_box;
|
||||
text_box_set_context(text_box, nfc);
|
||||
text_box_set_exit_callback(text_box, nfc_scene_device_info_text_box_callback);
|
||||
text_box_set_font(text_box, TextBoxFontHex);
|
||||
for(uint16_t i = 0; i < mf_ul_data->data_size; i += 2) {
|
||||
if(!(i % 8) && i) {
|
||||
@@ -170,7 +163,14 @@ bool nfc_scene_device_info_on_event(void* context, SceneManagerEvent event) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewBankCard);
|
||||
consumed = true;
|
||||
}
|
||||
} else if(state == NfcSceneDeviceInfoData) {
|
||||
} else if(state == NfcSceneDeviceInfoData && event.event == NfcCustomEventViewExit) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDeviceInfo, NfcSceneDeviceInfoUid);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
consumed = true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
if(state == NfcSceneDeviceInfoData) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDeviceInfo, NfcSceneDeviceInfoUid);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
@@ -184,7 +184,7 @@ void nfc_scene_device_info_on_exit(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
// Clear Custom Widget
|
||||
widget_clear(nfc->widget);
|
||||
widget_reset(nfc->widget);
|
||||
|
||||
if(nfc->dev->format == NfcDeviceSaveFormatUid) {
|
||||
// Clear Dialog
|
||||
|
@@ -1,61 +1,139 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
enum {
|
||||
NfcSceneEmulateUidStateWidget,
|
||||
NfcSceneEmulateUidStateTextBox,
|
||||
};
|
||||
|
||||
void nfc_emulate_uid_worker_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
}
|
||||
|
||||
void nfc_scene_emulate_uid_widget_callback(GuiButtonType result, InputType type, void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_emulate_uid_textbox_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
|
||||
// Add widget with device name or inform that data received
|
||||
static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
|
||||
NfcDeviceCommonData* data = &nfc->dev->dev_data.nfc_data;
|
||||
Widget* widget = nfc->widget;
|
||||
widget_reset(widget);
|
||||
string_t info_str;
|
||||
string_init(info_str);
|
||||
|
||||
widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
widget_add_string_element(widget, 56, 32, AlignLeft, AlignTop, FontPrimary, "Emulating UID");
|
||||
if(strcmp(nfc->dev->dev_name, "")) {
|
||||
string_printf(info_str, "%s", nfc->dev->dev_name);
|
||||
} else {
|
||||
for(uint8_t i = 0; i < data->uid_len; i++) {
|
||||
string_cat_printf(info_str, "%02X ", data->uid[i]);
|
||||
}
|
||||
}
|
||||
string_strim(info_str);
|
||||
widget_add_text_box_element(
|
||||
widget, 56, 43, 70, 21, AlignLeft, AlignTop, string_get_cstr(info_str));
|
||||
string_clear(info_str);
|
||||
if(data_received) {
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeCenter, "Log", nfc_scene_emulate_uid_widget_callback, nfc);
|
||||
}
|
||||
}
|
||||
|
||||
void nfc_scene_emulate_uid_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
Nfc* nfc = context;
|
||||
DOLPHIN_DEED(DolphinDeedNfcEmulate);
|
||||
|
||||
// Setup view
|
||||
Popup* popup = nfc->popup;
|
||||
NfcDeviceCommonData* data = &nfc->dev->dev_data.nfc_data;
|
||||
// Setup Widget
|
||||
nfc_scene_emulate_uid_widget_config(nfc, false);
|
||||
// Setup TextBox
|
||||
TextBox* text_box = nfc->text_box;
|
||||
text_box_set_font(text_box, TextBoxFontHex);
|
||||
text_box_set_focus(text_box, TextBoxFocusEnd);
|
||||
string_reset(nfc->text_box_store);
|
||||
|
||||
if(strcmp(nfc->dev->dev_name, "")) {
|
||||
nfc_text_store_set(nfc, "%s", nfc->dev->dev_name);
|
||||
} else if(data->uid_len == 4) {
|
||||
nfc_text_store_set(
|
||||
nfc, "%02X %02X %02X %02X", data->uid[0], data->uid[1], data->uid[2], data->uid[3]);
|
||||
} else if(data->uid_len == 7) {
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
"%02X %02X %02X %02X\n%02X %02X %02X",
|
||||
data->uid[0],
|
||||
data->uid[1],
|
||||
data->uid[2],
|
||||
data->uid[3],
|
||||
data->uid[4],
|
||||
data->uid[5],
|
||||
data->uid[6]);
|
||||
}
|
||||
|
||||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
popup_set_header(popup, "Emulating UID", 56, 31, AlignLeft, AlignTop);
|
||||
popup_set_text(popup, nfc->text_store, 56, 43, AlignLeft, AlignTop);
|
||||
|
||||
// Setup and start worker
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
|
||||
nfc_worker_start(nfc->worker, NfcWorkerStateEmulate, &nfc->dev->dev_data, NULL, nfc);
|
||||
// Set Widget state and view
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneEmulateUid, NfcSceneEmulateUidStateWidget);
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
// Start worker
|
||||
memset(&nfc->dev->dev_data.reader_data, 0, sizeof(NfcReaderRequestData));
|
||||
nfc_worker_start(
|
||||
nfc->worker,
|
||||
NfcWorkerStateEmulate,
|
||||
&nfc->dev->dev_data,
|
||||
nfc_emulate_uid_worker_callback,
|
||||
nfc);
|
||||
}
|
||||
|
||||
bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
Nfc* nfc = context;
|
||||
NfcReaderRequestData* reader_data = &nfc->dev->dev_data.reader_data;
|
||||
uint32_t state = scene_manager_get_scene_state(nfc->scene_manager, NfcSceneEmulateUid);
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeTick) {
|
||||
notification_message(nfc->notifications, &sequence_blink_blue_10);
|
||||
return true;
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
// Add data button to widget if data is received for the first time
|
||||
if(!string_size(nfc->text_box_store)) {
|
||||
nfc_scene_emulate_uid_widget_config(nfc, true);
|
||||
}
|
||||
// Update TextBox data
|
||||
string_cat_printf(nfc->text_box_store, "R:");
|
||||
for(uint16_t i = 0; i < reader_data->size; i++) {
|
||||
string_cat_printf(nfc->text_box_store, " %02X", reader_data->data[i]);
|
||||
}
|
||||
string_push_back(nfc->text_box_store, '\n');
|
||||
memset(reader_data, 0, sizeof(NfcReaderRequestData));
|
||||
text_box_set_text(nfc->text_box, string_get_cstr(nfc->text_box_store));
|
||||
consumed = true;
|
||||
} else if(event.event == GuiButtonTypeCenter && state == NfcSceneEmulateUidStateWidget) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneEmulateUid, NfcSceneEmulateUidStateTextBox);
|
||||
consumed = true;
|
||||
} else if(event.event == NfcCustomEventViewExit && state == NfcSceneEmulateUidStateTextBox) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneEmulateUid, NfcSceneEmulateUidStateWidget);
|
||||
consumed = true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
if(state == NfcSceneEmulateUidStateTextBox) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneEmulateUid, NfcSceneEmulateUidStateWidget);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_scene_emulate_uid_on_exit(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
Nfc* nfc = context;
|
||||
|
||||
// Stop worker
|
||||
nfc_worker_stop(nfc->worker);
|
||||
|
||||
// Clear view
|
||||
Popup* popup = nfc->popup;
|
||||
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
widget_reset(nfc->widget);
|
||||
text_box_reset(nfc->text_box);
|
||||
string_reset(nfc->text_box_store);
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define NFC_READ_CARD_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_card_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_CARD_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
}
|
||||
|
||||
void nfc_scene_read_card_on_enter(void* context) {
|
||||
@@ -27,7 +25,7 @@ bool nfc_scene_read_card_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_CARD_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadCardSuccess);
|
||||
return true;
|
||||
}
|
||||
|
@@ -85,5 +85,5 @@ 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;
|
||||
widget_clear(nfc->widget);
|
||||
widget_reset(nfc->widget);
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define NFC_READ_EMV_APP_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_emv_app_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_EMV_APP_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
}
|
||||
|
||||
void nfc_scene_read_emv_app_on_enter(void* context) {
|
||||
@@ -31,7 +29,7 @@ bool nfc_scene_read_emv_app_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_EMV_APP_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define NFC_READ_EMV_DATA_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_emv_data_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_EMV_DATA_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
}
|
||||
|
||||
void nfc_scene_read_emv_data_on_enter(void* context) {
|
||||
@@ -33,7 +31,7 @@ bool nfc_scene_read_emv_data_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_EMV_DATA_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadEmvDataSuccess, NFC_SEND_NOTIFICATION_TRUE);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvDataSuccess);
|
||||
|
@@ -140,5 +140,5 @@ bool nfc_scene_read_emv_data_success_on_event(void* context, SceneManagerEvent e
|
||||
void nfc_scene_read_emv_data_success_on_exit(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
widget_clear(nfc->widget);
|
||||
widget_reset(nfc->widget);
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define NFC_READ_MIFARE_UL_CUSTOM_EVENT (10UL)
|
||||
|
||||
void nfc_read_mifare_ul_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_MIFARE_UL_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_on_enter(void* context) {
|
||||
@@ -31,7 +29,7 @@ bool nfc_scene_read_mifare_ul_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NFC_READ_MIFARE_UL_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventWorkerExit) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareUlSuccess);
|
||||
return true;
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define NFC_SCENE_READ_SUCCESS_SHIFT " "
|
||||
#define NFC_SCENE_READ_MF_UL_CUSTOM_EVENT (0UL)
|
||||
|
||||
enum {
|
||||
ReadMifareUlStateShowUID,
|
||||
@@ -15,12 +14,6 @@ void nfc_scene_read_mifare_ul_success_dialog_callback(DialogExResult result, voi
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_success_text_box_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_SCENE_READ_MF_UL_CUSTOM_EVENT);
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
||||
@@ -59,8 +52,6 @@ void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
|
||||
// Setup TextBox view
|
||||
TextBox* text_box = nfc->text_box;
|
||||
text_box_set_context(text_box, nfc);
|
||||
text_box_set_exit_callback(text_box, nfc_scene_read_mifare_ul_success_text_box_callback);
|
||||
text_box_set_font(text_box, TextBoxFontHex);
|
||||
for(uint16_t i = 0; i < mf_ul_data->data_size; i += 2) {
|
||||
if(!(i % 8) && i) {
|
||||
@@ -77,39 +68,34 @@ void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
}
|
||||
|
||||
bool nfc_scene_read_mifare_ul_success_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
Nfc* nfc = context;
|
||||
uint32_t state =
|
||||
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess);
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if((scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess) ==
|
||||
ReadMifareUlStateShowUID) &&
|
||||
(event.event == DialogExResultLeft)) {
|
||||
if(state == ReadMifareUlStateShowUID && event.event == DialogExResultLeft) {
|
||||
scene_manager_previous_scene(nfc->scene_manager);
|
||||
return true;
|
||||
} else if(
|
||||
(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess) ==
|
||||
ReadMifareUlStateShowUID) &&
|
||||
(event.event == DialogExResultRight)) {
|
||||
consumed = true;
|
||||
} else if(state == ReadMifareUlStateShowUID && event.event == DialogExResultRight) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneMifareUlMenu);
|
||||
return true;
|
||||
} else if(
|
||||
(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess) ==
|
||||
ReadMifareUlStateShowUID) &&
|
||||
(event.event == DialogExResultCenter)) {
|
||||
consumed = true;
|
||||
} else if(state == ReadMifareUlStateShowUID && event.event == DialogExResultCenter) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadMifareUlSuccess, ReadMifareUlStateShowData);
|
||||
return true;
|
||||
} else if(
|
||||
(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess) ==
|
||||
ReadMifareUlStateShowData) &&
|
||||
(event.event == NFC_SCENE_READ_MF_UL_CUSTOM_EVENT)) {
|
||||
consumed = true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
if(state == ReadMifareUlStateShowData) {
|
||||
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadMifareUlSuccess, ReadMifareUlStateShowUID);
|
||||
return true;
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_success_on_exit(void* context) {
|
||||
|
@@ -1,10 +1,8 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define SCENE_RESTORE_ORIGINAL_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_restore_original_popup_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_RESTORE_ORIGINAL_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
|
||||
void nfc_scene_restore_original_on_enter(void* context) {
|
||||
@@ -26,7 +24,7 @@ bool nfc_scene_restore_original_on_event(void* context, SceneManagerEvent event)
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_RESTORE_ORIGINAL_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventViewExit) {
|
||||
consumed = scene_manager_previous_scene(nfc->scene_manager);
|
||||
}
|
||||
}
|
||||
|
@@ -2,12 +2,10 @@
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include <gui/modules/validators.h>
|
||||
|
||||
#define SCENE_SAVE_NAME_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_save_name_text_input_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SAVE_NAME_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventTextInputDone);
|
||||
}
|
||||
|
||||
void nfc_scene_save_name_on_enter(void* context) {
|
||||
@@ -42,7 +40,7 @@ bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SAVE_NAME_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventTextInputDone) {
|
||||
if(strcmp(nfc->dev->dev_name, "")) {
|
||||
nfc_device_delete(nfc->dev);
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_save_success_popup_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SAVE_SUCCESS_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
|
||||
}
|
||||
|
||||
void nfc_scene_save_success_on_enter(void* context) {
|
||||
@@ -28,7 +26,7 @@ bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventViewExit) {
|
||||
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) {
|
||||
consumed = scene_manager_search_and_switch_to_previous_scene(
|
||||
nfc->scene_manager, NfcSceneCardMenu);
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define SCENE_SET_ATQA_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_atqa_byte_input_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SET_ATQA_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void nfc_scene_set_atqa_on_enter(void* context) {
|
||||
@@ -28,7 +26,7 @@ bool nfc_scene_set_atqa_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_ATQA_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define SCENE_SET_SAK_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_sak_byte_input_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SET_SAK_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void nfc_scene_set_sak_on_enter(void* context) {
|
||||
@@ -28,7 +26,7 @@ bool nfc_scene_set_sak_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_SAK_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventByteInputDone) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetAtqua);
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
#include "../nfc_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#define SCENE_SET_UID_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_uid_byte_input_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SET_UID_CUSTOM_EVENT);
|
||||
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventByteInputDone);
|
||||
}
|
||||
|
||||
void nfc_scene_set_uid_on_enter(void* context) {
|
||||
@@ -30,7 +28,7 @@ bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_UID_CUSTOM_EVENT) {
|
||||
if(event.event == NfcCustomEventByteInputDone) {
|
||||
DOLPHIN_DEED(DolphinDeedNfcAdd);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user