seader_i.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #pragma once
  2. #include <stdlib.h> // malloc
  3. #include <stdint.h> // uint32_t
  4. #include <stdarg.h> // __VA_ARGS__
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <furi.h>
  8. #include <furi_hal.h>
  9. #include <gui/gui.h>
  10. #include <gui/view_dispatcher.h>
  11. #include <gui/scene_manager.h>
  12. #include <notification/notification_messages.h>
  13. #include <seader_icons.h>
  14. #include <assets_icons.h>
  15. #include <gui/modules/submenu.h>
  16. #include <gui/modules/popup.h>
  17. #include <gui/modules/loading.h>
  18. #include <gui/modules/text_input.h>
  19. #include <gui/modules/text_box.h>
  20. #include <gui/modules/widget.h>
  21. #include <input/input.h>
  22. #include <lib/nfc/nfc.h>
  23. #include <nfc/nfc_poller.h>
  24. #include <nfc/nfc_device.h>
  25. #include <nfc/helpers/nfc_data_generator.h>
  26. // ASN1
  27. #include <asn_system.h>
  28. #include <asn_internal.h>
  29. #include <asn_codecs_prim.h>
  30. #include <asn_codecs.h>
  31. #include <asn_application.h>
  32. #include <Payload.h>
  33. #include <FrameProtocol.h>
  34. #include "plugin/interface.h"
  35. #include <flipper_application/flipper_application.h>
  36. #include <flipper_application/plugins/plugin_manager.h>
  37. #include <loader/firmware_api/firmware_api.h>
  38. #include "protocol/picopass_poller.h"
  39. #include "scenes/seader_scene.h"
  40. #include "seader_bridge.h"
  41. #include "seader.h"
  42. #include "ccid.h"
  43. #include "uart.h"
  44. #include "lrc.h"
  45. #include "seader_worker.h"
  46. #include "seader_credential.h"
  47. #define WORKER_ALL_RX_EVENTS \
  48. (WorkerEvtStop | WorkerEvtRxDone | WorkerEvtCfgChange | WorkerEvtLineCfgSet | \
  49. WorkerEvtCtrlLineSet | WorkerEvtSamTxComplete)
  50. #define WORKER_ALL_TX_EVENTS (WorkerEvtTxStop | WorkerEvtSamRx)
  51. #define SEADER_TEXT_STORE_SIZE 128
  52. enum SeaderCustomEvent {
  53. // Reserve first 100 events for button types and indexes, starting from 0
  54. SeaderCustomEventReserved = 100,
  55. SeaderCustomEventViewExit,
  56. SeaderCustomEventWorkerExit,
  57. SeaderCustomEventByteInputDone,
  58. SeaderCustomEventTextInputDone,
  59. SeaderCustomEventPollerDetect,
  60. SeaderCustomEventPollerSuccess,
  61. };
  62. typedef enum {
  63. WorkerEvtStop = (1 << 0),
  64. WorkerEvtRxDone = (1 << 1),
  65. WorkerEvtTxStop = (1 << 2),
  66. WorkerEvtSamRx = (1 << 3),
  67. WorkerEvtSamTxComplete = (1 << 4),
  68. WorkerEvtCfgChange = (1 << 5),
  69. WorkerEvtLineCfgSet = (1 << 6),
  70. WorkerEvtCtrlLineSet = (1 << 7),
  71. } WorkerEvtFlags;
  72. struct Seader {
  73. bool revert_power;
  74. bool is_debug_enabled;
  75. SeaderWorker* worker;
  76. ViewDispatcher* view_dispatcher;
  77. Gui* gui;
  78. NotificationApp* notifications;
  79. SceneManager* scene_manager;
  80. SeaderUartBridge* uart;
  81. SeaderCredential* credential;
  82. SamCommand_PR samCommand;
  83. char text_store[SEADER_TEXT_STORE_SIZE + 1];
  84. FuriString* text_box_store;
  85. // Common Views
  86. Submenu* submenu;
  87. Popup* popup;
  88. Loading* loading;
  89. TextInput* text_input;
  90. TextBox* text_box;
  91. Widget* widget;
  92. Nfc* nfc;
  93. NfcPoller* poller;
  94. PicopassPoller* picopass_poller;
  95. NfcDevice* nfc_device;
  96. PluginManager* plugin_manager;
  97. PluginWiegand* plugin_wiegand;
  98. };
  99. struct SeaderPollerContainer {
  100. Iso14443_4aPoller* iso14443_4a_poller;
  101. MfClassicPoller* mfc_poller;
  102. PicopassPoller* picopass_poller;
  103. };
  104. typedef enum {
  105. SeaderViewMenu,
  106. SeaderViewPopup,
  107. SeaderViewLoading,
  108. SeaderViewTextInput,
  109. SeaderViewTextBox,
  110. SeaderViewWidget,
  111. SeaderViewUart,
  112. } SeaderView;
  113. void seader_text_store_set(Seader* seader, const char* text, ...);
  114. void seader_text_store_clear(Seader* seader);
  115. void seader_blink_start(Seader* seader);
  116. void seader_blink_stop(Seader* seader);
  117. void seader_show_loading_popup(void* context, bool show);