nfc_scene_emulate_mifare_ul.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "../nfc_i.h"
  2. const void nfc_scene_emulate_mifare_ul_on_enter(void* context) {
  3. Nfc* nfc = (Nfc*)context;
  4. // Setup view
  5. Popup* popup = nfc->popup;
  6. NfcDeviceCommomData* data = &nfc->dev.dev_data.nfc_data;
  7. if(strcmp(nfc->dev.dev_name, "")) {
  8. nfc_text_store_set(nfc, "%s", nfc->dev.dev_name);
  9. } else if(data->uid_len == 4) {
  10. nfc_text_store_set(
  11. nfc, "%02X %02X %02X %02X", data->uid[0], data->uid[1], data->uid[2], data->uid[3]);
  12. } else if(data->uid_len == 7) {
  13. nfc_text_store_set(
  14. nfc,
  15. "%02X %02X %02X %02X\n%02X %02X %02X",
  16. data->uid[0],
  17. data->uid[1],
  18. data->uid[2],
  19. data->uid[3],
  20. data->uid[4],
  21. data->uid[5],
  22. data->uid[6]);
  23. }
  24. popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
  25. popup_set_header(popup, "Emulating Mf Ul", 56, 31, AlignLeft, AlignTop);
  26. popup_set_text(popup, nfc->text_store, 56, 43, AlignLeft, AlignTop);
  27. // Setup and start worker
  28. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  29. nfc_worker_start(nfc->worker, NfcWorkerStateEmulateMifareUl, &nfc->dev.dev_data, NULL, nfc);
  30. }
  31. const bool nfc_scene_emulate_mifare_ul_on_event(void* context, SceneManagerEvent event) {
  32. Nfc* nfc = (Nfc*)context;
  33. bool consumed = false;
  34. if(event.type == SceneManagerEventTypeTick) {
  35. notification_message(nfc->notifications, &sequence_blink_blue_10);
  36. consumed = true;
  37. }
  38. return consumed;
  39. }
  40. const void nfc_scene_emulate_mifare_ul_on_exit(void* context) {
  41. Nfc* nfc = (Nfc*)context;
  42. // Stop worker
  43. nfc_worker_stop(nfc->worker);
  44. // Clear view
  45. Popup* popup = nfc->popup;
  46. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  47. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  48. popup_set_icon(popup, 0, 0, NULL);
  49. }