nfc_scene_set_uid.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  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, NfcCustomEventByteInputDone);
  6. }
  7. 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. nfc->dev_edit_data = nfc->dev->dev_data.nfc_data;
  13. byte_input_set_result_callback(
  14. byte_input,
  15. nfc_scene_set_uid_byte_input_callback,
  16. NULL,
  17. nfc,
  18. nfc->dev_edit_data.uid,
  19. nfc->dev_edit_data.uid_len);
  20. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
  21. }
  22. bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
  23. Nfc* nfc = (Nfc*)context;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == NfcCustomEventByteInputDone) {
  26. DOLPHIN_DEED(DolphinDeedNfcAdd);
  27. scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. void nfc_scene_set_uid_on_exit(void* context) {
  34. Nfc* nfc = (Nfc*)context;
  35. // Clear view
  36. byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
  37. byte_input_set_header_text(nfc->byte_input, "");
  38. }