unleashed-firmware/applications/main/nfc/scenes/nfc_scene_slix_key_input.c
Leptopt1los dd988ba449
bit_lib and nfc_util refactor (#3383)
* nfc_util functions for processing bytes moved into bit_lib
* bitlib test update
* bit_lib moved from lfrfid to standalone lib
* Added bit functions for any supported data types
* Error fix and api add
* Added test for 64
* Added doc
* Testcase for 64 rewrited
* Realization error fix
* API version bump
* sync api version, fix after-merge old libs usage
* fix build errors
* build fix
* fbt format

Co-authored-by: assasinfil <nfa57643@gmail.com>
Co-authored-by: gornekich <n.gorbadey@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
2024-02-14 11:41:42 +07:00

50 lines
1.6 KiB
C

#include "../nfc_app_i.h"
#include <bit_lib/bit_lib.h>
void nfc_scene_slix_key_input_byte_input_callback(void* context) {
NfcApp* instance = context;
SlixPassword password =
bit_lib_bytes_to_num_be(instance->byte_input_store, sizeof(SlixPassword));
slix_unlock_set_password(instance->slix_unlock, password);
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventByteInputDone);
}
void nfc_scene_slix_key_input_on_enter(void* context) {
NfcApp* instance = context;
// Setup view
ByteInput* byte_input = instance->byte_input;
byte_input_set_header_text(byte_input, "Enter the password in hex");
byte_input_set_result_callback(
byte_input,
nfc_scene_slix_key_input_byte_input_callback,
NULL,
instance,
instance->byte_input_store,
sizeof(SlixPassword));
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewByteInput);
}
bool nfc_scene_slix_key_input_on_event(void* context, SceneManagerEvent event) {
NfcApp* instance = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventByteInputDone) {
scene_manager_next_scene(instance->scene_manager, NfcSceneSlixUnlock);
consumed = true;
}
}
return consumed;
}
void nfc_scene_slix_key_input_on_exit(void* context) {
NfcApp* instance = context;
// Clear view
byte_input_set_result_callback(instance->byte_input, NULL, NULL, NULL, NULL, 0);
byte_input_set_header_text(instance->byte_input, "");
}