seader_i.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 <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 "t_1.h"
  46. #include "seader_worker.h"
  47. #include "seader_credential.h"
  48. #include "apdu_log.h"
  49. #define WORKER_ALL_RX_EVENTS \
  50. (WorkerEvtStop | WorkerEvtRxDone | WorkerEvtCfgChange | WorkerEvtLineCfgSet | \
  51. WorkerEvtCtrlLineSet | WorkerEvtSamTxComplete)
  52. #define WORKER_ALL_TX_EVENTS (WorkerEvtTxStop | WorkerEvtSamRx)
  53. #define SEADER_TEXT_STORE_SIZE 128
  54. enum SeaderCustomEvent {
  55. // Reserve first 100 events for button types and indexes, starting from 0
  56. SeaderCustomEventReserved = 100,
  57. SeaderCustomEventViewExit,
  58. SeaderCustomEventWorkerExit,
  59. SeaderCustomEventByteInputDone,
  60. SeaderCustomEventTextInputDone,
  61. SeaderCustomEventPollerDetect,
  62. SeaderCustomEventPollerSuccess,
  63. };
  64. typedef enum {
  65. WorkerEvtStop = (1 << 0),
  66. WorkerEvtRxDone = (1 << 1),
  67. WorkerEvtTxStop = (1 << 2),
  68. WorkerEvtSamRx = (1 << 3),
  69. WorkerEvtSamTxComplete = (1 << 4),
  70. WorkerEvtCfgChange = (1 << 5),
  71. WorkerEvtLineCfgSet = (1 << 6),
  72. WorkerEvtCtrlLineSet = (1 << 7),
  73. } WorkerEvtFlags;
  74. typedef struct {
  75. uint16_t total_lines;
  76. uint16_t current_line;
  77. } SeaderAPDURunnerContext;
  78. struct Seader {
  79. bool revert_power;
  80. bool is_debug_enabled;
  81. SeaderWorker* worker;
  82. ViewDispatcher* view_dispatcher;
  83. Gui* gui;
  84. NotificationApp* notifications;
  85. SceneManager* scene_manager;
  86. SeaderUartBridge* uart;
  87. SeaderCredential* credential;
  88. SamCommand_PR samCommand;
  89. char text_store[SEADER_TEXT_STORE_SIZE + 1];
  90. FuriString* text_box_store;
  91. // Common Views
  92. Submenu* submenu;
  93. Popup* popup;
  94. Loading* loading;
  95. TextInput* text_input;
  96. TextBox* text_box;
  97. Widget* widget;
  98. Nfc* nfc;
  99. NfcPoller* poller;
  100. PicopassPoller* picopass_poller;
  101. NfcDevice* nfc_device;
  102. PluginManager* plugin_manager;
  103. PluginWiegand* plugin_wiegand;
  104. APDULog* apdu_log;
  105. SeaderAPDURunnerContext apdu_runner_ctx;
  106. };
  107. struct SeaderPollerContainer {
  108. Iso14443_4aPoller* iso14443_4a_poller;
  109. MfClassicPoller* mfc_poller;
  110. PicopassPoller* picopass_poller;
  111. };
  112. typedef enum {
  113. SeaderViewMenu,
  114. SeaderViewPopup,
  115. SeaderViewLoading,
  116. SeaderViewTextInput,
  117. SeaderViewTextBox,
  118. SeaderViewWidget,
  119. SeaderViewUart,
  120. } SeaderView;
  121. void seader_text_store_set(Seader* seader, const char* text, ...);
  122. void seader_text_store_clear(Seader* seader);
  123. void seader_blink_start(Seader* seader);
  124. void seader_blink_stop(Seader* seader);
  125. void seader_show_loading_popup(void* context, bool show);