nfc_scene_emulate_uid.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "../nfc_i.h"
  2. const void nfc_scene_emulate_uid_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 UID", 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, NfcWorkerStateEmulate, &nfc->dev.dev_data, NULL, nfc);
  30. }
  31. const bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
  32. Nfc* nfc = (Nfc*)context;
  33. if(event.type == SceneManagerEventTypeTick) {
  34. notification_message(nfc->notifications, &sequence_blink_blue_10);
  35. return true;
  36. }
  37. return false;
  38. }
  39. const void nfc_scene_emulate_uid_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. }