seader_i.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 | WorkerEvtSamTxComplete)
  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. WorkerEvtSamTxComplete = (1 << 4),
  61. WorkerEvtCfgChange = (1 << 5),
  62. WorkerEvtLineCfgSet = (1 << 6),
  63. WorkerEvtCtrlLineSet = (1 << 7),
  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. SamCommand_PR samCommand;
  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);