nfc_scene_set_uid.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. #define SCENE_SET_UID_CUSTOM_EVENT (0UL)
  4. void nfc_scene_set_uid_byte_input_callback(void* context) {
  5. Nfc* nfc = (Nfc*)context;
  6. view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SET_UID_CUSTOM_EVENT);
  7. }
  8. void nfc_scene_set_uid_on_enter(void* context) {
  9. Nfc* nfc = (Nfc*)context;
  10. // Setup view
  11. ByteInput* byte_input = nfc->byte_input;
  12. byte_input_set_header_text(byte_input, "Enter uid in hex");
  13. nfc->dev_edit_data = nfc->dev->dev_data.nfc_data;
  14. byte_input_set_result_callback(
  15. byte_input,
  16. nfc_scene_set_uid_byte_input_callback,
  17. NULL,
  18. nfc,
  19. nfc->dev_edit_data.uid,
  20. nfc->dev_edit_data.uid_len);
  21. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
  22. }
  23. bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
  24. Nfc* nfc = (Nfc*)context;
  25. if(event.type == SceneManagerEventTypeCustom) {
  26. if(event.event == SCENE_SET_UID_CUSTOM_EVENT) {
  27. DOLPHIN_DEED(DolphinDeedNfcAdd);
  28. scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. void nfc_scene_set_uid_on_exit(void* context) {
  35. Nfc* nfc = (Nfc*)context;
  36. // Clear view
  37. byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
  38. byte_input_set_header_text(nfc->byte_input, "");
  39. }