Skip to content

Commit

Permalink
NFC: Edit UID feature (#1513)
Browse files Browse the repository at this point in the history
* Added option to edit UID in saved NFC files
* Fixed bug with saved filename
* Only show for data that can't be read

Co-authored-by: あく <[email protected]>
  • Loading branch information
fork-bombed and skotopes authored Aug 3, 2022
1 parent 135fbd2 commit 284c567
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions applications/nfc/scenes/nfc_scene_saved_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

enum SubmenuIndex {
SubmenuIndexEmulate,
SubmenuIndexEditUid,
SubmenuIndexRename,
SubmenuIndexDelete,
SubmenuIndexInfo,
Expand All @@ -27,6 +28,14 @@ void nfc_scene_saved_menu_on_enter(void* context) {
SubmenuIndexEmulate,
nfc_scene_saved_menu_submenu_callback,
nfc);
if(nfc->dev->dev_data.protocol == NfcDeviceProtocolUnknown) {
submenu_add_item(
submenu,
"Edit UID",
SubmenuIndexEditUid,
nfc_scene_saved_menu_submenu_callback,
nfc);
}
} else if(
nfc->dev->format == NfcDeviceSaveFormatMifareUl ||
nfc->dev->format == NfcDeviceSaveFormatMifareClassic) {
Expand Down Expand Up @@ -71,6 +80,9 @@ bool nfc_scene_saved_menu_on_event(void* context, SceneManagerEvent event) {
} else if(event.event == SubmenuIndexRename) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
consumed = true;
} else if(event.event == SubmenuIndexEditUid) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSetUid);
consumed = true;
} else if(event.event == SubmenuIndexDelete) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneDelete);
consumed = true;
Expand Down
12 changes: 10 additions & 2 deletions applications/nfc/scenes/nfc_scene_set_uid.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventByteInputDone) {
DOLPHIN_DEED(DolphinDeedNfcAdd);
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
consumed = true;
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSavedMenu)) {
nfc->dev->dev_data.nfc_data = nfc->dev_edit_data;
if(nfc_device_save(nfc->dev, nfc->dev->dev_name)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
consumed = true;
}
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
consumed = true;
}
}
}
return consumed;
Expand Down

0 comments on commit 284c567

Please sign in to comment.