seader_i.h 3.5 KB

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