Temporarily backport app updates from apps repo

This commit is contained in:
Willy-JL
2023-11-12 11:06:02 +00:00
parent 79e7f491fe
commit e309fa8a88
1498 changed files with 1325977 additions and 20227 deletions

View File

@@ -1,50 +0,0 @@
#include "../nfc_magic_i.h"
enum SubmenuIndex {
SubmenuIndexWrite,
SubmenuIndexWipe,
};
void nfc_magic_scene_actions_submenu_callback(void* context, uint32_t index) {
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, index);
}
void nfc_magic_scene_actions_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Submenu* submenu = nfc_magic->submenu;
submenu_add_item(
submenu, "Write", SubmenuIndexWrite, nfc_magic_scene_actions_submenu_callback, nfc_magic);
submenu_add_item(
submenu, "Wipe", SubmenuIndexWipe, nfc_magic_scene_actions_submenu_callback, nfc_magic);
submenu_set_selected_item(
submenu, scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneActions));
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewMenu);
}
bool nfc_magic_scene_actions_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexWrite) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneFileSelect);
consumed = true;
} else if(event.event == SubmenuIndexWipe) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipe);
consumed = true;
}
scene_manager_set_scene_state(nfc_magic->scene_manager, NfcMagicSceneActions, event.event);
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_actions_on_exit(void* context) {
NfcMagic* nfc_magic = context;
submenu_reset(nfc_magic->submenu);
}

View File

@@ -0,0 +1,108 @@
#include "../nfc_magic_app_i.h"
enum {
NfcMagicSceneChangeKeyStateCardSearch,
NfcMagicSceneChangeKeyStateCardFound,
};
NfcCommand nfc_mafic_scene_change_key_gen4_poller_callback(Gen4PollerEvent event, void* context) {
NfcMagicApp* instance = context;
furi_assert(event.data);
NfcCommand command = NfcCommandContinue;
if(event.type == Gen4PollerEventTypeCardDetected) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventCardDetected);
} else if(event.type == Gen4PollerEventTypeRequestMode) {
event.data->request_mode.mode = Gen4PollerModeSetPassword;
} else if(event.type == Gen4PollerEventTypeRequestNewPassword) {
event.data->request_password.password = instance->gen4_password_new;
} else if(event.type == Gen4PollerEventTypeSuccess) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
command = NfcCommandStop;
} else if(event.type == Gen4PollerEventTypeFail) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
command = NfcCommandStop;
}
return command;
}
static void nfc_magic_scene_change_key_setup_view(NfcMagicApp* instance) {
Popup* popup = instance->popup;
popup_reset(popup);
uint32_t state =
scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneChangeKey);
if(state == NfcMagicSceneChangeKeyStateCardSearch) {
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_text(
instance->popup, "Apply the\nsame card\nto the back", 128, 32, AlignRight, AlignCenter);
} else {
popup_set_icon(popup, 12, 23, &I_Loading_24);
popup_set_header(popup, "Writing\nDon't move...", 52, 32, AlignLeft, AlignCenter);
}
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
}
void nfc_magic_scene_change_key_on_enter(void* context) {
NfcMagicApp* instance = context;
scene_manager_set_scene_state(
instance->scene_manager, NfcMagicSceneChangeKey, NfcMagicSceneChangeKeyStateCardSearch);
nfc_magic_scene_change_key_setup_view(instance);
nfc_magic_app_blink_start(instance);
instance->gen4_poller = gen4_poller_alloc(instance->nfc);
gen4_poller_start(
instance->gen4_poller, nfc_mafic_scene_change_key_gen4_poller_callback, instance);
}
bool nfc_magic_scene_change_key_on_event(void* context, SceneManagerEvent event) {
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicCustomEventCardDetected) {
scene_manager_set_scene_state(
instance->scene_manager,
NfcMagicSceneChangeKey,
NfcMagicSceneChangeKeyStateCardFound);
nfc_magic_scene_change_key_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicCustomEventCardLost) {
scene_manager_set_scene_state(
instance->scene_manager,
NfcMagicSceneChangeKey,
NfcMagicSceneChangeKeyStateCardSearch);
nfc_magic_scene_change_key_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerSuccess) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerFail) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneChangeKeyFail);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_change_key_on_exit(void* context) {
NfcMagicApp* instance = context;
gen4_poller_stop(instance->gen4_poller);
gen4_poller_free(instance->gen4_poller);
scene_manager_set_scene_state(
instance->scene_manager, NfcMagicSceneChangeKey, NfcMagicSceneChangeKeyStateCardSearch);
// Clear view
popup_reset(instance->popup);
nfc_magic_app_blink_stop(instance);
}

View File

@@ -0,0 +1,54 @@
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_change_key_fail_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_change_key_fail_on_enter(void* context) {
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
notification_message(instance->notifications, &sequence_error);
widget_add_icon_element(widget, 72, 17, &I_DolphinCommon_56x48);
widget_add_string_element(
widget, 7, 4, AlignLeft, AlignTop, FontPrimary, "Can't change password!");
widget_add_button_element(
widget,
GuiButtonTypeLeft,
"Finish",
nfc_magic_scene_change_key_fail_widget_callback,
instance);
// Setup and start worker
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_change_key_fail_on_event(void* context, SceneManagerEvent event) {
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, NfcMagicSceneStart);
}
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_change_key_fail_on_exit(void* context) {
NfcMagicApp* instance = context;
widget_reset(instance->widget);
}

View File

