nfc_scene_read_emv_data.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 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. // Clear emv data
  15. memset(&nfc->dev.dev_data.emv_data, 0, sizeof(nfc->dev.dev_data.emv_data));
  16. // Start worker
  17. nfc_worker_start(
  18. nfc->worker,
  19. NfcWorkerStateReadEMV,
  20. &nfc->dev.dev_data,
  21. nfc_read_emv_data_worker_callback,
  22. nfc);
  23. }
  24. bool nfc_scene_read_emv_data_on_event(void* context, SceneManagerEvent event) {
  25. Nfc* nfc = (Nfc*)context;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. if(event.event == NFC_READ_EMV_DATA_CUSTOM_EVENT) {
  28. scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvDataSuccess);
  29. return true;
  30. }
  31. } else if(event.type == SceneManagerEventTypeTick) {
  32. notification_message(nfc->notifications, &sequence_blink_blue_10);
  33. return true;
  34. }
  35. return false;
  36. }
  37. void nfc_scene_read_emv_data_on_exit(void* context) {
  38. Nfc* nfc = (Nfc*)context;
  39. // Stop worker
  40. nfc_worker_stop(nfc->worker);
  41. // Send notification
  42. notification_message(nfc->notifications, &sequence_success);
  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. }