seader_i.h 2.9 KB

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