lfrfid_app_scene_emulate.cpp 1.7 KB

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