seader_i.h 3.8 KB

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