NFC refactoring (#3050)

"A long time ago in a galaxy far, far away...." we started NFC subsystem refactoring.

Starring:

- @gornekich - NFC refactoring project lead, architect, senior developer
- @gsurkov - architect, senior developer
- @RebornedBrain - senior developer

Supporting roles:

- @skotopes, @DrZlo13, @hedger - general architecture advisors, code review
- @Astrrra, @doomwastaken, @Hellitron, @ImagineVagon333 - quality assurance

Special thanks:

@bettse, @pcunning, @nxv, @noproto, @AloneLiberty and everyone else who has been helping us all this time and contributing valuable knowledges, ideas and source code.
This commit is contained in:
gornekich
2023-10-24 07:08:09 +04:00
committed by GitHub
parent 35c903494c
commit d92b0a82cc
514 changed files with 41488 additions and 68125 deletions

View File

@@ -1,44 +1,48 @@
#include "../nfc_i.h"
#include "../nfc_app_i.h"
void nfc_scene_set_sak_byte_input_callback(void* context) {
Nfc* nfc = context;
#include "../helpers/protocol_support/nfc_protocol_support_gui_common.h"
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventByteInputDone);
static void nfc_scene_set_sak_byte_input_changed_callback(void* context) {
NfcApp* instance = context;
iso14443_3a_set_sak(instance->iso14443_3a_edit_data, instance->byte_input_store[0]);
}
void nfc_scene_set_sak_on_enter(void* context) {
Nfc* nfc = context;
NfcApp* instance = context;
instance->byte_input_store[0] = iso14443_3a_get_sak(instance->iso14443_3a_edit_data);
// Setup view
ByteInput* byte_input = nfc->byte_input;
ByteInput* byte_input = instance->byte_input;
byte_input_set_header_text(byte_input, "Enter SAK in hex");
byte_input_set_result_callback(
byte_input,
nfc_scene_set_sak_byte_input_callback,
NULL,
nfc,
&nfc->dev->dev_data.nfc_data.sak,
nfc_protocol_support_common_byte_input_done_callback,
nfc_scene_set_sak_byte_input_changed_callback,
instance,
instance->byte_input_store,
1);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewByteInput);
}
bool nfc_scene_set_sak_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = context;
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventByteInputDone) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetAtqa);
scene_manager_next_scene(instance->scene_manager, NfcSceneSetAtqa);
consumed = true;
}
}
return consumed;
}
void nfc_scene_set_sak_on_exit(void* context) {
Nfc* nfc = context;
NfcApp* instance = context;
// Clear view
byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(nfc->byte_input, "");
byte_input_set_result_callback(instance->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(instance->byte_input, "");
}