nfc_scene_read_emv_app.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. nfc_blink_start(nfc);
  24. }
  25. bool nfc_scene_read_emv_app_on_event(void* context, SceneManagerEvent event) {
  26. Nfc* nfc = context;
  27. bool consumed = false;
  28. if(event.type == SceneManagerEventTypeCustom) {
  29. if(event.event == NfcCustomEventWorkerExit) {
  30. scene_manager_set_scene_state(
  31. nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE);
  32. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
  33. consumed = true;
  34. }
  35. } else if(event.type == SceneManagerEventTypeTick) {
  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. nfc_blink_stop(nfc);
  47. }