@@ -1,89 +1,54 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
enum {
NfcMagicSceneCheckStateCardSearch,
NfcMagicSceneCheckStateCardFound,
};
bool nfc_magic_check_worker_callback(NfcMagicWorkerEvent event, void* context) {
void nfc_magic_check_worker_callback(NfcMagicScannerEvent event, void* context) {
furi_assert(context);
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, event);
NfcMagicApp* instance = context;
return true;
}
static void nfc_magic_scene_check_setup_view(NfcMagic* nfc_magic) {
Popup* popup = nfc_magic->popup;
popup_reset(popup);
uint32_t state = scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneCheck);
if(state == NfcMagicSceneCheckStateCardSearch) {
popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_text(
nfc_magic->popup, "Apply card to\nthe back", 128, 32, AlignRight, AlignCenter);
} else {
popup_set_icon(popup, 12, 23, &I_Loading_24);
popup_set_header(popup, "Checking\nDon't move...", 52, 32, AlignLeft, AlignCenter);
if(event.type == NfcMagicScannerEventTypeDetected) {
instance->protocol = event.data.protocol;
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
} else if(event.type == NfcMagicScannerEventTypeDetectedNotMagic) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
}
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup);
}
void nfc_magic_scene_check_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneCheck, NfcMagicSceneCheckStateCardSearch);
nfc_magic_scene_check_setup_view(nfc_magic);
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_text(instance->popup, "Apply card to\nthe back", 128, 32, AlignRight, AlignCenter);
// Setup and start worker
nfc_magic_worker_start(
nfc_magic->worker,
NfcMagicWorkerStateCheck,
nfc_magic->dev,
&nfc_magic->source_dev->dev_data,
nfc_magic->new_password,
nfc_magic_check_worker_callback,
nfc_magic);
nfc_magic_blink_start(nfc_magic);
nfc_magic_app_blink_start(instance);
nfc_magic_scanner_start(instance->scanner, nfc_magic_check_worker_callback, instance);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
}
bool nfc_magic_scene_check_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicWorkerEventSuccess) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneMagicInfo);
if(event.event == NfcMagicCustomEventWorkerSuccess) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneMagicInfo);
consumed = true;
} else if(event.event == NfcMagicWorkerEventWrongCard) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneNotMagic);
consumed = true;
} else if(event.event == NfcMagicWorkerEventCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneCheck, NfcMagicSceneCheckStateCardFound);
nfc_magic_scene_check_setup_view(nfc_magic);
consumed = true;
} else if(event.event == NfcMagicWorkerEventNoCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneCheck, NfcMagicSceneCheckStateCardSearch);
nfc_magic_scene_check_setup_view(nfc_magic);
} else if(event.event == NfcMagicCustomEventWorkerFail) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneNotMagic);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_check_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
nfc_magic_worker_stop(nfc_magic->worker);
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneCheck, NfcMagicSceneCheckStateCardSearch);
// Clear view
popup_reset(nfc_magic->popup);
nfc_magic_blink_stop(nfc_magic);
nfc_magic_scanner_stop(instance->scanner);
popup_reset(instance->popup);
nfc_magic_app_blink_stop(instance);
}

View File

@@ -1,18 +1,17 @@
ADD_SCENE(nfc_magic, start, Start)
ADD_SCENE(nfc_magic, key_input, KeyInput)
ADD_SCENE(nfc_magic, actions, Actions)
ADD_SCENE(nfc_magic, gen4_actions, Gen4Actions)
ADD_SCENE(nfc_magic, new_key_input, NewKeyInput)
ADD_SCENE(nfc_magic, file_select, FileSelect)
ADD_SCENE(nfc_magic, write_confirm, WriteConfirm)
ADD_SCENE(nfc_magic, wrong_card, WrongCard)
ADD_SCENE(nfc_magic, write, Write)
ADD_SCENE(nfc_magic, write_fail, WriteFail)
ADD_SCENE(nfc_magic, success, Success)
ADD_SCENE(nfc_magic, check, Check)
ADD_SCENE(nfc_magic, not_magic, NotMagic)
ADD_SCENE(nfc_magic, key_input, KeyInput)
ADD_SCENE(nfc_magic, magic_info, MagicInfo)
ADD_SCENE(nfc_magic, rekey, Rekey)
ADD_SCENE(nfc_magic, rekey_fail, RekeyFail)
ADD_SCENE(nfc_magic, gen1_menu, Gen1Menu)
ADD_SCENE(nfc_magic, gen4_menu, Gen4Menu)
ADD_SCENE(nfc_magic, wipe, Wipe)
ADD_SCENE(nfc_magic, wipe_fail, WipeFail)
ADD_SCENE(nfc_magic, success, Success)
ADD_SCENE(nfc_magic, file_select, FileSelect)
ADD_SCENE(nfc_magic, write_confirm, WriteConfirm)
ADD_SCENE(nfc_magic, write, Write)
ADD_SCENE(nfc_magic, write_fail, WriteFail)
ADD_SCENE(nfc_magic, change_key, ChangeKey)
ADD_SCENE(nfc_magic, change_key_fail, ChangeKeyFail)
ADD_SCENE(nfc_magic, wrong_card, WrongCard)
ADD_SCENE(nfc_magic, not_magic, NotMagic)

View File

