subghz_i.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include <lib/toolbox/path.h>
  29. #define SUBGHZ_MAX_LEN_NAME 250
  30. /** SubGhzNotification state */
  31. typedef enum {
  32. SubGhzNotificationStateStarting,
  33. SubGhzNotificationStateIDLE,
  34. SubGhzNotificationStateTX,
  35. SubGhzNotificationStateRX,
  36. } SubGhzNotificationState;
  37. /** SubGhzTxRx state */
  38. typedef enum {
  39. SubGhzTxRxStateIDLE,
  40. SubGhzTxRxStateRx,
  41. SubGhzTxRxStateTx,
  42. SubGhzTxRxStateSleep,
  43. } SubGhzTxRxState;
  44. /** SubGhzHopperState state */
  45. typedef enum {
  46. SubGhzHopperStateOFF,
  47. SubGhzHopperStateRunnig,
  48. SubGhzHopperStatePause,
  49. SubGhzHopperStateRSSITimeOut,
  50. } SubGhzHopperState;
  51. /** SubGhzRxKeyState state */
  52. typedef enum {
  53. SubGhzRxKeyStateIDLE,
  54. SubGhzRxKeyStateNoSave,
  55. SubGhzRxKeyStateNeedSave,
  56. SubGhzRxKeyStateBack,
  57. SubGhzRxKeyStateStart,
  58. SubGhzRxKeyStateAddKey,
  59. SubGhzRxKeyStateExit,
  60. SubGhzRxKeyStateRAWLoad,
  61. SubGhzRxKeyStateRAWSave,
  62. } SubGhzRxKeyState;
  63. /** SubGhzLoadKeyState state */
  64. typedef enum {
  65. SubGhzLoadKeyStateUnknown,
  66. SubGhzLoadKeyStateOK,
  67. SubGhzLoadKeyStateParseErr,
  68. SubGhzLoadKeyStateOnlyRx,
  69. } SubGhzLoadKeyState;
  70. struct SubGhzTxRx {
  71. SubGhzWorker* worker;
  72. SubGhzEnvironment* environment;
  73. SubGhzReceiver* receiver;
  74. SubGhzTransmitter* transmitter;
  75. SubGhzProtocolDecoderBase* decoder_result;
  76. FlipperFormat* fff_data;
  77. uint32_t frequency;
  78. FuriHalSubGhzPreset preset;
  79. SubGhzHistory* history;
  80. uint16_t idx_menu_chosen;
  81. SubGhzTxRxState txrx_state;
  82. SubGhzHopperState hopper_state;
  83. uint8_t hopper_timeout;
  84. uint8_t hopper_idx_frequency;
  85. SubGhzRxKeyState rx_key_state;
  86. };
  87. typedef struct SubGhzTxRx SubGhzTxRx;
  88. struct SubGhz {
  89. Gui* gui;
  90. NotificationApp* notifications;
  91. SubGhzTxRx* txrx;
  92. SceneManager* scene_manager;
  93. ViewDispatcher* view_dispatcher;
  94. Submenu* submenu;
  95. Popup* popup;
  96. TextInput* text_input;
  97. Widget* widget;
  98. DialogsApp* dialogs;
  99. char file_path[SUBGHZ_MAX_LEN_NAME + 1];
  100. char file_path_tmp[SUBGHZ_MAX_LEN_NAME + 1];
  101. //ToDo you can get rid of it, you need to refactor text input to return the path to the folder
  102. char file_dir[SUBGHZ_MAX_LEN_NAME + 1];
  103. SubGhzNotificationState state_notifications;
  104. SubGhzViewReceiver* subghz_receiver;
  105. SubGhzViewTransmitter* subghz_transmitter;
  106. VariableItemList* variable_item_list;
  107. SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
  108. SubGhzReadRAW* subghz_read_raw;
  109. SubGhzTestStatic* subghz_test_static;
  110. SubGhzTestCarrier* subghz_test_carrier;
  111. SubGhzTestPacket* subghz_test_packet;
  112. string_t error_str;
  113. SubGhzSetting* setting;
  114. };
  115. typedef enum {
  116. SubGhzViewIdMenu,
  117. SubGhzViewIdReceiver,
  118. SubGhzViewIdPopup,
  119. SubGhzViewIdTextInput,
  120. SubGhzViewIdWidget,
  121. SubGhzViewIdTransmitter,
  122. SubGhzViewIdVariableItemList,
  123. SubGhzViewIdFrequencyAnalyzer,
  124. SubGhzViewIdReadRAW,
  125. SubGhzViewIdStatic,
  126. SubGhzViewIdTestCarrier,
  127. SubGhzViewIdTestPacket,
  128. } SubGhzViewId;
  129. bool subghz_set_preset(SubGhz* subghz, const char* preset);
  130. void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_t modulation);
  131. void subghz_begin(SubGhz* subghz, FuriHalSubGhzPreset preset);
  132. uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
  133. void subghz_rx_end(SubGhz* subghz);
  134. void subghz_sleep(SubGhz* subghz);
  135. bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
  136. void subghz_tx_stop(SubGhz* subghz);
  137. void subghz_dialog_message_show_only_rx(SubGhz* subghz);
  138. bool subghz_key_load(SubGhz* subghz, const char* file_path);
  139. bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
  140. bool subghz_save_protocol_to_file(
  141. SubGhz* subghz,
  142. FlipperFormat* flipper_format,
  143. const char* dev_file_name);
  144. bool subghz_load_protocol_from_file(SubGhz* subghz);
  145. bool subghz_rename_file(SubGhz* subghz);
  146. bool subghz_delete_file(SubGhz* subghz);
  147. void subghz_file_name_clear(SubGhz* subghz);
  148. uint32_t subghz_random_serial(void);
  149. void subghz_hopper_update(SubGhz* subghz);