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