@@ -1,66 +1,51 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
#include <nfc/protocols/mf_classic/mf_classic.h>
static bool nfc_magic_scene_file_select_is_file_suitable(NfcMagic* nfc_magic) {
NfcDevice* nfc_dev = nfc_magic->source_dev;
if(nfc_dev->format == NfcDeviceSaveFormatMifareClassic) {
switch(nfc_magic->dev->type) {
case MagicTypeClassicGen1:
case MagicTypeClassicDirectWrite:
case MagicTypeClassicAPDU:
if((nfc_dev->dev_data.mf_classic_data.type != MfClassicType1k) ||
(nfc_dev->dev_data.nfc_data.uid_len != nfc_magic->dev->uid_len)) {
return false;
static bool nfc_magic_scene_file_select_is_file_suitable(NfcMagicApp* instance) {
NfcProtocol protocol = nfc_device_get_protocol(instance->source_dev);
size_t uid_len = 0;
nfc_device_get_uid(instance->source_dev, &uid_len);
bool suitable = false;
if(instance->protocol == NfcMagicProtocolGen1) {
if((uid_len == 4) && (protocol == NfcProtocolMfClassic)) {
const MfClassicData* mfc_data =
nfc_device_get_data(instance->source_dev, NfcProtocolMfClassic);
if(mfc_data->type == MfClassicType1k) {
suitable = true;
}
return true;
case MagicTypeGen4:
return true;
default:
return false;
}
} else if(
(nfc_dev->format == NfcDeviceSaveFormatMifareUl) &&
(nfc_dev->dev_data.nfc_data.uid_len == 7)) {
switch(nfc_magic->dev->type) {
case MagicTypeUltralightGen1:
case MagicTypeUltralightDirectWrite:
case MagicTypeUltralightC_Gen1:
case MagicTypeUltralightC_DirectWrite:
case MagicTypeGen4:
switch(nfc_dev->dev_data.mf_ul_data.type) {
case MfUltralightTypeNTAGI2C1K:
case MfUltralightTypeNTAGI2C2K:
case MfUltralightTypeNTAGI2CPlus1K:
case MfUltralightTypeNTAGI2CPlus2K:
return false;
default:
return true;
} else if(instance->protocol == NfcMagicProtocolGen4) {
if(protocol == NfcProtocolMfClassic) {
suitable = true;
} else if(protocol == NfcProtocolMfUltralight) {
const MfUltralightData* mfu_data =
nfc_device_get_data(instance->source_dev, NfcProtocolMfUltralight);
const Iso14443_3aData* iso3_data = mfu_data->iso14443_3a_data;
if(iso3_data->uid_len == 7) {
MfUltralightType mfu_type = mfu_data->type;
suitable = (mfu_type != MfUltralightTypeNTAGI2C1K) &&
(mfu_type != MfUltralightTypeNTAGI2C2K) &&
(mfu_type != MfUltralightTypeNTAGI2CPlus1K) &&
(mfu_type != MfUltralightTypeNTAGI2CPlus2K);
}
default:
return false;
}
}
return false;
return suitable;
}
void nfc_magic_scene_file_select_on_enter(void* context) {
NfcMagic* nfc_magic = context;
// Process file_select return
nfc_device_set_loading_callback(
nfc_magic->source_dev, nfc_magic_show_loading_popup, nfc_magic);
NfcMagicApp* instance = context;
if(!furi_string_size(nfc_magic->source_dev->load_path)) {
furi_string_set_str(nfc_magic->source_dev->load_path, NFC_APP_FOLDER);
}
if(nfc_file_select(nfc_magic->source_dev)) {
if(nfc_magic_scene_file_select_is_file_suitable(nfc_magic)) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWriteConfirm);
if(nfc_magic_load_from_file_select(instance)) {
if(nfc_magic_scene_file_select_is_file_suitable(instance)) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWriteConfirm);
} else {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWrongCard);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWrongCard);
}
} else {
scene_manager_previous_scene(nfc_magic->scene_manager);
scene_manager_previous_scene(instance->scene_manager);
}
}
@@ -71,6 +56,5 @@ bool nfc_magic_scene_file_select_on_event(void* context, SceneManagerEvent event
}
void nfc_magic_scene_file_select_on_exit(void* context) {
NfcMagic* nfc_magic = context;
nfc_device_set_loading_callback(nfc_magic->source_dev, NULL, nfc_magic);
UNUSED(context);
}

View File

@@ -0,0 +1,53 @@
#include "../nfc_magic_app_i.h"
enum SubmenuIndex {
SubmenuIndexWrite,
SubmenuIndexWipe,
};
void nfc_magic_scene_gen1_menu_submenu_callback(void* context, uint32_t index) {
NfcMagicApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, index);
}
void nfc_magic_scene_gen1_menu_on_enter(void* context) {
NfcMagicApp* instance = context;
Submenu* submenu = instance->submenu;
submenu_add_item(
submenu, "Write", SubmenuIndexWrite, nfc_magic_scene_gen1_menu_submenu_callback, instance);
submenu_add_item(
submenu, "Wipe", SubmenuIndexWipe, nfc_magic_scene_gen1_menu_submenu_callback, instance);
submenu_set_selected_item(
submenu, scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneGen4Menu));
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewMenu);
}
bool nfc_magic_scene_gen1_menu_on_event(void* context, SceneManagerEvent event) {
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexWrite) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneFileSelect);
consumed = true;
} else if(event.event == SubmenuIndexWipe) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWipe);
consumed = true;
}
scene_manager_set_scene_state(instance->scene_manager, NfcMagicSceneGen4Menu, event.event);
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_gen1_menu_on_exit(void* context) {
NfcMagicApp* instance = context;
submenu_reset(instance->submenu);
}

View File

@@ -1,70 +0,0 @@
#include "../nfc_magic_i.h"
enum SubmenuIndex {
SubmenuIndexWrite,
SubmenuIndexChangePassword,
SubmenuIndexWipe,
};
void nfc_magic_scene_gen4_actions_submenu_callback(void* context, uint32_t index) {
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, index);
}
void nfc_magic_scene_gen4_actions_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Submenu* submenu = nfc_magic->submenu;
submenu_add_item(
submenu,
"Write",
SubmenuIndexWrite,
nfc_magic_scene_gen4_actions_submenu_callback,
nfc_magic);
submenu_add_item(
submenu,
"Change password",
SubmenuIndexChangePassword,
nfc_magic_scene_gen4_actions_submenu_callback,
nfc_magic);
submenu_add_item(
submenu,
"Wipe",
SubmenuIndexWipe,
nfc_magic_scene_gen4_actions_submenu_callback,
nfc_magic);
submenu_set_selected_item(
submenu,
scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneGen4Actions));
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewMenu);
}
bool nfc_magic_scene_gen4_actions_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexWrite) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneFileSelect);
consumed = true;
} else if(event.event == SubmenuIndexChangePassword) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneNewKeyInput);
consumed = true;
} else if(event.event == SubmenuIndexWipe) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipe);
consumed = true;
}
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneGen4Actions, event.event);
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_gen4_actions_on_exit(void* context) {
NfcMagic* nfc_magic = context;
submenu_reset(nfc_magic->submenu);
}

