seader_i.h 3.2 KB

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