nfc_scene_read_emv_app.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. #define NFC_READ_EMV_APP_CUSTOM_EVENT (10UL)
  4. void nfc_read_emv_app_worker_callback(void* context) {
  5. Nfc* nfc = (Nfc*)context;
  6. view_dispatcher_send_custom_event(nfc->view_dispatcher, NFC_READ_EMV_APP_CUSTOM_EVENT);
  7. }
  8. void nfc_scene_read_emv_app_on_enter(void* context) {
  9. Nfc* 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 = (Nfc*)context;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. if(event.event == NFC_READ_EMV_APP_CUSTOM_EVENT) {
  28. scene_manager_set_scene_state(
  29. nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_TRUE);
  30. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
  31. return true;
  32. }
  33. } else if(event.type == SceneManagerEventTypeTick) {
  34. notification_message(nfc->notifications, &sequence_blink_blue_10);
  35. return true;
  36. }
  37. return false;
  38. }
  39. void nfc_scene_read_emv_app_on_exit(void* context) {
  40. Nfc* nfc = (Nfc*)context;
  41. // Stop worker
  42. nfc_worker_stop(nfc->worker);
  43. // Clear view
  44. Popup* popup = nfc->popup;
  45. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  46. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  47. popup_set_icon(popup, 0, 0, NULL);
  48. }