View File

@@ -0,0 +1,63 @@
#include "../nfc_magic_app_i.h"
enum SubmenuIndex {
SubmenuIndexWrite,
SubmenuIndexChangePassword,
SubmenuIndexWipe,
};
void nfc_magic_scene_gen4_menu_submenu_callback(void* context, uint32_t index) {
NfcMagicApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, index);
}
void nfc_magic_scene_gen4_menu_on_enter(void* context) {
NfcMagicApp* instance = context;
Submenu* submenu = instance->submenu;
submenu_add_item(
submenu, "Write", SubmenuIndexWrite, nfc_magic_scene_gen4_menu_submenu_callback, instance);
submenu_add_item(
submenu,
"Change password",
SubmenuIndexChangePassword,
nfc_magic_scene_gen4_menu_submenu_callback,
instance);
submenu_add_item(
submenu, "Wipe", SubmenuIndexWipe, nfc_magic_scene_gen4_menu_submenu_callback, instance);
submenu_set_selected_item(
submenu, scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneGen4Menu));
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewMenu);
}
bool nfc_magic_scene_gen4_menu_on_event(void* context, SceneManagerEvent event) {
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexWrite) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneFileSelect);
consumed = true;
} else if(event.event == SubmenuIndexChangePassword) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneKeyInput);
consumed = true;
} else if(event.event == SubmenuIndexWipe) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWipe);
consumed = true;
}
scene_manager_set_scene_state(instance->scene_manager, NfcMagicSceneGen4Menu, event.event);
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
instance->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_gen4_menu_on_exit(void* context) {
NfcMagicApp* instance = context;
submenu_reset(instance->submenu);
}

View File

@@ -1,35 +1,45 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
#include <nfc/helpers/nfc_util.h>
void nfc_magic_scene_key_input_byte_input_callback(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
view_dispatcher_send_custom_event(
nfc_magic->view_dispatcher, NfcMagicCustomEventByteInputDone);
instance->view_dispatcher, NfcMagicAppCustomEventByteInputDone);
}
void nfc_magic_scene_key_input_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
// Setup view
ByteInput* byte_input = nfc_magic->byte_input;
ByteInput* byte_input = instance->byte_input;
byte_input_set_header_text(byte_input, "Enter the password in hex");
byte_input_set_result_callback(
byte_input,
nfc_magic_scene_key_input_byte_input_callback,
NULL,
nfc_magic,
(uint8_t*)&nfc_magic->dev->password,
4);
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewByteInput);
instance,
instance->byte_input_store,
NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewByteInput);
}
bool nfc_magic_scene_key_input_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicCustomEventByteInputDone) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneCheck);
if(event.event == NfcMagicAppCustomEventByteInputDone) {
if(scene_manager_has_previous_scene(instance->scene_manager, NfcMagicSceneGen4Menu)) {
instance->gen4_password_new = nfc_util_bytes2num(
instance->byte_input_store, NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneChangeKey);
} else {
instance->gen4_password = nfc_util_bytes2num(
instance->byte_input_store, NFC_MAGIC_APP_BYTE_INPUT_STORE_SIZE);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneCheck);
}
consumed = true;
}
}
@@ -37,9 +47,9 @@ bool nfc_magic_scene_key_input_on_event(void* context, SceneManagerEvent event)
}
void nfc_magic_scene_key_input_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
// Clear view
byte_input_set_result_callback(nfc_magic->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(nfc_magic->byte_input, "");
byte_input_set_result_callback(instance->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(instance->byte_input, "");
}

View File

@@ -1,50 +1,54 @@
#include "../nfc_magic_i.h"
#include "../lib/magic/types.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_magic_info_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_magic_info_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
const char* card_type = nfc_magic_type(nfc_magic->dev->type);
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
notification_message(nfc_magic->notifications, &sequence_success);
notification_message(instance->notifications, &sequence_success);
widget_add_icon_element(widget, 73, 17, &I_DolphinCommon_56x48);
widget_add_string_element(
widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Magic card detected");
widget_add_string_element(widget, 3, 17, AlignLeft, AlignTop, FontSecondary, card_type);
widget_add_string_element(
widget,
3,
17,
AlignLeft,
AlignTop,
FontSecondary,
nfc_magic_protocols_get_name(instance->protocol));
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_magic_info_widget_callback, nfc_magic);
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_magic_info_widget_callback, instance);
widget_add_button_element(
widget, GuiButtonTypeRight, "More", nfc_magic_scene_magic_info_widget_callback, nfc_magic);
widget, GuiButtonTypeRight, "More", nfc_magic_scene_magic_info_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_magic_info_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
consumed = scene_manager_previous_scene(instance->scene_manager);
} else if(event.event == GuiButtonTypeRight) {
MagicType type = nfc_magic->dev->type;
if(type == MagicTypeGen4) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneGen4Actions);
if(instance->protocol == NfcMagicProtocolGen1) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneGen1Menu);
consumed = true;
} else {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneActions);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneGen4Menu);
consumed = true;
}
}
@@ -53,7 +57,7 @@ bool nfc_magic_scene_magic_info_on_event(void* context, SceneManagerEvent event)
}
void nfc_magic_scene_magic_info_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}

View File

