diff --git a/applications/debug/unit_tests/nfc/nfc_test.c b/applications/debug/unit_tests/nfc/nfc_test.c index 4218482c..e9e7b35f 100644 --- a/applications/debug/unit_tests/nfc/nfc_test.c +++ b/applications/debug/unit_tests/nfc/nfc_test.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -102,7 +102,10 @@ static bool nfc_test_digital_signal_test_encode( do { // Read test data - if(!nfc_test_read_signal_from_file(file_name)) break; + if(!nfc_test_read_signal_from_file(file_name)) { + FURI_LOG_E(TAG, "Failed to read signal from file"); + break; + } // Encode signal FURI_CRITICAL_ENTER(); diff --git a/applications/main/nfc/nfc_i.h b/applications/main/nfc/nfc_i.h index 57eefbf6..d49b8476 100644 --- a/applications/main/nfc/nfc_i.h +++ b/applications/main/nfc/nfc_i.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "views/dict_attack.h" #include "views/detect_reader.h" @@ -50,9 +51,6 @@ typedef enum { NfcRpcStateEmulated, } NfcRpcState; -// Forward declaration due to circular dependency -typedef struct NfcGenerator NfcGenerator; - struct Nfc { NfcWorker* worker; ViewDispatcher* view_dispatcher; diff --git a/applications/main/nfc/scenes/nfc_scene_generate_info.c b/applications/main/nfc/scenes/nfc_scene_generate_info.c index 66900767..7b84ae43 100644 --- a/applications/main/nfc/scenes/nfc_scene_generate_info.c +++ b/applications/main/nfc/scenes/nfc_scene_generate_info.c @@ -1,5 +1,5 @@ #include "../nfc_i.h" -#include "../helpers/nfc_generators.h" +#include "lib/nfc/helpers/nfc_generators.h" void nfc_scene_generate_info_dialog_callback(DialogExResult result, void* context) { Nfc* nfc = context; @@ -39,7 +39,12 @@ bool nfc_scene_generate_info_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == DialogExResultRight) { - scene_manager_next_scene(nfc->scene_manager, nfc->generator->next_scene); + // Switch either to NfcSceneMfClassicMenu or NfcSceneMfUltralightMenu + if(nfc->dev->dev_data.protocol == NfcDeviceProtocolMifareClassic) { + scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicMenu); + } else if(nfc->dev->dev_data.protocol == NfcDeviceProtocolMifareUl) { + scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightMenu); + } consumed = true; } } diff --git a/applications/main/nfc/scenes/nfc_scene_set_type.c b/applications/main/nfc/scenes/nfc_scene_set_type.c index 3e08aeb3..cadf2eb6 100644 --- a/applications/main/nfc/scenes/nfc_scene_set_type.c +++ b/applications/main/nfc/scenes/nfc_scene_set_type.c @@ -1,5 +1,5 @@ #include "../nfc_i.h" -#include "../helpers/nfc_generators.h" +#include "lib/nfc/helpers/nfc_generators.h" enum SubmenuIndex { SubmenuIndexNFCA4, diff --git a/fbt_options.py b/fbt_options.py index 7a805c99..4850389a 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -81,7 +81,6 @@ FIRMWARE_APPS = { "basic_services", "updater_app", "unit_tests", - "nfc", ], } diff --git a/applications/main/nfc/helpers/nfc_generators.c b/lib/nfc/helpers/nfc_generators.c similarity index 95% rename from applications/main/nfc/helpers/nfc_generators.c rename to lib/nfc/helpers/nfc_generators.c index 5f0527c6..769b9c7b 100644 --- a/applications/main/nfc/helpers/nfc_generators.c +++ b/lib/nfc/helpers/nfc_generators.c @@ -376,103 +376,86 @@ static void nfc_generate_mf_classic_4k_7b_uid(NfcDeviceData* data) { static const NfcGenerator mf_ul_generator = { .name = "Mifare Ultralight", .generator_func = nfc_generate_mf_ul_orig, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator mf_ul_11_generator = { .name = "Mifare Ultralight EV1 11", .generator_func = nfc_generate_mf_ul_11, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator mf_ul_h11_generator = { .name = "Mifare Ultralight EV1 H11", .generator_func = nfc_generate_mf_ul_h11, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator mf_ul_21_generator = { .name = "Mifare Ultralight EV1 21", .generator_func = nfc_generate_mf_ul_21, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator mf_ul_h21_generator = { .name = "Mifare Ultralight EV1 H21", .generator_func = nfc_generate_mf_ul_h21, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag203_generator = { .name = "NTAG203", .generator_func = nfc_generate_mf_ul_ntag203, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag213_generator = { .name = "NTAG213", .generator_func = nfc_generate_ntag213, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag215_generator = { .name = "NTAG215", .generator_func = nfc_generate_ntag215, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag216_generator = { .name = "NTAG216", .generator_func = nfc_generate_ntag216, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag_i2c_1k_generator = { .name = "NTAG I2C 1k", .generator_func = nfc_generate_ntag_i2c_1k, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag_i2c_2k_generator = { .name = "NTAG I2C 2k", .generator_func = nfc_generate_ntag_i2c_2k, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag_i2c_plus_1k_generator = { .name = "NTAG I2C Plus 1k", .generator_func = nfc_generate_ntag_i2c_plus_1k, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator ntag_i2c_plus_2k_generator = { .name = "NTAG I2C Plus 2k", .generator_func = nfc_generate_ntag_i2c_plus_2k, - .next_scene = NfcSceneMfUltralightMenu, }; static const NfcGenerator mifare_classic_1k_4b_uid_generator = { .name = "Mifare Classic 1k 4byte UID", .generator_func = nfc_generate_mf_classic_1k_4b_uid, - .next_scene = NfcSceneMfClassicMenu, }; static const NfcGenerator mifare_classic_1k_7b_uid_generator = { .name = "Mifare Classic 1k 7byte UID", .generator_func = nfc_generate_mf_classic_1k_7b_uid, - .next_scene = NfcSceneMfClassicMenu, }; static const NfcGenerator mifare_classic_4k_4b_uid_generator = { .name = "Mifare Classic 4k 4byte UID", .generator_func = nfc_generate_mf_classic_4k_4b_uid, - .next_scene = NfcSceneMfClassicMenu, }; static const NfcGenerator mifare_classic_4k_7b_uid_generator = { .name = "Mifare Classic 4k 7byte UID", .generator_func = nfc_generate_mf_classic_4k_7b_uid, - .next_scene = NfcSceneMfClassicMenu, }; const NfcGenerator* const nfc_generators[] = { diff --git a/applications/main/nfc/helpers/nfc_generators.h b/lib/nfc/helpers/nfc_generators.h similarity index 79% rename from applications/main/nfc/helpers/nfc_generators.h rename to lib/nfc/helpers/nfc_generators.h index 362a19b1..8cee6706 100644 --- a/applications/main/nfc/helpers/nfc_generators.h +++ b/lib/nfc/helpers/nfc_generators.h @@ -1,14 +1,13 @@ #pragma once -#include "../nfc_i.h" +#include "../nfc_device.h" typedef void (*NfcGeneratorFunc)(NfcDeviceData* data); -struct NfcGenerator { +typedef struct { const char* name; NfcGeneratorFunc generator_func; - NfcScene next_scene; -}; +} NfcGenerator; extern const NfcGenerator* const nfc_generators[];