nfc_scene_read_emv_app.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. void nfc_read_emv_app_worker_callback(NfcWorkerEvent event, void* context) {
  4. UNUSED(event);
  5. Nfc* nfc = context;
  6. view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
  7. }
  8. void nfc_scene_read_emv_app_on_enter(void* context) {
  9. Nfc* nfc = context;
  10. DOLPHIN_DEED(DolphinDeedNfcRead);
  11. // Setup view
  12. Popup* popup = nfc->popup;
  13. popup_set_header(popup, "Reading\nbank card", 70, 34, AlignLeft, AlignTop);
  14. popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
  15. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  16. // Start worker
  17. nfc_worker_start(
  18. nfc->worker,
  19. NfcWorkerStateReadEMVApp,
  20. &nfc->dev->dev_data,
  21. nfc_read_emv_app_worker_callback,
  22. nfc);
  23. }
  24. bool nfc_scene_read_emv_app_on_event(void* context, SceneManagerEvent event) {
  25. Nfc* nfc = context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. if(event.event == NfcCustomEventWorkerExit) {
  29. scene_manager_set_scene_state(
  30. nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE);
  31. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
  32. consumed = true;
  33. }
  34. } else if(event.type == SceneManagerEventTypeTick) {
  35. notification_message(nfc->notifications, &sequence_blink_blue_10);
  36. consumed = true;
  37. }
  38. return consumed;
  39. }
  40. void nfc_scene_read_emv_app_on_exit(void* context) {
  41. Nfc* nfc = context;
  42. // Stop worker
  43. nfc_worker_stop(nfc->worker);
  44. // Clear view
  45. popup_reset(nfc->popup);
  46. }