@@ -1,45 +0,0 @@
#include "../nfc_magic_i.h"
void nfc_magic_scene_new_key_input_byte_input_callback(void* context) {
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(
nfc_magic->view_dispatcher, NfcMagicCustomEventByteInputDone);
}
void nfc_magic_scene_new_key_input_on_enter(void* context) {
NfcMagic* nfc_magic = context;
// Setup view
ByteInput* byte_input = nfc_magic->byte_input;
byte_input_set_header_text(byte_input, "Enter the password in hex");
byte_input_set_result_callback(
byte_input,
nfc_magic_scene_new_key_input_byte_input_callback,
NULL,
nfc_magic,
(uint8_t*)&nfc_magic->new_password,
4);
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewByteInput);
}
bool nfc_magic_scene_new_key_input_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicCustomEventByteInputDone) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneRekey);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_new_key_input_on_exit(void* context) {
NfcMagic* nfc_magic = context;
// Clear view
byte_input_set_result_callback(nfc_magic->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(nfc_magic->byte_input, "");
}

View File

@@ -1,43 +1,43 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_not_magic_widget_callback(GuiButtonType result, InputType type, void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_not_magic_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
notification_message(nfc_magic->notifications, &sequence_error);
notification_message(instance->notifications, &sequence_error);
widget_add_string_element(
widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "This is wrong card");
widget_add_string_multiline_element(
widget, 4, 17, AlignLeft, AlignTop, FontSecondary, "Not magic or unsupported\ncard");
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_not_magic_widget_callback, nfc_magic);
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_not_magic_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_not_magic_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
consumed = scene_manager_previous_scene(instance->scene_manager);
}
}
return consumed;
}
void nfc_magic_scene_not_magic_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}

View File

@@ -1,95 +0,0 @@
#include "../nfc_magic_i.h"
enum {
NfcMagicSceneRekeyStateCardSearch,
NfcMagicSceneRekeyStateCardFound,
};
bool nfc_magic_rekey_worker_callback(NfcMagicWorkerEvent event, void* context) {
furi_assert(context);
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, event);
return true;
}
static void nfc_magic_scene_rekey_setup_view(NfcMagic* nfc_magic) {
Popup* popup = nfc_magic->popup;
popup_reset(popup);
uint32_t state = scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneRekey);
if(state == NfcMagicSceneRekeyStateCardSearch) {
popup_set_text(
nfc_magic->popup,
"Apply the\nsame card\nto the back",
128,
32,
AlignRight,
AlignCenter);
popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50);
} else {
popup_set_icon(popup, 12, 23, &I_Loading_24);
popup_set_header(popup, "Writing\nDon't move...", 52, 32, AlignLeft, AlignCenter);
}
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup);
}
void nfc_magic_scene_rekey_on_enter(void* context) {
NfcMagic* nfc_magic = context;
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch);
nfc_magic_scene_rekey_setup_view(nfc_magic);
// Setup and start worker
nfc_magic_worker_start(
nfc_magic->worker,
NfcMagicWorkerStateRekey,
nfc_magic->dev,
&nfc_magic->source_dev->dev_data,
nfc_magic->new_password,
nfc_magic_rekey_worker_callback,
nfc_magic);
nfc_magic_blink_start(nfc_magic);
}
bool nfc_magic_scene_rekey_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicWorkerEventSuccess) {
nfc_magic->dev->password = nfc_magic->new_password;
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicWorkerEventFail) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneRekeyFail);
consumed = true;
} else if(event.event == NfcMagicWorkerEventCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardFound);
nfc_magic_scene_rekey_setup_view(nfc_magic);
consumed = true;
} else if(event.event == NfcMagicWorkerEventNoCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch);
nfc_magic_scene_rekey_setup_view(nfc_magic);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_rekey_on_exit(void* context) {
NfcMagic* nfc_magic = context;
nfc_magic_worker_stop(nfc_magic->worker);
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneRekey, NfcMagicSceneRekeyStateCardSearch);
// Clear view
popup_reset(nfc_magic->popup);
nfc_magic_blink_stop(nfc_magic);
}

View File

@@ -1,50 +0,0 @@
#include "../nfc_magic_i.h"
void nfc_magic_scene_rekey_fail_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagic* nfc_magic = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
}
}
void nfc_magic_scene_rekey_fail_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
notification_message(nfc_magic->notifications, &sequence_error);
widget_add_icon_element(widget, 72, 17, &I_DolphinCommon_56x48);
widget_add_string_element(
widget, 7, 4, AlignLeft, AlignTop, FontPrimary, "Can't change password!");
widget_add_button_element(
widget, GuiButtonTypeLeft, "Finish", nfc_magic_scene_rekey_fail_widget_callback, nfc_magic);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
}
bool nfc_magic_scene_rekey_fail_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
}
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_rekey_fail_on_exit(void* context) {
NfcMagic* nfc_magic = context;
widget_reset(nfc_magic->widget);
}

View File

@@ -1,49 +1,51 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
enum SubmenuIndex {
SubmenuIndexCheck,
SubmenuIndexAuthenticateGen4,
};
void nfc_magic_scene_start_submenu_callback(void* context, uint32_t index) {
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, index);
NfcMagicApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, index);
}
void nfc_magic_scene_start_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
Submenu* submenu = nfc_magic->submenu;
Submenu* submenu = instance->submenu;
submenu_add_item(
submenu,
"Check Magic Tag",
SubmenuIndexCheck,
nfc_magic_scene_start_submenu_callback,
nfc_magic);
instance);
submenu_add_item(
submenu,
"Authenticate Gen4",
SubmenuIndexAuthenticateGen4,
nfc_magic_scene_start_submenu_callback,
nfc_magic);
instance);
instance->gen4_password = 0;
submenu_set_selected_item(
submenu, scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneStart));
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewMenu);
submenu, scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneStart));
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewMenu);
}
bool nfc_magic_scene_start_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexCheck) {
nfc_magic->dev->password = MAGIC_GEN4_DEFAULT_PWD;
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneStart, SubmenuIndexCheck);
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneCheck);
instance->scene_manager, NfcMagicSceneStart, SubmenuIndexCheck);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneCheck);
consumed = true;
} else if(event.event == SubmenuIndexAuthenticateGen4) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneKeyInput);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneKeyInput);
}
}
@@ -51,6 +53,7 @@ bool nfc_magic_scene_start_on_event(void* context, SceneManagerEvent event) {
}
void nfc_magic_scene_start_on_exit(void* context) {
NfcMagic* nfc_magic = context;
submenu_reset(nfc_magic->submenu);
NfcMagicApp* instance = context;
submenu_reset(instance->submenu);
}

