nfc_scene_set_atqa.c 1.3 KB

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