seader_i.h 3.0 KB

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