View File

@@ -1,42 +1,42 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_success_popup_callback(void* context) {
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, NfcMagicCustomEventViewExit);
NfcMagicApp* instance = context;
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcMagicAppCustomEventViewExit);
}
void nfc_magic_scene_success_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
notification_message(nfc_magic->notifications, &sequence_success);
notification_message(instance->notifications, &sequence_success);
Popup* popup = nfc_magic->popup;
Popup* popup = instance->popup;
popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
popup_set_header(popup, "Success!", 10, 20, AlignLeft, AlignBottom);
popup_set_timeout(popup, 1500);
popup_set_context(popup, nfc_magic);
popup_set_context(popup, instance);
popup_set_callback(popup, nfc_magic_scene_success_popup_callback);
popup_enable_timeout(popup);
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
}
bool nfc_magic_scene_success_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicCustomEventViewExit) {
if(event.event == NfcMagicAppCustomEventViewExit) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
instance->scene_manager, NfcMagicSceneStart);
}
}
return consumed;
}
void nfc_magic_scene_success_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
// Clear view
popup_reset(nfc_magic->popup);
popup_reset(instance->popup);
}

View File

@@ -1,97 +1,136 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
enum {
NfcMagicSceneWipeStateCardSearch,
NfcMagicSceneWipeStateCardFound,
};
bool nfc_magic_wipe_worker_callback(NfcMagicWorkerEvent event, void* context) {
furi_assert(context);
NfcCommand nfc_mafic_scene_wipe_gen1_poller_callback(Gen1aPollerEvent event, void* context) {
NfcMagicApp* instance = context;
furi_assert(event.data);
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, event);
NfcCommand command = NfcCommandContinue;
return true;
if(event.type == Gen1aPollerEventTypeDetected) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventCardDetected);
} else if(event.type == Gen1aPollerEventTypeRequestMode) {
event.data->request_mode.mode = Gen1aPollerModeWipe;
} else if(event.type == Gen1aPollerEventTypeSuccess) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
command = NfcCommandStop;
} else if(event.type == Gen1aPollerEventTypeFail) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
command = NfcCommandStop;
}
return command;
}
static void nfc_magic_scene_wipe_setup_view(NfcMagic* nfc_magic) {
Popup* popup = nfc_magic->popup;
NfcCommand nfc_mafic_scene_wipe_gen4_poller_callback(Gen4PollerEvent event, void* context) {
NfcMagicApp* instance = context;
NfcCommand command = NfcCommandContinue;
if(event.type == Gen4PollerEventTypeCardDetected) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventCardDetected);
} else if(event.type == Gen4PollerEventTypeRequestMode) {
event.data->request_mode.mode = Gen4PollerModeWipe;
} else if(event.type == Gen4PollerEventTypeSuccess) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
command = NfcCommandStop;
} else if(event.type == Gen4PollerEventTypeFail) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
command = NfcCommandStop;
}
return command;
}
static void nfc_magic_scene_wipe_setup_view(NfcMagicApp* instance) {
Popup* popup = instance->popup;
popup_reset(popup);
uint32_t state = scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneWipe);
uint32_t state = scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneWipe);
if(state == NfcMagicSceneWipeStateCardSearch) {
popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_text(
nfc_magic->popup,
"Apply the\nsame card\nto the back",
128,
32,
AlignRight,
AlignCenter);
instance->popup, "Apply the\nsame card\nto the back", 128, 32, AlignRight, AlignCenter);
} else {
popup_set_icon(popup, 12, 23, &I_Loading_24);
popup_set_header(popup, "Wiping\nDon't move...", 52, 32, AlignLeft, AlignCenter);
}
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
}
void nfc_magic_scene_wipe_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
nfc_magic_scene_wipe_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
nfc_magic_scene_wipe_setup_view(instance);
// Setup and start worker
nfc_magic_worker_start(
nfc_magic->worker,
NfcMagicWorkerStateWipe,
nfc_magic->dev,
&nfc_magic->source_dev->dev_data,
nfc_magic->new_password,
nfc_magic_wipe_worker_callback,
nfc_magic);
nfc_magic_blink_start(nfc_magic);
nfc_magic_app_blink_start(instance);
if(instance->protocol == NfcMagicProtocolGen1) {
instance->gen1a_poller = gen1a_poller_alloc(instance->nfc);
gen1a_poller_start(
instance->gen1a_poller, nfc_mafic_scene_wipe_gen1_poller_callback, instance);
} else {
instance->gen4_poller = gen4_poller_alloc(instance->nfc);
gen4_poller_set_password(instance->gen4_poller, instance->gen4_password);
gen4_poller_start(
instance->gen4_poller, nfc_mafic_scene_wipe_gen4_poller_callback, instance);
}
}
bool nfc_magic_scene_wipe_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicWorkerEventSuccess) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicWorkerEventFail) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWipeFail);
consumed = true;
} else if(event.event == NfcMagicWorkerEventWrongCard) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneNotMagic);
consumed = true;
} else if(event.event == NfcMagicWorkerEventCardDetected) {
if(event.event == NfcMagicCustomEventCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardFound);
nfc_magic_scene_wipe_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardFound);
nfc_magic_scene_wipe_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicWorkerEventNoCardDetected) {
} else if(event.event == NfcMagicCustomEventCardLost) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
nfc_magic_scene_wipe_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
nfc_magic_scene_wipe_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerSuccess) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerFail) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWipeFail);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_wipe_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
nfc_magic_worker_stop(nfc_magic->worker);
if(instance->protocol == NfcMagicProtocolGen1) {
gen1a_poller_stop(instance->gen1a_poller);
gen1a_poller_free(instance->gen1a_poller);
} else {
gen4_poller_stop(instance->gen4_poller);
gen4_poller_free(instance->gen4_poller);
}
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
instance->scene_manager, NfcMagicSceneWipe, NfcMagicSceneWipeStateCardSearch);
// Clear view
popup_reset(nfc_magic->popup);
popup_reset(instance->popup);
nfc_magic_blink_stop(nfc_magic);
nfc_magic_app_blink_stop(instance);
}

