subghz_i.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #pragma once
  2. #include "subghz.h"
  3. #include "views/receiver.h"
  4. #include "views/transmitter.h"
  5. #include "views/subghz_frequency_analyzer.h"
  6. #include "views/subghz_read_raw.h"
  7. #include "views/subghz_test_static.h"
  8. #include "views/subghz_test_carrier.h"
  9. #include "views/subghz_test_packet.h"
  10. #include <furi.h>
  11. #include <furi_hal.h>
  12. #include <gui/gui.h>
  13. #include <dialogs/dialogs.h>
  14. #include <gui/scene_manager.h>
  15. #include <notification/notification_messages.h>
  16. #include <gui/view_dispatcher.h>
  17. #include <gui/modules/submenu.h>
  18. #include <gui/modules/popup.h>
  19. #include <gui/modules/text_input.h>
  20. #include <gui/modules/widget.h>
  21. #include <subghz/scenes/subghz_scene.h>
  22. #include <lib/subghz/subghz_worker.h>
  23. #include <lib/subghz/receiver.h>
  24. #include <lib/subghz/transmitter.h>
  25. #include "subghz_history.h"
  26. #include "subghz_setting.h"
  27. #include <gui/modules/variable_item_list.h>
  28. #define SUBGHZ_MAX_LEN_NAME 128
  29. /** SubGhzNotification state */
  30. typedef enum {
  31. SubGhzNotificationStateStarting,
  32. SubGhzNotificationStateIDLE,
  33. SubGhzNotificationStateTX,
  34. SubGhzNotificationStateRX,
  35. } SubGhzNotificationState;
  36. /** SubGhzTxRx state */
  37. typedef enum {
  38. SubGhzTxRxStateIDLE,
  39. SubGhzTxRxStateRx,
  40. SubGhzTxRxStateTx,
  41. SubGhzTxRxStateSleep,
  42. } SubGhzTxRxState;
  43. /** SubGhzHopperState state */
  44. typedef enum {
  45. SubGhzHopperStateOFF,
  46. SubGhzHopperStateRunnig,
  47. SubGhzHopperStatePause,
  48. SubGhzHopperStateRSSITimeOut,
  49. } SubGhzHopperState;
  50. /** SubGhzRxKeyState state */
  51. typedef enum {
  52. SubGhzRxKeyStateIDLE,
  53. SubGhzRxKeyStateNoSave,
  54. SubGhzRxKeyStateNeedSave,
  55. SubGhzRxKeyStateBack,
  56. SubGhzRxKeyStateStart,
  57. SubGhzRxKeyStateAddKey,
  58. SubGhzRxKeyStateExit,
  59. SubGhzRxKeyStateRAWLoad,
  60. SubGhzRxKeyStateRAWSave,
  61. } SubGhzRxKeyState;
  62. /** SubGhzLoadKeyState state */
  63. typedef enum {
  64. SubGhzLoadKeyStateUnknown,
  65. SubGhzLoadKeyStateOK,
  66. SubGhzLoadKeyStateParseErr,
  67. SubGhzLoadKeyStateOnlyRx,
  68. } SubGhzLoadKeyState;
  69. struct SubGhzTxRx {
  70. SubGhzWorker* worker;
  71. SubGhzEnvironment* environment;
  72. SubGhzReceiver* receiver;
  73. SubGhzTransmitter* transmitter;
  74. SubGhzProtocolDecoderBase* decoder_result;
  75. FlipperFormat* fff_data;
  76. uint32_t frequency;
  77. FuriHalSubGhzPreset preset;
  78. SubGhzHistory* history;
  79. uint16_t idx_menu_chosen;
  80. SubGhzTxRxState txrx_state;
  81. SubGhzHopperState hopper_state;
  82. uint8_t hopper_timeout;
  83. uint8_t hopper_idx_frequency;
  84. SubGhzRxKeyState rx_key_state;
  85. };
  86. typedef struct SubGhzTxRx SubGhzTxRx;
  87. struct SubGhz {
  88. Gui* gui;
  89. NotificationApp* notifications;
  90. SubGhzTxRx* txrx;
  91. SceneManager* scene_manager;
  92. ViewDispatcher* view_dispatcher;
  93. Submenu* submenu;
  94. Popup* popup;
  95. TextInput* text_input;
  96. Widget* widget;
  97. DialogsApp* dialogs;
  98. char file_name[SUBGHZ_MAX_LEN_NAME + 1];
  99. char file_name_tmp[SUBGHZ_MAX_LEN_NAME + 1];
  100. SubGhzNotificationState state_notifications;
  101. SubGhzViewReceiver* subghz_receiver;
  102. SubGhzViewTransmitter* subghz_transmitter;
  103. VariableItemList* variable_item_list;
  104. SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
  105. SubGhzReadRAW* subghz_read_raw;
  106. SubGhzTestStatic* subghz_test_static;
  107. SubGhzTestCarrier* subghz_test_carrier;
  108. SubGhzTestPacket* subghz_test_packet;
  109. string_t error_str;
  110. SubGhzSetting* setting;
  111. };
  112. typedef enum {
  113. SubGhzViewIdMenu,
  114. SubGhzViewIdReceiver,
  115. SubGhzViewIdPopup,
  116. SubGhzViewIdTextInput,
  117. SubGhzViewIdWidget,
  118. SubGhzViewIdTransmitter,
  119. SubGhzViewIdVariableItemList,
  120. SubGhzViewIdFrequencyAnalyzer,
  121. SubGhzViewIdReadRAW,
  122. SubGhzViewIdStatic,
  123. SubGhzViewIdTestCarrier,
  124. SubGhzViewIdTestPacket,
  125. } SubGhzViewId;
  126. bool subghz_set_preset(SubGhz* subghz, const char* preset);
  127. void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_t modulation);
  128. void subghz_begin(SubGhz* subghz, FuriHalSubGhzPreset preset);
  129. uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
  130. void subghz_rx_end(SubGhz* subghz);
  131. void subghz_sleep(SubGhz* subghz);
  132. bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
  133. void subghz_tx_stop(SubGhz* subghz);
  134. void subghz_dialog_message_show_only_rx(SubGhz* subghz);
  135. bool subghz_key_load(SubGhz* subghz, const char* file_path);
  136. bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
  137. bool subghz_save_protocol_to_file(
  138. SubGhz* subghz,
  139. FlipperFormat* flipper_format,
  140. const char* dev_name);
  141. bool subghz_load_protocol_from_file(SubGhz* subghz);
  142. bool subghz_rename_file(SubGhz* subghz);
  143. bool subghz_delete_file(SubGhz* subghz);
  144. void subghz_file_name_clear(SubGhz* subghz);
  145. uint32_t subghz_random_serial(void);
  146. void subghz_hopper_update(SubGhz* subghz);