mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-18 16:53:45 +00:00
d92b0a82cc
"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.
72 lines
2.4 KiB
C
72 lines
2.4 KiB
C
#include "../nfc_app_i.h"
|
|
|
|
enum SubmenuIndex {
|
|
SubmenuIndexReadCardType,
|
|
SubmenuIndexMfClassicKeys,
|
|
SubmenuIndexMfUltralightUnlock,
|
|
};
|
|
|
|
void nfc_scene_extra_actions_submenu_callback(void* context, uint32_t index) {
|
|
NfcApp* instance = context;
|
|
|
|
view_dispatcher_send_custom_event(instance->view_dispatcher, index);
|
|
}
|
|
|
|
void nfc_scene_extra_actions_on_enter(void* context) {
|
|
NfcApp* instance = context;
|
|
Submenu* submenu = instance->submenu;
|
|
|
|
submenu_add_item(
|
|
submenu,
|
|
"Read Specific Card Type",
|
|
SubmenuIndexReadCardType,
|
|
nfc_scene_extra_actions_submenu_callback,
|
|
instance);
|
|
submenu_add_item(
|
|
submenu,
|
|
"Mifare Classic Keys",
|
|
SubmenuIndexMfClassicKeys,
|
|
nfc_scene_extra_actions_submenu_callback,
|
|
instance);
|
|
submenu_add_item(
|
|
submenu,
|
|
"Unlock NTAG/Ultralight",
|
|
SubmenuIndexMfUltralightUnlock,
|
|
nfc_scene_extra_actions_submenu_callback,
|
|
instance);
|
|
submenu_set_selected_item(
|
|
submenu, scene_manager_get_scene_state(instance->scene_manager, NfcSceneExtraActions));
|
|
view_dispatcher_switch_to_view(instance->view_dispatcher, NfcViewMenu);
|
|
}
|
|
|
|
bool nfc_scene_extra_actions_on_event(void* context, SceneManagerEvent event) {
|
|
NfcApp* instance = context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == SubmenuIndexMfClassicKeys) {
|
|
if(nfc_dict_check_presence(NFC_APP_MF_CLASSIC_DICT_USER_PATH)) {
|
|
scene_manager_next_scene(instance->scene_manager, NfcSceneMfClassicKeys);
|
|
} else {
|
|
scene_manager_previous_scene(instance->scene_manager);
|
|
}
|
|
consumed = true;
|
|
} else if(event.event == SubmenuIndexMfUltralightUnlock) {
|
|
mf_ultralight_auth_reset(instance->mf_ul_auth);
|
|
scene_manager_next_scene(instance->scene_manager, NfcSceneMfUltralightUnlockMenu);
|
|
consumed = true;
|
|
} else if(event.event == SubmenuIndexReadCardType) {
|
|
scene_manager_next_scene(instance->scene_manager, NfcSceneSelectProtocol);
|
|
consumed = true;
|
|
}
|
|
scene_manager_set_scene_state(instance->scene_manager, NfcSceneExtraActions, event.event);
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void nfc_scene_extra_actions_on_exit(void* context) {
|
|
NfcApp* instance = context;
|
|
|
|
submenu_reset(instance->submenu);
|
|
}
|