nfc_scene_read_emv_data.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "../nfc_i.h"
  2. #define NFC_READ_EMV_DATA_CUSTOM_EVENT (0UL)
  3. void nfc_read_emv_data_worker_callback(void* context) {
  4. Nfc* nfc = (Nfc*)context;
  5. view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_EMV_DATA_CUSTOM_EVENT);
  6. }
  7. const void nfc_scene_read_emv_data_on_enter(void* context) {
  8. Nfc* nfc = (Nfc*)context;
  9. // Setup view
  10. Popup* popup = nfc->popup;
  11. popup_set_header(popup, "Reading\nbank card", 70, 34, AlignLeft, AlignTop);
  12. popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
  13. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  14. // Start worker
  15. nfc_worker_start(
  16. nfc->worker,
  17. NfcWorkerStateReadEMV,
  18. &nfc->dev.dev_data,
  19. nfc_read_emv_data_worker_callback,
  20. nfc);
  21. }
  22. const bool nfc_scene_read_emv_data_on_event(void* context, SceneManagerEvent event) {
  23. Nfc* nfc = (Nfc*)context;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == NFC_READ_EMV_DATA_CUSTOM_EVENT) {
  26. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvDataSuccess);
  27. return true;
  28. }
  29. } else if(event.type == SceneManagerEventTypeTick) {
  30. notification_message(nfc->notifications, &sequence_blink_blue_10);
  31. return true;
  32. }
  33. return false;
  34. }
  35. const void nfc_scene_read_emv_data_on_exit(void* context) {
  36. Nfc* nfc = (Nfc*)context;
  37. // Stop worker
  38. nfc_worker_stop(nfc->worker);
  39. // Send notification
  40. notification_message(nfc->notifications, &sequence_success);
  41. // Clear view
  42. Popup* popup = nfc->popup;
  43. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  44. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  45. popup_set_icon(popup, 0, 0, NULL);
  46. }