diff options
author | gornekich <n.gorbadey@gmail.com> | 2021-08-03 20:24:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-03 20:24:20 +0300 |
commit | 841804026e5cfe2692d199ffff31763347c8dc58 (patch) | |
tree | dfe34b6c4fe9064d222dd2bb14aaabd5ae7b2c30 /applications/nfc | |
parent | 15592682ad7cc0dd4559f8544798075b2a1e7a1e (diff) |
[FL-1619] NFC long APDU emulation (#623)
* nfc: add apdu sequence exchange debug scene
* api-hal-gpio: fix GPIO initialization
* nfc: pull down nfc chip IRQ pin
Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/nfc')
-rwxr-xr-x | applications/nfc/nfc_worker.c | 2 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_config.h | 1 | ||||
-rw-r--r-- | applications/nfc/scenes/nfc_scene_emulate_apdu_sequence.c | 38 | ||||
-rwxr-xr-x | applications/nfc/scenes/nfc_scene_start.c | 17 |
4 files changed, 52 insertions, 6 deletions
diff --git a/applications/nfc/nfc_worker.c b/applications/nfc/nfc_worker.c index e536620e..c5c9ed76 100755 --- a/applications/nfc/nfc_worker.c +++ b/applications/nfc/nfc_worker.c @@ -364,7 +364,7 @@ void nfc_worker_emulate_emv(NfcWorker* nfc_worker) { }; while(nfc_worker->state == NfcWorkerStateEmulateEMV) { - if(api_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 100)) { + if(api_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, 300)) { FURI_LOG_I(NFC_WORKER_TAG, "POS terminal detected"); // Read data from POS terminal err = api_hal_nfc_data_exchange(NULL, 0, &rx_buff, &rx_len, false); diff --git a/applications/nfc/scenes/nfc_scene_config.h b/applications/nfc/scenes/nfc_scene_config.h index 385b84a3..149b4d7f 100755 --- a/applications/nfc/scenes/nfc_scene_config.h +++ b/applications/nfc/scenes/nfc_scene_config.h @@ -25,3 +25,4 @@ ADD_SCENE(nfc, delete_success, DeleteSuccess) ADD_SCENE(nfc, run_emv_app_confirm, RunEmvAppConfirm) ADD_SCENE(nfc, read_emv_data, ReadEmvData) ADD_SCENE(nfc, read_emv_data_success, ReadEmvDataSuccess) +ADD_SCENE(nfc, emulate_apdu_sequence, EmulateApduSequence) diff --git a/applications/nfc/scenes/nfc_scene_emulate_apdu_sequence.c b/applications/nfc/scenes/nfc_scene_emulate_apdu_sequence.c new file mode 100644 index 00000000..2f5018c8 --- /dev/null +++ b/applications/nfc/scenes/nfc_scene_emulate_apdu_sequence.c @@ -0,0 +1,38 @@ +#include "../nfc_i.h" + +const void nfc_scene_emulate_apdu_sequence_on_enter(void* context) { + Nfc* nfc = (Nfc*)context; + + // Setup view + Popup* popup = nfc->popup; + + popup_set_header(popup, "Run APDU reader", 64, 31, AlignCenter, AlignTop); + + // Setup and start worker + + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup); + nfc_worker_start(nfc->worker, NfcWorkerStateEmulateEMV, &nfc->dev.dev_data, NULL, nfc); +} + +const bool nfc_scene_emulate_apdu_sequence_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; +} + +const void nfc_scene_emulate_apdu_sequence_on_exit(void* context) { + Nfc* nfc = (Nfc*)context; + + // Stop worker + nfc_worker_stop(nfc->worker); + + // Clear view + Popup* popup = nfc->popup; + popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); + popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); + popup_set_icon(popup, 0, 0, NULL); +} diff --git a/applications/nfc/scenes/nfc_scene_start.c b/applications/nfc/scenes/nfc_scene_start.c index 78a4d923..3b560c07 100755 --- a/applications/nfc/scenes/nfc_scene_start.c +++ b/applications/nfc/scenes/nfc_scene_start.c @@ -5,6 +5,7 @@ enum SubmenuIndex { SubmenuIndexRunScript, SubmenuIndexSaved, SubmenuIndexAddManualy, + SubmenuIndexDebug, }; void nfc_scene_start_submenu_callback(void* context, uint32_t index) { @@ -29,6 +30,7 @@ const void nfc_scene_start_on_enter(void* context) { submenu, "Saved cards", SubmenuIndexSaved, nfc_scene_start_submenu_callback, nfc); 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)); @@ -38,29 +40,34 @@ const void nfc_scene_start_on_enter(void* context) { const bool nfc_scene_start_on_event(void* context, SceneManagerEvent event) { Nfc* nfc = (Nfc*)context; + bool consumed = false; 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; + consumed = 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; + consumed = 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; + consumed = 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; + consumed = true; + } else if(event.event == SubmenuIndexDebug) { + scene_manager_set_scene_state(nfc->scene_manager, NfcSceneStart, SubmenuIndexDebug); + scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateApduSequence); + consumed = true; } } - return false; + return consumed; } const void nfc_scene_start_on_exit(void* context) { |