lfrfid_app_scene_emulate.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "lfrfid_app_scene_emulate.h"
  2. #include <core/common_defines.h>
  3. #include <dolphin/dolphin.h>
  4. void LfRfidAppSceneEmulate::on_enter(LfRfidApp* app, bool /* need_restore */) {
  5. string_init(data_string);
  6. DOLPHIN_DEED(DolphinDeedRfidEmulate);
  7. const uint8_t* data = app->worker.key.get_data();
  8. for(uint8_t i = 0; i < app->worker.key.get_type_data_count(); i++) {
  9. string_cat_printf(data_string, "%02X", data[i]);
  10. }
  11. auto popup = app->view_controller.get<PopupVM>();
  12. popup->set_header("Emulating", 89, 30, AlignCenter, AlignTop);
  13. if(strlen(app->worker.key.get_name())) {
  14. popup->set_text(app->worker.key.get_name(), 89, 43, AlignCenter, AlignTop);
  15. } else {
  16. popup->set_text(string_get_cstr(data_string), 89, 43, AlignCenter, AlignTop);
  17. }
  18. popup->set_icon(0, 3, &I_RFIDDolphinSend_97x61);
  19. app->view_controller.switch_to<PopupVM>();
  20. app->worker.start_emulate();
  21. notification_message(app->notification, &sequence_blink_start_magenta);
  22. }
  23. bool LfRfidAppSceneEmulate::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  24. UNUSED(app);
  25. UNUSED(event);
  26. bool consumed = false;
  27. return consumed;
  28. }
  29. void LfRfidAppSceneEmulate::on_exit(LfRfidApp* app) {
  30. app->view_controller.get<PopupVM>()->clean();
  31. app->worker.stop_emulate();
  32. string_clear(data_string);
  33. notification_message(app->notification, &sequence_blink_stop);
  34. }