nfc_scene_emulate_uid.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. NfcDeviceData* data = &nfc->device.data;
  7. if(strcmp(nfc->device.dev_name, "")) {
  8. nfc_text_store_set(nfc, "%s", nfc->device.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. nfc_worker_set_emulation_params(nfc->nfc_common.worker, data);
  29. nfc_worker_start(
  30. nfc->nfc_common.worker, NfcWorkerStateEmulate, &nfc->nfc_common.worker_result, NULL, nfc);
  31. view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewPopup);
  32. }
  33. const bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {
  34. Nfc* nfc = (Nfc*)context;
  35. if(event.type == SceneManagerEventTypeTick) {
  36. notification_message(nfc->notifications, &sequence_blink_blue_10);
  37. return true;
  38. }
  39. return false;
  40. }
  41. const void nfc_scene_emulate_uid_on_exit(void* context) {
  42. Nfc* nfc = (Nfc*)context;
  43. // Stop worker
  44. nfc_worker_stop(nfc->nfc_common.worker);
  45. // Clear view
  46. Popup* popup = nfc->popup;
  47. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  48. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  49. popup_set_icon(popup, 0, 0, NULL);
  50. }