nfc_scene_set_uid.c 1.3 KB

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