nfc_scene_set_uid.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. void nfc_scene_set_uid_byte_input_callback(void* context) {
  4. 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 = 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. bool consumed = false;
  25. if(event.type == SceneManagerEventTypeCustom) {
  26. if(event.event == NfcCustomEventByteInputDone) {
  27. DOLPHIN_DEED(DolphinDeedNfcAdd);
  28. scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
  29. consumed = true;
  30. }
  31. }
  32. return consumed;
  33. }
  34. void nfc_scene_set_uid_on_exit(void* context) {
  35. 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. }