[FL-1448], [FL-1529] Introducing Scene Manager, NFC App refactoring and bug fixes (#575)
* gui: refactore ViewNavigator -> SceneManager * view_dispatcher: remove scene controller, add custom and navigation cb * scene_manager: rework scene controller, move AppScene from lib * nfc: rework nfc scenes with new scene controller API * view_dispatcher: crash on free if not all views were freed * nfc: introduce scene declaration * scene_manager: allocate and configure application scenes * nfc: rework nfc with new Scene Manager API * scene_manager: remove dublicated scene handlers allocation * nfc: rework nfc app with new scene manager API * view_dispatcher: add tick event * scene_manager: add tick event type and handler * nfc: rework notifications with tick event * scene_manager: remove scene id from scene structure * scene_manager: rename array -> stack, add documentation * api-hal-nfc: remove listen activation processing * nfc_scene_start: shorter submenu call * nfc: fix nfc file name * nfc: fix Retry in mifare ul success read * nfc_cli: fix read timeout in nfc_detect CLI command Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -1,14 +1,38 @@
|
||||
#include "nfc_i.h"
|
||||
#include "api-hal-nfc.h"
|
||||
#include "app_scene.h"
|
||||
|
||||
bool nfc_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
return scene_manager_handle_custom_event(nfc->scene_manager, event);
|
||||
}
|
||||
|
||||
bool nfc_navigation_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
return scene_manager_handle_navigation_event(nfc->scene_manager);
|
||||
}
|
||||
|
||||
void nfc_tick_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
scene_manager_handle_tick_event(nfc->scene_manager);
|
||||
}
|
||||
|
||||
Nfc* nfc_alloc() {
|
||||
Nfc* nfc = furi_alloc(sizeof(Nfc));
|
||||
|
||||
nfc->nfc_common.worker = nfc_worker_alloc();
|
||||
nfc->nfc_common.view_dispatcher = view_dispatcher_alloc();
|
||||
nfc->scene_manager = scene_manager_alloc(&nfc_scene_handlers, nfc);
|
||||
view_dispatcher_enable_queue(nfc->nfc_common.view_dispatcher);
|
||||
view_dispatcher_enable_navigation(nfc->nfc_common.view_dispatcher, nfc);
|
||||
view_dispatcher_set_event_callback_context(nfc->nfc_common.view_dispatcher, nfc);
|
||||
view_dispatcher_set_custom_event_callback(
|
||||
nfc->nfc_common.view_dispatcher, nfc_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
nfc->nfc_common.view_dispatcher, nfc_navigation_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(
|
||||
nfc->nfc_common.view_dispatcher, nfc_tick_event_callback, 300);
|
||||
|
||||
// Open GUI record
|
||||
nfc->gui = furi_record_open("gui");
|
||||
@@ -71,32 +95,8 @@ Nfc* nfc_alloc() {
|
||||
NfcViewMifareUl,
|
||||
nfc_mifare_ul_get_view(nfc->nfc_mifare_ul));
|
||||
|
||||
// Scene allocation
|
||||
nfc->scene_start = nfc_scene_start_alloc();
|
||||
nfc->scene_read_card = nfc_scene_read_card_alloc();
|
||||
nfc->scene_read_card_success = nfc_scene_read_card_success_alloc();
|
||||
nfc->scene_card_menu = nfc_scene_card_menu_alloc();
|
||||
nfc->scene_not_implemented = nfc_scene_not_implemented_alloc();
|
||||
nfc->scene_debug_menu = nfc_scene_debug_menu_alloc();
|
||||
nfc->scene_debug_detect = nfc_scene_debug_detect_alloc();
|
||||
nfc->scene_debug_emulate = nfc_scene_debug_emulate_alloc();
|
||||
nfc->scene_debug_read_emv = nfc_scene_debug_read_emv_alloc();
|
||||
nfc->scene_debug_read_mifare_ul = nfc_scene_debug_read_mifare_ul_alloc();
|
||||
nfc->scene_emulate_uid = nfc_scene_emulate_uid_alloc();
|
||||
nfc->scene_save_name = nfc_scene_save_name_alloc();
|
||||
nfc->scene_save_success = nfc_scene_save_success_alloc();
|
||||
nfc->scene_file_select = nfc_scene_file_select_alloc();
|
||||
nfc->scene_saved_menu = nfc_scene_saved_menu_alloc();
|
||||
nfc->scene_set_type = nfc_scene_set_type_alloc();
|
||||
nfc->scene_set_sak = nfc_scene_set_sak_alloc();
|
||||
nfc->scene_set_atqa = nfc_scene_set_atqa_alloc();
|
||||
nfc->scene_set_uid = nfc_scene_set_uid_alloc();
|
||||
nfc->scene_scripts_menu = nfc_scene_scripts_menu_alloc();
|
||||
nfc->scene_read_mifare_ul = nfc_scene_read_mifare_ul_alloc();
|
||||
nfc->scene_read_mifare_ul_success = nfc_scene_read_mifare_ul_success_alloc();
|
||||
nfc->scene_mifare_ul_menu = nfc_scene_mifare_ul_menu_alloc();
|
||||
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_start);
|
||||
// Run first scene
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneStart);
|
||||
|
||||
return nfc;
|
||||
}
|
||||
@@ -149,34 +149,12 @@ void nfc_free(Nfc* nfc) {
|
||||
nfc_worker_stop(nfc->nfc_common.worker);
|
||||
nfc_worker_free(nfc->nfc_common.worker);
|
||||
|
||||
// Scenes
|
||||
nfc_scene_start_free(nfc->scene_start);
|
||||
nfc_scene_read_card_free(nfc->scene_read_card);
|
||||
nfc_scene_read_card_success_free(nfc->scene_read_card_success);
|
||||
nfc_scene_card_menu_free(nfc->scene_card_menu);
|
||||
nfc_scene_not_implemented_free(nfc->scene_not_implemented);
|
||||
nfc_scene_debug_menu_free(nfc->scene_debug_menu);
|
||||
nfc_scene_debug_detect_free(nfc->scene_debug_detect);
|
||||
nfc_scene_debug_emulate_free(nfc->scene_debug_emulate);
|
||||
nfc_scene_debug_read_emv_free(nfc->scene_debug_read_emv);
|
||||
nfc_scene_debug_read_mifare_ul_free(nfc->scene_debug_read_mifare_ul);
|
||||
nfc_scene_emulate_uid_free(nfc->scene_emulate_uid);
|
||||
nfc_scene_save_name_free(nfc->scene_save_name);
|
||||
nfc_scene_save_success_free(nfc->scene_save_success);
|
||||
nfc_scene_file_select_free(nfc->scene_file_select);
|
||||
nfc_scene_saved_menu_free(nfc->scene_saved_menu);
|
||||
nfc_scene_set_type_free(nfc->scene_set_type);
|
||||
nfc_scene_set_sak_free(nfc->scene_set_sak);
|
||||
nfc_scene_set_atqa_free(nfc->scene_set_atqa);
|
||||
nfc_scene_set_uid_free(nfc->scene_set_uid);
|
||||
nfc_scene_scripts_menu_free(nfc->scene_scripts_menu);
|
||||
nfc_scene_read_mifare_ul_free(nfc->scene_read_mifare_ul);
|
||||
nfc_scene_read_mifare_ul_success_free(nfc->scene_read_mifare_ul_success);
|
||||
nfc_scene_mifare_ul_menu_free(nfc->scene_mifare_ul_menu);
|
||||
|
||||
// View Dispatcher
|
||||
view_dispatcher_free(nfc->nfc_common.view_dispatcher);
|
||||
|
||||
// Scene Manager
|
||||
scene_manager_free(nfc->scene_manager);
|
||||
|
||||
// GUI
|
||||
furi_record_close("gui");
|
||||
nfc->gui = NULL;
|
||||
@@ -198,7 +176,7 @@ int32_t nfc_task(void* p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nfc_set_text_store(Nfc* nfc, const char* text, ...) {
|
||||
void nfc_text_store_set(Nfc* nfc, const char* text, ...) {
|
||||
va_list args;
|
||||
va_start(args, text);
|
||||
|
||||
@@ -206,3 +184,7 @@ void nfc_set_text_store(Nfc* nfc, const char* text, ...) {
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void nfc_text_store_clear(Nfc* nfc) {
|
||||
memset(nfc->text_store, 0, sizeof(nfc->text_store));
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ void nfc_cli_detect(Cli* cli, string_t args, void* context) {
|
||||
printf("Detecting nfc...\r\nPress Ctrl+C to abort\r\n");
|
||||
while(!cmd_exit) {
|
||||
cmd_exit |= cli_cmd_interrupt_received(cli);
|
||||
cmd_exit |= api_hal_nfc_detect(&dev_list, &dev_cnt, 1000, true);
|
||||
cmd_exit |= api_hal_nfc_detect(&dev_list, &dev_cnt, 200, true);
|
||||
if(dev_cnt > 0) {
|
||||
printf("Found %d devices\r\n", dev_cnt);
|
||||
for(uint8_t i = 0; i < dev_cnt; i++) {
|
||||
@@ -57,7 +57,7 @@ void nfc_cli_emulate(Cli* cli, string_t args, void* context) {
|
||||
printf("Press Ctrl+C to abort\r\n");
|
||||
|
||||
NfcDeviceData params = {
|
||||
.uid = {0x36, 0x9C, 0xe7, 0xb1, 0x0A, 0xC1},
|
||||
.uid = {0x36, 0x9C, 0xe7, 0xb1, 0x0A, 0xC1, 0x34},
|
||||
.uid_len = 7,
|
||||
.atqa = {0x44, 0x00},
|
||||
.sak = 0x00,
|
||||
|
@@ -25,7 +25,7 @@ bool nfc_device_save(NfcDevice* dev, const char* dev_name) {
|
||||
};
|
||||
|
||||
// First remove nfc device file if it was saved
|
||||
string_init_printf(dev_file_name, "%s/%s%s", nfc_app_folder, dev->dev_name, nfc_app_extension);
|
||||
string_init_printf(dev_file_name, "%s/%s%s", nfc_app_folder, dev_name, nfc_app_extension);
|
||||
if(!file_worker_remove(file_worker, string_get_cstr(dev_file_name))) {
|
||||
string_clear(dev_file_name);
|
||||
return false;
|
||||
@@ -73,7 +73,7 @@ static bool nfc_device_load_data(FileWorker* file_worker, string_t path, NfcDevi
|
||||
return false;
|
||||
}
|
||||
|
||||
// // Load other data
|
||||
// Load other data
|
||||
if(!file_worker_read_hex(file_worker, &buff[1], buff[0] + 3)) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <cli/cli.h>
|
||||
#include <notification/notification-messages.h>
|
||||
|
||||
@@ -20,43 +21,20 @@
|
||||
#include <gui/modules/byte_input.h>
|
||||
#include <gui/modules/text_box.h>
|
||||
|
||||
#include <nfc/scenes/nfc_scene.h>
|
||||
|
||||
#include "views/nfc_detect.h"
|
||||
#include "views/nfc_emulate.h"
|
||||
#include "views/nfc_emv.h"
|
||||
#include "views/nfc_mifare_ul.h"
|
||||
|
||||
#include "scenes/nfc_scene_start.h"
|
||||
#include "scenes/nfc_scene_read_card.h"
|
||||
#include "scenes/nfc_scene_read_card_success.h"
|
||||
#include "scenes/nfc_scene_card_menu.h"
|
||||
#include "scenes/nfc_scene_emulate_uid.h"
|
||||
#include "scenes/nfc_scene_not_implemented.h"
|
||||
#include "scenes/nfc_scene_save_name.h"
|
||||
#include "scenes/nfc_scene_save_success.h"
|
||||
#include "scenes/nfc_scene_file_select.h"
|
||||
#include "scenes/nfc_scene_saved_menu.h"
|
||||
#include "scenes/nfc_scene_set_type.h"
|
||||
#include "scenes/nfc_scene_set_sak.h"
|
||||
#include "scenes/nfc_scene_set_atqa.h"
|
||||
#include "scenes/nfc_scene_set_uid.h"
|
||||
#include "scenes/nfc_scene_scripts_menu.h"
|
||||
#include "scenes/nfc_scene_read_mifare_ul.h"
|
||||
#include "scenes/nfc_scene_read_mifare_ul_success.h"
|
||||
#include "scenes/nfc_scene_mifare_ul_menu.h"
|
||||
|
||||
// TODO delete debug scenes
|
||||
#include "scenes/nfc_scene_debug_menu.h"
|
||||
#include "scenes/nfc_scene_debug_detect.h"
|
||||
#include "scenes/nfc_scene_debug_emulate.h"
|
||||
#include "scenes/nfc_scene_debug_read_emv.h"
|
||||
#include "scenes/nfc_scene_debug_read_mifare_ul.h"
|
||||
|
||||
#define NFC_TEXT_STORE_SIZE 128
|
||||
|
||||
struct Nfc {
|
||||
NfcCommon nfc_common;
|
||||
Gui* gui;
|
||||
NotificationApp* notifications;
|
||||
SceneManager* scene_manager;
|
||||
NfcDevice device;
|
||||
|
||||
char text_store[NFC_TEXT_STORE_SIZE + 1];
|
||||
@@ -75,33 +53,6 @@ struct Nfc {
|
||||
TextInput* text_input;
|
||||
ByteInput* byte_input;
|
||||
TextBox* text_box;
|
||||
|
||||
// Scenes
|
||||
AppScene* scene_start;
|
||||
AppScene* scene_read_card;
|
||||
AppScene* scene_read_card_success;
|
||||
AppScene* scene_card_menu;
|
||||
AppScene* scene_not_implemented;
|
||||
AppScene* scene_emulate_uid;
|
||||
AppScene* scene_save_name;
|
||||
AppScene* scene_save_success;
|
||||
AppScene* scene_file_select;
|
||||
AppScene* scene_saved_menu;
|
||||
AppScene* scene_set_type;
|
||||
AppScene* scene_set_sak;
|
||||
AppScene* scene_set_atqa;
|
||||
AppScene* scene_set_uid;
|
||||
AppScene* scene_scripts_menu;
|
||||
AppScene* scene_read_mifare_ul;
|
||||
AppScene* scene_read_mifare_ul_success;
|
||||
AppScene* scene_mifare_ul_menu;
|
||||
|
||||
// TODO delete debug scenes
|
||||
AppScene* scene_debug_menu;
|
||||
AppScene* scene_debug_detect;
|
||||
AppScene* scene_debug_emulate;
|
||||
AppScene* scene_debug_read_emv;
|
||||
AppScene* scene_debug_read_mifare_ul;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -117,34 +68,10 @@ typedef enum {
|
||||
NfcViewMifareUl,
|
||||
} NfcView;
|
||||
|
||||
typedef enum {
|
||||
NfcSceneStart,
|
||||
NfcSceneReadCard,
|
||||
NfcSceneReadCardSuccess,
|
||||
NfcSceneCardMenu,
|
||||
NfcSceneEmulateUID,
|
||||
NfcSceneNotImplemented,
|
||||
NfcSceneDebugMenu,
|
||||
NfcSceneDebugDetect,
|
||||
NfcSceneDebugEmulate,
|
||||
NfcSceneDebugReadEmv,
|
||||
NfcSceneDebugReadMifareUl,
|
||||
NfcSceneSaveName,
|
||||
NfcSceneSaveSuccess,
|
||||
NfcSceneFileSelect,
|
||||
NfcSceneSavedMenu,
|
||||
NfcSceneSetType,
|
||||
NfcSceneSetSak,
|
||||
NfcSceneSetAtqa,
|
||||
NfcSceneSetUid,
|
||||
NfcSceneScriptsMenu,
|
||||
NfcSceneReadMifareUl,
|
||||
NfcSceneReadMifareUlSuccess,
|
||||
NfcSceneReadMifareUlMenu,
|
||||
} NfcScene;
|
||||
|
||||
Nfc* nfc_alloc();
|
||||
|
||||
int32_t nfc_task(void* p);
|
||||
|
||||
void nfc_set_text_store(Nfc* nfc, const char* text, ...);
|
||||
void nfc_text_store_set(Nfc* nfc, const char* text, ...);
|
||||
|
||||
void nfc_text_store_clear(Nfc* nfc);
|
||||
|
30
applications/nfc/scenes/nfc_scene.c
Executable file
30
applications/nfc/scenes/nfc_scene.c
Executable file
@@ -0,0 +1,30 @@
|
||||
#include "nfc_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const nfc_on_enter_handlers[])(void*) = {
|
||||
#include "nfc_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event,
|
||||
bool (*const nfc_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "nfc_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit,
|
||||
void (*const nfc_on_exit_handlers[])(void* context) = {
|
||||
#include "nfc_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers nfc_scene_handlers = {
|
||||
.on_enter_handlers = nfc_on_enter_handlers,
|
||||
.on_event_handlers = nfc_on_event_handlers,
|
||||
.on_exit_handlers = nfc_on_exit_handlers,
|
||||
.scene_num = NfcSceneNum,
|
||||
};
|
29
applications/nfc/scenes/nfc_scene.h
Normal file
29
applications/nfc/scenes/nfc_scene.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) NfcScene##id,
|
||||
typedef enum {
|
||||
#include "nfc_scene_config.h"
|
||||
NfcSceneNum,
|
||||
} NfcScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers nfc_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "nfc_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_event handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) \
|
||||
bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event);
|
||||
#include "nfc_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Generate scene on_exit handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context);
|
||||
#include "nfc_scene_config.h"
|
||||
#undef ADD_SCENE
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_card_menu.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexRunApp,
|
||||
SubmenuIndexChooseScript,
|
||||
@@ -38,37 +33,38 @@ const void nfc_scene_card_menu_on_enter(void* context) {
|
||||
submenu, "Emulate UID", SubmenuIndexEmulate, nfc_scene_card_menu_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
submenu, "Name and save UID", SubmenuIndexSave, nfc_scene_card_menu_submenu_callback, nfc);
|
||||
submenu_set_selected_item(
|
||||
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneCardMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_card_menu_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_card_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexRunApp) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexChooseScript) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexEmulate) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_emulate_uid);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexSave) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_save_name);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == ViewNavigatorEventBack) {
|
||||
view_dispatcher_send_back_search_scene_event(
|
||||
nfc->nfc_common.view_dispatcher, NfcSceneStart);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexRunApp) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneCardMenu, SubmenuIndexRunApp);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexChooseScript) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneCardMenu, SubmenuIndexChooseScript);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEmulate) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneCardMenu, SubmenuIndexEmulate);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexSave) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneCardMenu, SubmenuIndexSave);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeNavigation) {
|
||||
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -79,17 +75,3 @@ const void nfc_scene_card_menu_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_card_menu_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneCardMenu;
|
||||
scene->on_enter = nfc_scene_card_menu_on_enter;
|
||||
scene->on_event = nfc_scene_card_menu_on_event;
|
||||
scene->on_exit = nfc_scene_card_menu_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_card_menu_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_card_menu_alloc();
|
||||
|
||||
void nfc_scene_card_menu_free(AppScene* scene);
|
23
applications/nfc/scenes/nfc_scene_config.h
Executable file
23
applications/nfc/scenes/nfc_scene_config.h
Executable file
@@ -0,0 +1,23 @@
|
||||
ADD_SCENE(nfc, start, Start)
|
||||
ADD_SCENE(nfc, read_card, ReadCard)
|
||||
ADD_SCENE(nfc, read_card_success, ReadCardSuccess)
|
||||
ADD_SCENE(nfc, card_menu, CardMenu)
|
||||
ADD_SCENE(nfc, not_implemented, NotImplemented)
|
||||
ADD_SCENE(nfc, emulate_uid, EmulateUid)
|
||||
ADD_SCENE(nfc, save_name, SaveName)
|
||||
ADD_SCENE(nfc, save_success, SaveSuccess)
|
||||
ADD_SCENE(nfc, file_select, FileSelect)
|
||||
ADD_SCENE(nfc, saved_menu, SavedMenu)
|
||||
ADD_SCENE(nfc, set_type, SetType)
|
||||
ADD_SCENE(nfc, set_sak, SetSak)
|
||||
ADD_SCENE(nfc, set_atqa, SetAtqua)
|
||||
ADD_SCENE(nfc, set_uid, SetUid)
|
||||
ADD_SCENE(nfc, scripts_menu, ScriptsMenu)
|
||||
ADD_SCENE(nfc, read_mifare_ul, ReadMifareUl)
|
||||
ADD_SCENE(nfc, read_mifare_ul_success, ReadMifareUlSuccess)
|
||||
ADD_SCENE(nfc, mifare_ul_menu, MifareUlMenu)
|
||||
ADD_SCENE(nfc, debug_menu, DebugMenu)
|
||||
ADD_SCENE(nfc, debug_detect, DebugDetect)
|
||||
ADD_SCENE(nfc, debug_emulate, DebugEmulate)
|
||||
ADD_SCENE(nfc, debug_read_emv, DebugReadEmv)
|
||||
ADD_SCENE(nfc, debug_read_mifare_ul, DebugReadMifareUl)
|
@@ -1,31 +1,14 @@
|
||||
#include "nfc_scene_debug_detect.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
const void nfc_scene_debug_detect_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDetect);
|
||||
}
|
||||
|
||||
const bool nfc_scene_debug_detect_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_debug_detect_on_event(void* context, SceneManagerEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void nfc_scene_debug_detect_on_exit(void* context) {
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_debug_detect_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneDebugDetect;
|
||||
scene->on_enter = nfc_scene_debug_detect_on_enter;
|
||||
scene->on_event = nfc_scene_debug_detect_on_event;
|
||||
scene->on_exit = nfc_scene_debug_detect_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_debug_detect_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_debug_detect_alloc();
|
||||
|
||||
void nfc_scene_debug_detect_free(AppScene* scene);
|
@@ -1,31 +1,14 @@
|
||||
#include "nfc_scene_debug_emulate.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
const void nfc_scene_debug_emulate_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewEmulate);
|
||||
}
|
||||
|
||||
const bool nfc_scene_debug_emulate_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_debug_emulate_on_event(void* context, SceneManagerEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void nfc_scene_debug_emulate_on_exit(void* context) {
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_debug_emulate_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneDebugEmulate;
|
||||
scene->on_enter = nfc_scene_debug_emulate_on_enter;
|
||||
scene->on_event = nfc_scene_debug_emulate_on_event;
|
||||
scene->on_exit = nfc_scene_debug_emulate_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_debug_emulate_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_debug_emulate_alloc();
|
||||
|
||||
void nfc_scene_debug_emulate_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_debug_menu.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexDetect,
|
||||
SubmenuIndexEmulate,
|
||||
@@ -34,34 +29,37 @@ const void nfc_scene_debug_menu_on_enter(void* context) {
|
||||
SubmenuIndexReadMifareUl,
|
||||
nfc_scene_debug_menu_submenu_callback,
|
||||
nfc);
|
||||
submenu_set_selected_item(
|
||||
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneDebugMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_debug_menu_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_debug_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexDetect) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_debug_detect);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexEmulate) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_debug_emulate);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexReadEmv) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_debug_read_emv);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexReadMifareUl) {
|
||||
view_dispatcher_add_scene(
|
||||
nfc->nfc_common.view_dispatcher, nfc->scene_debug_read_mifare_ul);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexDetect) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDebugMenu, SubmenuIndexDetect);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDebugDetect);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEmulate) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDebugMenu, SubmenuIndexEmulate);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDebugEmulate);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexReadEmv) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDebugMenu, SubmenuIndexReadEmv);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDebugReadEmv);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexReadMifareUl) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneDebugMenu, SubmenuIndexReadMifareUl);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDebugReadMifareUl);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -72,17 +70,3 @@ const void nfc_scene_debug_menu_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_debug_menu_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneDebugMenu;
|
||||
scene->on_enter = nfc_scene_debug_menu_on_enter;
|
||||
scene->on_event = nfc_scene_debug_menu_on_event;
|
||||
scene->on_exit = nfc_scene_debug_menu_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_debug_menu_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_debug_menu_alloc();
|
||||
|
||||
void nfc_scene_debug_menu_free(AppScene* scene);
|
@@ -1,31 +1,14 @@
|
||||
#include "nfc_scene_debug_read_emv.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
const void nfc_scene_debug_read_emv_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewEmv);
|
||||
}
|
||||
|
||||
const bool nfc_scene_debug_read_emv_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_debug_read_emv_on_event(void* context, SceneManagerEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void nfc_scene_debug_read_emv_on_exit(void* context) {
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_debug_read_emv_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneDebugReadEmv;
|
||||
scene->on_enter = nfc_scene_debug_read_emv_on_enter;
|
||||
scene->on_event = nfc_scene_debug_read_emv_on_event;
|
||||
scene->on_exit = nfc_scene_debug_read_emv_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_debug_read_emv_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_debug_read_emv_alloc();
|
||||
|
||||
void nfc_scene_debug_read_emv_free(AppScene* scene);
|
@@ -1,31 +1,14 @@
|
||||
#include "nfc_scene_debug_read_mifare_ul.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
const void nfc_scene_debug_read_mifare_ul_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMifareUl);
|
||||
}
|
||||
|
||||
const bool nfc_scene_debug_read_mifare_ul_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_debug_read_mifare_ul_on_event(void* context, SceneManagerEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void nfc_scene_debug_read_mifare_ul_on_exit(void* context) {
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_debug_read_mifare_ul_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneDebugReadMifareUl;
|
||||
scene->on_enter = nfc_scene_debug_read_mifare_ul_on_enter;
|
||||
scene->on_event = nfc_scene_debug_read_mifare_ul_on_event;
|
||||
scene->on_exit = nfc_scene_debug_read_mifare_ul_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_debug_read_mifare_ul_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_debug_read_mifare_ul_alloc();
|
||||
|
||||
void nfc_scene_debug_read_mifare_ul_free(AppScene* scene);
|
@@ -1,7 +1,3 @@
|
||||
#include <nfc/scenes/nfc_scene_emulate_uid.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
const void nfc_scene_emulate_uid_on_enter(void* context) {
|
||||
@@ -12,12 +8,12 @@ const void nfc_scene_emulate_uid_on_enter(void* context) {
|
||||
NfcDeviceData* data = &nfc->device.data;
|
||||
|
||||
if(strcmp(nfc->device.dev_name, "")) {
|
||||
nfc_set_text_store(nfc, "%s", nfc->device.dev_name);
|
||||
nfc_text_store_set(nfc, "%s", nfc->device.dev_name);
|
||||
} else if(data->uid_len == 4) {
|
||||
nfc_set_text_store(
|
||||
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_set_text_store(
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
"%02X %02X %02X %02X\n%02X %02X %02X",
|
||||
data->uid[0],
|
||||
@@ -41,7 +37,13 @@ const void nfc_scene_emulate_uid_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
|
||||
}
|
||||
|
||||
const bool nfc_scene_emulate_uid_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeTick) {
|
||||
notification_message(nfc->notifications, &sequence_blink_blue_10);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,17 +59,3 @@ const void nfc_scene_emulate_uid_on_exit(void* context) {
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_emulate_uid_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneEmulateUID;
|
||||
scene->on_enter = nfc_scene_emulate_uid_on_enter;
|
||||
scene->on_event = nfc_scene_emulate_uid_on_event;
|
||||
scene->on_exit = nfc_scene_emulate_uid_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_emulate_uid_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_emulate_uid_alloc();
|
||||
|
||||
void nfc_scene_emulate_uid_free(AppScene* scene);
|
@@ -1,39 +1,18 @@
|
||||
#include <nfc/scenes/nfc_scene_file_select.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
const void nfc_scene_file_select_on_enter(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
// Process file_select return
|
||||
if(nfc_file_select(&nfc->device)) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_saved_menu);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSavedMenu);
|
||||
} else {
|
||||
view_dispatcher_send_back_search_scene_event(
|
||||
nfc->nfc_common.view_dispatcher, NfcSceneStart);
|
||||
scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
}
|
||||
|
||||
const bool nfc_scene_file_select_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_file_select_on_event(void* context, SceneManagerEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const void nfc_scene_file_select_on_exit(void* context) {
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_file_select_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneFileSelect;
|
||||
scene->on_enter = nfc_scene_file_select_on_enter;
|
||||
scene->on_event = nfc_scene_file_select_on_event;
|
||||
scene->on_exit = nfc_scene_file_select_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_file_select_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_file_select_alloc();
|
||||
|
||||
void nfc_scene_file_select_free(AppScene* scene);
|
49
applications/nfc/scenes/nfc_scene_mifare_ul_menu.c
Executable file → Normal file
49
applications/nfc/scenes/nfc_scene_mifare_ul_menu.c
Executable file → Normal file
@@ -1,8 +1,5 @@
|
||||
#include "nfc_scene_mifare_ul_menu.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexSave,
|
||||
SubmenuIndexEmulate,
|
||||
@@ -22,27 +19,29 @@ const void nfc_scene_mifare_ul_menu_on_enter(void* context) {
|
||||
submenu, "Name and save", SubmenuIndexSave, nfc_scene_mifare_ul_menu_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
submenu, "Emulate", SubmenuIndexEmulate, nfc_scene_mifare_ul_menu_submenu_callback, nfc);
|
||||
submenu_set_selected_item(
|
||||
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareUlMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_mifare_ul_menu_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_mifare_ul_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexSave) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexEmulate) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == ViewNavigatorEventBack) {
|
||||
view_dispatcher_send_back_search_scene_event(
|
||||
nfc->nfc_common.view_dispatcher, NfcSceneStart);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexSave) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneMifareUlMenu, SubmenuIndexSave);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEmulate) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneMifareUlMenu, SubmenuIndexEmulate);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeNavigation) {
|
||||
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -53,17 +52,3 @@ const void nfc_scene_mifare_ul_menu_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_mifare_ul_menu_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadMifareUlMenu;
|
||||
scene->on_enter = nfc_scene_mifare_ul_menu_on_enter;
|
||||
scene->on_event = nfc_scene_mifare_ul_menu_on_event;
|
||||
scene->on_exit = nfc_scene_mifare_ul_menu_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_mifare_ul_menu_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_mifare_ul_menu_alloc();
|
||||
|
||||
void nfc_scene_mifare_ul_menu_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_not_implemented.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
void nfc_scene_not_implemented_dialog_callback(DialogExResult result, void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
@@ -24,13 +19,13 @@ const void nfc_scene_not_implemented_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDialogEx);
|
||||
}
|
||||
|
||||
const bool nfc_scene_not_implemented_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_not_implemented_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == DialogExResultLeft) {
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventBack);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == DialogExResultLeft) {
|
||||
return scene_manager_previous_scene(nfc->scene_manager);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -45,17 +40,3 @@ const void nfc_scene_not_implemented_on_exit(void* context) {
|
||||
dialog_ex_set_result_callback(dialog_ex, NULL);
|
||||
dialog_ex_set_context(dialog_ex, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_not_implemented_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadCardSuccess;
|
||||
scene->on_enter = nfc_scene_not_implemented_on_enter;
|
||||
scene->on_event = nfc_scene_not_implemented_on_event;
|
||||
scene->on_exit = nfc_scene_not_implemented_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_not_implemented_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_not_implemented_alloc();
|
||||
|
||||
void nfc_scene_not_implemented_free(AppScene* scene);
|
@@ -1,11 +1,4 @@
|
||||
#include <nfc/scenes/nfc_scene_read_card.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
#include "../views/nfc_detect.h"
|
||||
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
void nfc_read_card_worker_callback(void* context) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
@@ -30,14 +23,17 @@ const void nfc_scene_read_card_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
|
||||
}
|
||||
|
||||
const bool nfc_scene_read_card_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_read_card_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == NfcEventDetect) {
|
||||
nfc->device.data = nfc->nfc_common.worker_result.nfc_detect_data;
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_read_card_success);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NfcEventDetect) {
|
||||
nfc->device.data = nfc->nfc_common.worker_result.nfc_detect_data;
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadCardSuccess);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
notification_message(nfc->notifications, &sequence_blink_blue_10);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -55,17 +51,3 @@ const void nfc_scene_read_card_on_exit(void* context) {
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_read_card_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadCard;
|
||||
scene->on_enter = nfc_scene_read_card_on_enter;
|
||||
scene->on_event = nfc_scene_read_card_on_event;
|
||||
scene->on_exit = nfc_scene_read_card_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_read_card_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_read_card_alloc();
|
||||
|
||||
void nfc_scene_read_card_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_read_card_success.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define NFC_SCENE_READ_SUCCESS_SHIFT " "
|
||||
|
||||
void nfc_scene_read_card_success_dialog_callback(DialogExResult result, void* context) {
|
||||
@@ -31,7 +26,7 @@ const void nfc_scene_read_card_success_on_enter(void* context) {
|
||||
dialog_ex_set_icon(dialog_ex, 8, 13, &I_Medium_chip_22x21);
|
||||
// Display UID
|
||||
if(data->uid_len == 4) {
|
||||
nfc_set_text_store(
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
NFC_SCENE_READ_SUCCESS_SHIFT "%s\n" NFC_SCENE_READ_SUCCESS_SHIFT
|
||||
"ATQA: %02X%02X SAK: %02X\nUID: %02X %02X %02X %02X",
|
||||
@@ -44,7 +39,7 @@ const void nfc_scene_read_card_success_on_enter(void* context) {
|
||||
data->uid[2],
|
||||
data->uid[3]);
|
||||
} else if(data->uid_len == 7) {
|
||||
nfc_set_text_store(
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
NFC_SCENE_READ_SUCCESS_SHIFT
|
||||
"%s\n" NFC_SCENE_READ_SUCCESS_SHIFT
|
||||
@@ -68,18 +63,16 @@ const void nfc_scene_read_card_success_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDialogEx);
|
||||
}
|
||||
|
||||
const bool nfc_scene_read_card_success_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == DialogExResultLeft) {
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventBack);
|
||||
return true;
|
||||
} else if(event == DialogExResultRight) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_card_menu);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == DialogExResultLeft) {
|
||||
return scene_manager_previous_scene(nfc->scene_manager);
|
||||
} else if(event.event == DialogExResultRight) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneCardMenu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -96,17 +89,3 @@ const void nfc_scene_read_card_success_on_exit(void* context) {
|
||||
dialog_ex_set_result_callback(dialog_ex, NULL);
|
||||
dialog_ex_set_context(dialog_ex, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_read_card_success_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadCardSuccess;
|
||||
scene->on_enter = nfc_scene_read_card_success_on_enter;
|
||||
scene->on_event = nfc_scene_read_card_success_on_event;
|
||||
scene->on_exit = nfc_scene_read_card_success_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_read_card_success_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_read_card_success_alloc();
|
||||
|
||||
void nfc_scene_read_card_success_free(AppScene* scene);
|
@@ -1,5 +1,3 @@
|
||||
#include <nfc/scenes/nfc_scene_read_mifare_ul.h>
|
||||
#include <furi.h>
|
||||
#include "../nfc_i.h"
|
||||
|
||||
void nfc_read_mifare_ul_worker_callback(void* context) {
|
||||
@@ -25,15 +23,17 @@ const void nfc_scene_read_mifare_ul_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
|
||||
}
|
||||
|
||||
const bool nfc_scene_read_mifare_ul_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_read_mifare_ul_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == NfcEventMifareUl) {
|
||||
nfc->device.data = nfc->nfc_common.worker_result.nfc_detect_data;
|
||||
view_dispatcher_add_scene(
|
||||
nfc->nfc_common.view_dispatcher, nfc->scene_read_mifare_ul_success);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == NfcEventMifareUl) {
|
||||
nfc->device.data = nfc->nfc_common.worker_result.nfc_detect_data;
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareUlSuccess);
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
notification_message(nfc->notifications, &sequence_blink_blue_10);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -51,17 +51,3 @@ const void nfc_scene_read_mifare_ul_on_exit(void* context) {
|
||||
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 0, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_read_mifare_ul_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadMifareUl;
|
||||
scene->on_enter = nfc_scene_read_mifare_ul_on_enter;
|
||||
scene->on_event = nfc_scene_read_mifare_ul_on_event;
|
||||
scene->on_exit = nfc_scene_read_mifare_ul_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_read_mifare_ul_alloc();
|
||||
|
||||
void nfc_scene_read_mifare_ul_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_read_mifare_ul_success.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define NFC_SCENE_READ_SUCCESS_SHIFT " "
|
||||
#define NFC_SCENE_READ_MF_UL_CUSTOM_EVENT (0UL)
|
||||
|
||||
@@ -45,7 +40,7 @@ const void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
dialog_ex_set_header(dialog_ex, "Mifare Ultralight", 22, 8, AlignLeft, AlignCenter);
|
||||
dialog_ex_set_icon(dialog_ex, 8, 13, &I_Medium_chip_22x21);
|
||||
// Display UID
|
||||
nfc_set_text_store(
|
||||
nfc_text_store_set(
|
||||
nfc,
|
||||
NFC_SCENE_READ_SUCCESS_SHIFT "ATQA: %02X%02X\n" NFC_SCENE_READ_SUCCESS_SHIFT
|
||||
"SAK: %02X\nUID: %02X %02X %02X %02X %02X %02X %02X",
|
||||
@@ -82,37 +77,43 @@ const void nfc_scene_read_mifare_ul_success_on_enter(void* context) {
|
||||
}
|
||||
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
|
||||
|
||||
nfc->scene_read_mifare_ul_success->state = ReadMifareUlStateShowUID;
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadMifareUlSuccess, ReadMifareUlStateShowUID);
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDialogEx);
|
||||
}
|
||||
|
||||
const bool nfc_scene_read_mifare_ul_success_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_read_mifare_ul_success_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if((nfc->scene_read_mifare_ul_success->state == ReadMifareUlStateShowUID) &&
|
||||
(event == DialogExResultLeft)) {
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventBack);
|
||||
return true;
|
||||
} else if(
|
||||
(nfc->scene_read_mifare_ul_success->state == ReadMifareUlStateShowUID) &&
|
||||
(event == DialogExResultRight)) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_mifare_ul_menu);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(
|
||||
(nfc->scene_read_mifare_ul_success->state == ReadMifareUlStateShowUID) &&
|
||||
(event == DialogExResultCenter)) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewTextBox);
|
||||
nfc->scene_read_mifare_ul_success->state = ReadMifareUlStateShowData;
|
||||
return true;
|
||||
} else if(
|
||||
(nfc->scene_read_mifare_ul_success->state == ReadMifareUlStateShowData) &&
|
||||
(event == NFC_SCENE_READ_MF_UL_CUSTOM_EVENT)) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDialogEx);
|
||||
nfc->scene_read_mifare_ul_success->state = ReadMifareUlStateShowUID;
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if((scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareUlSuccess) ==
|
||||
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)) {
|
||||
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)) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.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)) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewDialogEx);
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneReadMifareUlSuccess, ReadMifareUlStateShowUID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -136,17 +137,3 @@ const void nfc_scene_read_mifare_ul_success_on_exit(void* context) {
|
||||
text_box_clean(text_box);
|
||||
string_clean(nfc->text_box_store);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_read_mifare_ul_success_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneReadMifareUlSuccess;
|
||||
scene->on_enter = nfc_scene_read_mifare_ul_success_on_enter;
|
||||
scene->on_event = nfc_scene_read_mifare_ul_success_on_event;
|
||||
scene->on_exit = nfc_scene_read_mifare_ul_success_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_read_mifare_ul_success_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_read_mifare_ul_success_alloc();
|
||||
|
||||
void nfc_scene_read_mifare_ul_success_free(AppScene* scene);
|
@@ -1,11 +1,4 @@
|
||||
#include <nfc/scenes/nfc_scene_save_name.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
#include "../views/nfc_detect.h"
|
||||
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define SCENE_SAVE_NAME_CUSTOM_EVENT (0UL)
|
||||
|
||||
@@ -21,7 +14,7 @@ const void nfc_scene_save_name_on_enter(void* context) {
|
||||
|
||||
// Setup view
|
||||
TextInput* text_input = nfc->text_input;
|
||||
nfc_set_text_store(nfc, "");
|
||||
nfc_text_store_clear(nfc);
|
||||
text_input_set_header_text(text_input, "Name the card");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
@@ -32,20 +25,19 @@ const void nfc_scene_save_name_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewTextInput);
|
||||
}
|
||||
|
||||
const bool nfc_scene_save_name_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SCENE_SAVE_NAME_CUSTOM_EVENT) {
|
||||
memcpy(&nfc->device.dev_name, nfc->text_store, strlen(nfc->text_store));
|
||||
if(nfc_device_save(&nfc->device, "test")) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_save_success);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
} else {
|
||||
view_dispatcher_send_back_search_scene_event(
|
||||
nfc->nfc_common.view_dispatcher, NfcSceneStart);
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SAVE_NAME_CUSTOM_EVENT) {
|
||||
memcpy(&nfc->device.dev_name, nfc->text_store, strlen(nfc->text_store));
|
||||
if(nfc_device_save(&nfc->device, nfc->text_store)) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
|
||||
return true;
|
||||
} else {
|
||||
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -56,17 +48,3 @@ const void nfc_scene_save_name_on_exit(void* context) {
|
||||
// Clear view
|
||||
text_input_set_header_text(nfc->text_input, NULL);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_save_name_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSaveName;
|
||||
scene->on_enter = nfc_scene_save_name_on_enter;
|
||||
scene->on_event = nfc_scene_save_name_on_event;
|
||||
scene->on_exit = nfc_scene_save_name_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_save_name_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_save_name_alloc();
|
||||
|
||||
void nfc_scene_save_name_free(AppScene* scene);
|
@@ -1,7 +1,3 @@
|
||||
#include <nfc/scenes/nfc_scene_save_success.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL)
|
||||
@@ -26,13 +22,13 @@ const void nfc_scene_save_success_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
|
||||
}
|
||||
|
||||
const bool nfc_scene_save_success_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
|
||||
view_dispatcher_send_back_search_scene_event(
|
||||
nfc->nfc_common.view_dispatcher, NfcSceneStart);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
|
||||
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -50,17 +46,3 @@ const void nfc_scene_save_success_on_exit(void* context) {
|
||||
popup_set_timeout(popup, 0);
|
||||
popup_disable_timeout(popup);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_save_success_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSaveSuccess;
|
||||
scene->on_enter = nfc_scene_save_success_on_enter;
|
||||
scene->on_event = nfc_scene_save_success_on_event;
|
||||
scene->on_exit = nfc_scene_save_success_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_save_success_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_save_success_alloc();
|
||||
|
||||
void nfc_scene_save_success_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_saved_menu.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexEmulate,
|
||||
SubmenuIndexEdit,
|
||||
@@ -30,33 +25,35 @@ const void nfc_scene_saved_menu_on_enter(void* context) {
|
||||
submenu, "Delete", SubmenuIndexDelete, nfc_scene_saved_menu_submenu_callback, nfc);
|
||||
submenu_add_item(
|
||||
submenu, "Info", SubmenuIndexInfo, nfc_scene_saved_menu_submenu_callback, nfc);
|
||||
submenu_set_selected_item(
|
||||
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneSavedMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_saved_menu_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_saved_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexEmulate) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_emulate_uid);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexEdit) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexDelete) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexInfo) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexEmulate) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneSavedMenu, SubmenuIndexEmulate);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEdit) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneSavedMenu, SubmenuIndexEdit);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexDelete) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneSavedMenu, SubmenuIndexDelete);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexInfo) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneSavedMenu, SubmenuIndexInfo);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -67,17 +64,3 @@ const void nfc_scene_saved_menu_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_saved_menu_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSavedMenu;
|
||||
scene->on_enter = nfc_scene_saved_menu_on_enter;
|
||||
scene->on_event = nfc_scene_saved_menu_on_event;
|
||||
scene->on_exit = nfc_scene_saved_menu_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_saved_menu_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_saved_menu_alloc();
|
||||
|
||||
void nfc_scene_saved_menu_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_scripts_menu.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexBankCard,
|
||||
SubmenuIndexMifareUltralight,
|
||||
@@ -32,23 +27,26 @@ const void nfc_scene_scripts_menu_on_enter(void* context) {
|
||||
SubmenuIndexMifareUltralight,
|
||||
nfc_scene_scripts_menu_submenu_callback,
|
||||
nfc);
|
||||
|
||||
submenu_set_selected_item(
|
||||
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneScriptsMenu));
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_scripts_menu_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_scripts_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexBankCard) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_not_implemented);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexMifareUltralight) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_read_mifare_ul);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexBankCard) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneScriptsMenu, SubmenuIndexBankCard);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexMifareUltralight) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneScriptsMenu, SubmenuIndexMifareUltralight);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareUl);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -59,17 +57,3 @@ const void nfc_scene_scripts_menu_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_scripts_menu_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneScriptsMenu;
|
||||
scene->on_enter = nfc_scene_scripts_menu_on_enter;
|
||||
scene->on_event = nfc_scene_scripts_menu_on_event;
|
||||
scene->on_exit = nfc_scene_scripts_menu_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_scripts_menu_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_scripts_menu_alloc();
|
||||
|
||||
void nfc_scene_scripts_menu_free(AppScene* scene);
|
@@ -1,11 +1,5 @@
|
||||
#include <nfc/scenes/nfc_scene_set_atqa.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define SCENE_SET_ATQA_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_atqa_byte_input_callback(void* context) {
|
||||
@@ -26,14 +20,14 @@ const void nfc_scene_set_atqa_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewByteInput);
|
||||
}
|
||||
|
||||
const bool nfc_scene_set_atqa_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_set_atqa_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SCENE_SET_ATQA_CUSTOM_EVENT) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_uid);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_ATQA_CUSTOM_EVENT) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetUid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -45,17 +39,3 @@ const void nfc_scene_set_atqa_on_exit(void* context) {
|
||||
byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(nfc->byte_input, "");
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_set_atqa_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSetAtqa;
|
||||
scene->on_enter = nfc_scene_set_atqa_on_enter;
|
||||
scene->on_event = nfc_scene_set_atqa_on_event;
|
||||
scene->on_exit = nfc_scene_set_atqa_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_set_atqa_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_set_atqa_alloc();
|
||||
|
||||
void nfc_scene_set_atqa_free(AppScene* scene);
|
@@ -1,11 +1,5 @@
|
||||
#include <nfc/scenes/nfc_scene_set_sak.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define SCENE_SET_SAK_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_sak_byte_input_callback(void* context) {
|
||||
@@ -25,14 +19,14 @@ const void nfc_scene_set_sak_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewByteInput);
|
||||
}
|
||||
|
||||
const bool nfc_scene_set_sak_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_set_sak_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SCENE_SET_SAK_CUSTOM_EVENT) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_atqa);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_SAK_CUSTOM_EVENT) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetAtqua);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -44,17 +38,3 @@ const void nfc_scene_set_sak_on_exit(void* context) {
|
||||
byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(nfc->byte_input, "");
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_set_sak_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSetSak;
|
||||
scene->on_enter = nfc_scene_set_sak_on_enter;
|
||||
scene->on_event = nfc_scene_set_sak_on_event;
|
||||
scene->on_exit = nfc_scene_set_sak_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_set_sak_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_set_sak_alloc();
|
||||
|
||||
void nfc_scene_set_sak_free(AppScene* scene);
|
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_set_type.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexNFCA4,
|
||||
SubmenuIndexNFCA7,
|
||||
@@ -27,21 +22,19 @@ const void nfc_scene_set_type_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_set_type_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexNFCA7) {
|
||||
nfc->device.data.uid_len = 7;
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_sak);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexNFCA4) {
|
||||
nfc->device.data.uid_len = 4;
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_sak);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexNFCA7) {
|
||||
nfc->device.data.uid_len = 7;
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetSak);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexNFCA4) {
|
||||
nfc->device.data.uid_len = 4;
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetSak);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -51,17 +44,3 @@ const void nfc_scene_set_type_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_set_type_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSetType;
|
||||
scene->on_enter = nfc_scene_set_type_on_enter;
|
||||
scene->on_event = nfc_scene_set_type_on_event;
|
||||
scene->on_exit = nfc_scene_set_type_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_set_type_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_set_type_alloc();
|
||||
|
||||
void nfc_scene_set_type_free(AppScene* scene);
|
@@ -1,11 +1,5 @@
|
||||
#include <nfc/scenes/nfc_scene_set_uid.h>
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#define SCENE_SET_UID_CUSTOM_EVENT (0UL)
|
||||
|
||||
void nfc_scene_set_uid_byte_input_callback(void* context) {
|
||||
@@ -30,14 +24,14 @@ const void nfc_scene_set_uid_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewByteInput);
|
||||
}
|
||||
|
||||
const bool nfc_scene_set_uid_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SCENE_SET_UID_CUSTOM_EVENT) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_save_name);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SCENE_SET_UID_CUSTOM_EVENT) {
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -49,17 +43,3 @@ const void nfc_scene_set_uid_on_exit(void* context) {
|
||||
byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(nfc->byte_input, "");
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_set_uid_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneSetUid;
|
||||
scene->on_enter = nfc_scene_set_uid_on_enter;
|
||||
scene->on_event = nfc_scene_set_uid_on_event;
|
||||
scene->on_exit = nfc_scene_set_uid_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_set_uid_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_set_uid_alloc();
|
||||
|
||||
void nfc_scene_set_uid_free(AppScene* scene);
|
71
applications/nfc/scenes/nfc_scene_start.c
Normal file → Executable file
71
applications/nfc/scenes/nfc_scene_start.c
Normal file → Executable file
@@ -1,10 +1,5 @@
|
||||
#include "nfc_scene_start.h"
|
||||
#include "../nfc_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexRead,
|
||||
SubmenuIndexRunScript,
|
||||
@@ -36,37 +31,39 @@ const void nfc_scene_start_on_enter(void* context) {
|
||||
submenu_add_item(
|
||||
submenu, "Add manually", SubmenuIndexAddManualy, nfc_scene_start_submenu_callback, nfc);
|
||||
submenu_add_item(submenu, "Debug", SubmenuIndexDebug, nfc_scene_start_submenu_callback, nfc);
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewMenu);
|
||||
}
|
||||
|
||||
const bool nfc_scene_start_on_event(void* context, uint32_t event) {
|
||||
const bool nfc_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
|
||||
if(event == SubmenuIndexRead) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_read_card);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexRunScript) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_scripts_menu);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexSaved) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_file_select);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexAddManualy) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_type);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
return true;
|
||||
} else if(event == SubmenuIndexDebug) {
|
||||
view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_debug_menu);
|
||||
view_dispatcher_send_navigation_event(
|
||||
nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexRead) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneStart, SubmenuIndexRead);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadCard);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexRunScript) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneStart, SubmenuIndexRunScript);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneScriptsMenu);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexSaved) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneStart, SubmenuIndexSaved);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneFileSelect);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexAddManualy) {
|
||||
scene_manager_set_scene_state(
|
||||
nfc->scene_manager, NfcSceneStart, SubmenuIndexAddManualy);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetType);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexDebug) {
|
||||
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneStart, SubmenuIndexDebug);
|
||||
scene_manager_next_scene(nfc->scene_manager, NfcSceneDebugMenu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -76,17 +73,3 @@ const void nfc_scene_start_on_exit(void* context) {
|
||||
|
||||
submenu_clean(nfc->submenu);
|
||||
}
|
||||
|
||||
AppScene* nfc_scene_start_alloc() {
|
||||
AppScene* scene = furi_alloc(sizeof(AppScene));
|
||||
scene->id = NfcSceneStart;
|
||||
scene->on_enter = nfc_scene_start_on_enter;
|
||||
scene->on_event = nfc_scene_start_on_event;
|
||||
scene->on_exit = nfc_scene_start_on_exit;
|
||||
|
||||
return scene;
|
||||
}
|
||||
|
||||
void nfc_scene_start_free(AppScene* scene) {
|
||||
free(scene);
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_scene.h"
|
||||
|
||||
AppScene* nfc_scene_start_alloc();
|
||||
|
||||
void nfc_scene_start_free(AppScene* scene);
|
Reference in New Issue
Block a user