nfc_scene_set_uid.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. 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 == SCENE_SET_UID_CUSTOM_EVENT) {
  26. scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. void nfc_scene_set_uid_on_exit(void* context) {
  33. Nfc* nfc = (Nfc*)context;
  34. // Clear view
  35. byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
  36. byte_input_set_header_text(nfc->byte_input, "");
  37. }