View File

@@ -1,41 +1,43 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_wipe_fail_widget_callback(GuiButtonType result, InputType type, void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_wipe_fail_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
NfcMagicApp* instance = context;
notification_message(nfc_magic->notifications, &sequence_error);
Widget* widget = instance->widget;
notification_message(instance->notifications, &sequence_error);
widget_add_icon_element(widget, 73, 17, &I_DolphinCommon_56x48);
widget_add_string_element(widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Wipe failed");
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wipe_fail_widget_callback, nfc_magic);
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wipe_fail_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_wipe_fail_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
consumed = scene_manager_previous_scene(instance->scene_manager);
}
}
return consumed;
}
void nfc_magic_scene_wipe_fail_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}

View File

@@ -1,97 +1,144 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
enum {
NfcMagicSceneWriteStateCardSearch,
NfcMagicSceneWriteStateCardFound,
};
bool nfc_magic_write_worker_callback(NfcMagicWorkerEvent event, void* context) {
furi_assert(context);
NfcCommand nfc_mafic_scene_write_gen1_poller_callback(Gen1aPollerEvent event, void* context) {
NfcMagicApp* instance = context;
furi_assert(event.data);
NfcMagic* nfc_magic = context;
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, event);
NfcCommand command = NfcCommandContinue;
return true;
if(event.type == Gen1aPollerEventTypeDetected) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventCardDetected);
} else if(event.type == Gen1aPollerEventTypeRequestMode) {
event.data->request_mode.mode = Gen1aPollerModeWrite;
} else if(event.type == Gen1aPollerEventTypeRequestDataToWrite) {
const MfClassicData* mfc_data =
nfc_device_get_data(instance->source_dev, NfcProtocolMfClassic);
event.data->data_to_write.mfc_data = mfc_data;
} else if(event.type == Gen1aPollerEventTypeSuccess) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
command = NfcCommandStop;
} else if(event.type == Gen1aPollerEventTypeFail) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
command = NfcCommandStop;
}
return command;
}
static void nfc_magic_scene_write_setup_view(NfcMagic* nfc_magic) {
Popup* popup = nfc_magic->popup;
NfcCommand nfc_mafic_scene_write_gen4_poller_callback(Gen4PollerEvent event, void* context) {
NfcMagicApp* instance = context;
furi_assert(event.data);
NfcCommand command = NfcCommandContinue;
if(event.type == Gen4PollerEventTypeCardDetected) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventCardDetected);
} else if(event.type == Gen4PollerEventTypeRequestMode) {
event.data->request_mode.mode = Gen4PollerModeWrite;
} else if(event.type == Gen4PollerEventTypeRequestDataToWrite) {
NfcProtocol protocol = nfc_device_get_protocol(instance->source_dev);
event.data->request_data.protocol = protocol;
event.data->request_data.data = nfc_device_get_data(instance->source_dev, protocol);
} else if(event.type == Gen4PollerEventTypeSuccess) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerSuccess);
command = NfcCommandStop;
} else if(event.type == Gen4PollerEventTypeFail) {
view_dispatcher_send_custom_event(
instance->view_dispatcher, NfcMagicCustomEventWorkerFail);
command = NfcCommandStop;
}
return command;
}
static void nfc_magic_scene_write_setup_view(NfcMagicApp* instance) {
Popup* popup = instance->popup;
popup_reset(popup);
uint32_t state = scene_manager_get_scene_state(nfc_magic->scene_manager, NfcMagicSceneWrite);
uint32_t state = scene_manager_get_scene_state(instance->scene_manager, NfcMagicSceneWrite);
if(state == NfcMagicSceneWriteStateCardSearch) {
popup_set_icon(instance->popup, 0, 8, &I_NFC_manual_60x50);
popup_set_text(
nfc_magic->popup,
"Apply the\nsame card\nto the back",
128,
32,
AlignRight,
AlignCenter);
popup_set_icon(nfc_magic->popup, 0, 8, &I_NFC_manual_60x50);
instance->popup, "Apply the\nsame card\nto the back", 128, 32, AlignRight, AlignCenter);
} else {
popup_set_icon(popup, 12, 23, &I_Loading_24);
popup_set_header(popup, "Writing\nDon't move...", 52, 32, AlignLeft, AlignCenter);
}
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewPopup);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewPopup);
}
void nfc_magic_scene_write_on_enter(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
nfc_magic_scene_write_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
nfc_magic_scene_write_setup_view(instance);
// Setup and start worker
nfc_magic_worker_start(
nfc_magic->worker,
NfcMagicWorkerStateWrite,
nfc_magic->dev,
&nfc_magic->source_dev->dev_data,
nfc_magic->new_password,
nfc_magic_write_worker_callback,
nfc_magic);
nfc_magic_blink_start(nfc_magic);
nfc_magic_app_blink_start(instance);
if(instance->protocol == NfcMagicProtocolGen1) {
instance->gen1a_poller = gen1a_poller_alloc(instance->nfc);
gen1a_poller_start(
instance->gen1a_poller, nfc_mafic_scene_write_gen1_poller_callback, instance);
} else {
instance->gen4_poller = gen4_poller_alloc(instance->nfc);
gen4_poller_start(
instance->gen4_poller, nfc_mafic_scene_write_gen4_poller_callback, instance);
}
}
bool nfc_magic_scene_write_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcMagicWorkerEventSuccess) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicWorkerEventFail) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWriteFail);
consumed = true;
} else if(event.event == NfcMagicWorkerEventWrongCard) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneNotMagic);
consumed = true;
} else if(event.event == NfcMagicWorkerEventCardDetected) {
if(event.event == NfcMagicCustomEventCardDetected) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardFound);
nfc_magic_scene_write_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardFound);
nfc_magic_scene_write_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicWorkerEventNoCardDetected) {
} else if(event.event == NfcMagicCustomEventCardLost) {
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
nfc_magic_scene_write_setup_view(nfc_magic);
instance->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
nfc_magic_scene_write_setup_view(instance);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerSuccess) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneSuccess);
consumed = true;
} else if(event.event == NfcMagicCustomEventWorkerFail) {
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWriteFail);
consumed = true;
}
}
return consumed;
}
void nfc_magic_scene_write_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
nfc_magic_worker_stop(nfc_magic->worker);
if(instance->protocol == NfcMagicProtocolGen1) {
gen1a_poller_stop(instance->gen1a_poller);
gen1a_poller_free(instance->gen1a_poller);
} else {
gen4_poller_stop(instance->gen4_poller);
gen4_poller_free(instance->gen4_poller);
}
scene_manager_set_scene_state(
nfc_magic->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
instance->scene_manager, NfcMagicSceneWrite, NfcMagicSceneWriteStateCardSearch);
// Clear view
popup_reset(nfc_magic->popup);
popup_reset(instance->popup);
nfc_magic_blink_stop(nfc_magic);
nfc_magic_app_blink_stop(instance);
}

