From 51ba8b66b699a85fd39b5c8b804a57ca2b0c38f8 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 17 May 2023 23:05:44 +0300 Subject: [PATCH] Save a little bit (~2k) of space --- applications/main/nfc/scenes/nfc_scene_config.h | 4 ++++ applications/main/nfc/scenes/nfc_scene_debug.c | 2 ++ .../main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c | 2 ++ applications/main/nfc/scenes/nfc_scene_field.c | 2 ++ applications/main/nfc/scenes/nfc_scene_start.c | 11 ++++++++--- lib/nfc/nfc_worker.c | 11 ++++++++--- lib/nfc/protocols/emv.c | 6 ++++-- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/applications/main/nfc/scenes/nfc_scene_config.h b/applications/main/nfc/scenes/nfc_scene_config.h index d6edebe73..445c4436a 100644 --- a/applications/main/nfc/scenes/nfc_scene_config.h +++ b/applications/main/nfc/scenes/nfc_scene_config.h @@ -52,14 +52,18 @@ ADD_SCENE(nfc, mf_classic_update_success, MfClassicUpdateSuccess) ADD_SCENE(nfc, mf_classic_wrong_card, MfClassicWrongCard) ADD_SCENE(nfc, emv_read_success, EmvReadSuccess) ADD_SCENE(nfc, emv_menu, EmvMenu) +#if FURI_DEBUG ADD_SCENE(nfc, emulate_apdu_sequence, EmulateApduSequence) +#endif ADD_SCENE(nfc, device_info, DeviceInfo) ADD_SCENE(nfc, delete, Delete) ADD_SCENE(nfc, delete_success, DeleteSuccess) ADD_SCENE(nfc, restore_original_confirm, RestoreOriginalConfirm) ADD_SCENE(nfc, restore_original, RestoreOriginal) +#if FURI_DEBUG ADD_SCENE(nfc, debug, Debug) ADD_SCENE(nfc, field, Field) +#endif ADD_SCENE(nfc, dict_not_found, DictNotFound) ADD_SCENE(nfc, rpc, Rpc) ADD_SCENE(nfc, exit_confirm, ExitConfirm) diff --git a/applications/main/nfc/scenes/nfc_scene_debug.c b/applications/main/nfc/scenes/nfc_scene_debug.c index ed079c2ed..5dc29c96a 100644 --- a/applications/main/nfc/scenes/nfc_scene_debug.c +++ b/applications/main/nfc/scenes/nfc_scene_debug.c @@ -1,3 +1,4 @@ +#if FURI_DEBUG #include "../nfc_i.h" enum SubmenuDebugIndex { @@ -52,3 +53,4 @@ void nfc_scene_debug_on_exit(void* context) { submenu_reset(nfc->submenu); } +#endif \ No newline at end of file diff --git a/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c b/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c index 358ad2ab6..bc3f0f42d 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate_apdu_sequence.c @@ -1,3 +1,4 @@ +#if FURI_DEBUG #include "../nfc_i.h" #include @@ -32,3 +33,4 @@ void nfc_scene_emulate_apdu_sequence_on_exit(void* context) { nfc_blink_stop(nfc); } +#endif \ No newline at end of file diff --git a/applications/main/nfc/scenes/nfc_scene_field.c b/applications/main/nfc/scenes/nfc_scene_field.c index e3eb6a708..f287e8796 100644 --- a/applications/main/nfc/scenes/nfc_scene_field.c +++ b/applications/main/nfc/scenes/nfc_scene_field.c @@ -1,3 +1,4 @@ +#if FURI_DEBUG #include "../nfc_i.h" void nfc_scene_field_on_enter(void* context) { @@ -31,3 +32,4 @@ void nfc_scene_field_on_exit(void* context) { notification_internal_message(nfc->notifications, &sequence_reset_blue); popup_reset(nfc->popup); } +#endif \ No newline at end of file diff --git a/applications/main/nfc/scenes/nfc_scene_start.c b/applications/main/nfc/scenes/nfc_scene_start.c index a01f871ab..858d519fc 100644 --- a/applications/main/nfc/scenes/nfc_scene_start.c +++ b/applications/main/nfc/scenes/nfc_scene_start.c @@ -8,7 +8,9 @@ enum SubmenuIndex { SubmenuIndexSaved, SubmenuIndexExtraAction, SubmenuIndexAddManually, +#if FURI_DEBUG SubmenuIndexDebug, +#endif }; void nfc_scene_start_submenu_callback(void* context, uint32_t index) { @@ -29,12 +31,12 @@ void nfc_scene_start_on_enter(void* context) { submenu, "Extra Actions", SubmenuIndexExtraAction, nfc_scene_start_submenu_callback, nfc); submenu_add_item( submenu, "Add Manually", SubmenuIndexAddManually, nfc_scene_start_submenu_callback, nfc); - +#if FURI_DEBUG if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) { submenu_add_item( submenu, "Debug", SubmenuIndexDebug, nfc_scene_start_submenu_callback, nfc); } - +#endif submenu_set_selected_item( submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneStart)); @@ -82,11 +84,14 @@ bool nfc_scene_start_on_event(void* context, SceneManagerEvent event) { nfc->scene_manager, NfcSceneStart, SubmenuIndexAddManually); scene_manager_next_scene(nfc->scene_manager, NfcSceneSetType); consumed = true; - } else if(event.event == SubmenuIndexDebug) { + } +#if FURI_DEBUG + else if(event.event == SubmenuIndexDebug) { scene_manager_set_scene_state(nfc->scene_manager, NfcSceneStart, SubmenuIndexDebug); scene_manager_next_scene(nfc->scene_manager, NfcSceneDebug); consumed = true; } +#endif } return consumed; } diff --git a/lib/nfc/nfc_worker.c b/lib/nfc/nfc_worker.c index 197b6f58a..8f7a1b5e4 100644 --- a/lib/nfc/nfc_worker.c +++ b/lib/nfc/nfc_worker.c @@ -95,9 +95,13 @@ int32_t nfc_worker_task(void* context) { } } else if(nfc_worker->state == NfcWorkerStateUidEmulate) { nfc_worker_emulate_uid(nfc_worker); - } else if(nfc_worker->state == NfcWorkerStateEmulateApdu) { + } +#if FURI_DEBUG + else if(nfc_worker->state == NfcWorkerStateEmulateApdu) { nfc_worker_emulate_apdu(nfc_worker); - } else if(nfc_worker->state == NfcWorkerStateMfUltralightEmulate) { + } +#endif + else if(nfc_worker->state == NfcWorkerStateMfUltralightEmulate) { nfc_worker_emulate_mf_ultralight(nfc_worker); } else if(nfc_worker->state == NfcWorkerStateMfClassicEmulate) { nfc_worker_emulate_mf_classic(nfc_worker); @@ -741,7 +745,7 @@ void nfc_worker_emulate_uid(NfcWorker* nfc_worker) { } } } - +#if FURI_DEBUG void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) { FuriHalNfcTxRxContext tx_rx = {}; FuriHalNfcDevData params = { @@ -774,6 +778,7 @@ void nfc_worker_emulate_apdu(NfcWorker* nfc_worker) { reader_analyzer_stop(nfc_worker->reader_analyzer); } } +#endif void nfc_worker_mf_ultralight_auth_received_callback(MfUltralightAuth auth, void* context) { furi_assert(context); diff --git a/lib/nfc/protocols/emv.c b/lib/nfc/protocols/emv.c index 4c4ac856b..8cc5fc44e 100644 --- a/lib/nfc/protocols/emv.c +++ b/lib/nfc/protocols/emv.c @@ -44,7 +44,7 @@ const PDOLValue* const pdol_values[] = { &pdol_transaction_cert, &pdol_unpredict_number, }; - +#if FURI_DEBUG static const uint8_t select_ppse_ans[] = {0x6F, 0x29, 0x84, 0x0E, 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0xA5, 0x17, 0xBF, 0x0C, 0x14, 0x61, 0x12, 0x4F, 0x07, @@ -61,7 +61,7 @@ static const uint8_t pdol_ans[] = {0x77, 0x40, 0x82, 0x02, 0x20, 0x00, 0x57, 0x1 0x00, 0x9F, 0x26, 0x08, 0x7A, 0x65, 0x7F, 0xD3, 0x52, 0x96, 0xC9, 0x85, 0x9F, 0x27, 0x01, 0x00, 0x9F, 0x36, 0x02, 0x06, 0x0C, 0x9F, 0x6C, 0x02, 0x10, 0x00, 0x90, 0x00}; - +#endif static void emv_trace(FuriHalNfcTxRxContext* tx_rx, const char* message) { if(furi_log_get_level() == FuriLogLevelTrace) { FURI_LOG_T(TAG, "%s", message); @@ -409,6 +409,7 @@ bool emv_read_bank_card(FuriHalNfcTxRxContext* tx_rx, EmvApplication* emv_app) { return card_num_read; } +#if FURI_DEBUG bool emv_card_emulation(FuriHalNfcTxRxContext* tx_rx) { furi_assert(tx_rx); bool emulation_complete = false; @@ -442,3 +443,4 @@ bool emv_card_emulation(FuriHalNfcTxRxContext* tx_rx) { return emulation_complete; } +#endif \ No newline at end of file