nfc_scene_set_atqa.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "../nfc_i.h"
  2. void nfc_scene_set_atqa_byte_input_callback(void* context) {
  3. Nfc* nfc = context;
  4. view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventByteInputDone);
  5. }
  6. void nfc_scene_set_atqa_on_enter(void* context) {
  7. Nfc* nfc = context;
  8. // Setup view
  9. ByteInput* byte_input = nfc->byte_input;
  10. byte_input_set_header_text(byte_input, "Enter atqa in hex");
  11. byte_input_set_result_callback(
  12. byte_input,
  13. nfc_scene_set_atqa_byte_input_callback,
  14. NULL,
  15. nfc,
  16. nfc->dev->dev_data.nfc_data.atqa,
  17. 2);
  18. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewByteInput);
  19. }
  20. bool nfc_scene_set_atqa_on_event(void* context, SceneManagerEvent event) {
  21. Nfc* nfc = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. if(event.event == NfcCustomEventByteInputDone) {
  25. scene_manager_next_scene(nfc->scene_manager, NfcSceneSetUid);
  26. consumed = true;
  27. }
  28. }
  29. return consumed;
  30. }
  31. void nfc_scene_set_atqa_on_exit(void* context) {
  32. 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. }