View File

@@ -1,18 +1,19 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_write_confirm_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_write_confirm_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
widget_add_string_element(widget, 3, 0, AlignLeft, AlignTop, FontPrimary, "Risky operation");
widget_add_text_box_element(
@@ -30,27 +31,23 @@ void nfc_magic_scene_write_confirm_on_enter(void* context) {
GuiButtonTypeCenter,
"Continue",
nfc_magic_scene_write_confirm_widget_callback,
nfc_magic);
instance);
widget_add_button_element(
widget,
GuiButtonTypeLeft,
"Back",
nfc_magic_scene_write_confirm_widget_callback,
nfc_magic);
widget, GuiButtonTypeLeft, "Back", nfc_magic_scene_write_confirm_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_write_confirm_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
consumed = scene_manager_previous_scene(instance->scene_manager);
} else if(event.event == GuiButtonTypeCenter) {
scene_manager_next_scene(nfc_magic->scene_manager, NfcMagicSceneWrite);
scene_manager_next_scene(instance->scene_manager, NfcMagicSceneWrite);
consumed = true;
}
}
@@ -58,7 +55,7 @@ bool nfc_magic_scene_write_confirm_on_event(void* context, SceneManagerEvent eve
}
void nfc_magic_scene_write_confirm_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}

View File

@@ -1,20 +1,20 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_write_fail_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_write_fail_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
notification_message(nfc_magic->notifications, &sequence_error);
notification_message(instance->notifications, &sequence_error);
widget_add_icon_element(widget, 72, 17, &I_DolphinCommon_56x48);
widget_add_string_element(
@@ -29,30 +29,30 @@ void nfc_magic_scene_write_fail_on_enter(void* context) {
"Not all sectors\nwere written\ncorrectly.");
widget_add_button_element(
widget, GuiButtonTypeLeft, "Finish", nfc_magic_scene_write_fail_widget_callback, nfc_magic);
widget, GuiButtonTypeLeft, "Finish", nfc_magic_scene_write_fail_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_write_fail_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
instance->scene_manager, NfcMagicSceneStart);
}
} else if(event.type == SceneManagerEventTypeBack) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc_magic->scene_manager, NfcMagicSceneStart);
instance->scene_manager, NfcMagicSceneStart);
}
return consumed;
}
void nfc_magic_scene_write_fail_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}

View File

@@ -1,20 +1,20 @@
#include "../nfc_magic_i.h"
#include "../nfc_magic_app_i.h"
void nfc_magic_scene_wrong_card_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
view_dispatcher_send_custom_event(instance->view_dispatcher, result);
}
}
void nfc_magic_scene_wrong_card_on_enter(void* context) {
NfcMagic* nfc_magic = context;
Widget* widget = nfc_magic->widget;
NfcMagicApp* instance = context;
Widget* widget = instance->widget;
notification_message(nfc_magic->notifications, &sequence_error);
notification_message(instance->notifications, &sequence_error);
widget_add_icon_element(widget, 73, 17, &I_DolphinCommon_56x48);
widget_add_string_element(
@@ -28,26 +28,26 @@ void nfc_magic_scene_wrong_card_on_enter(void* context) {
FontSecondary,
"Writing this file is\nnot supported for\nthis magic card.");
widget_add_button_element(
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wrong_card_widget_callback, nfc_magic);
widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wrong_card_widget_callback, instance);
// Setup and start worker
view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
}
bool nfc_magic_scene_wrong_card_on_event(void* context, SceneManagerEvent event) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
consumed = scene_manager_previous_scene(instance->scene_manager);
}
}
return consumed;
}
void nfc_magic_scene_wrong_card_on_exit(void* context) {
NfcMagic* nfc_magic = context;
NfcMagicApp* instance = context;
widget_reset(nfc_magic->widget);
widget_reset(instance->widget);
}