subghz_i.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 40
  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. SubGhzRxKeyStateAddKey,
  57. SubGhzRxKeyStateExit,
  58. SubGhzRxKeyStateRAWLoad,
  59. SubGhzRxKeyStateRAWSave,
  60. } SubGhzRxKeyState;
  61. /** SubGhzLoadKeyState state */
  62. typedef enum {
  63. SubGhzLoadKeyStateUnknown,
  64. SubGhzLoadKeyStateOK,
  65. SubGhzLoadKeyStateParseErr,
  66. SubGhzLoadKeyStateOnlyRx,
  67. } SubGhzLoadKeyState;
  68. struct SubGhzTxRx {
  69. SubGhzWorker* worker;
  70. SubGhzEnvironment* environment;
  71. SubGhzReceiver* receiver;
  72. SubGhzTransmitter* transmitter;
  73. SubGhzProtocolDecoderBase* decoder_result;
  74. FlipperFormat* fff_data;
  75. uint32_t frequency;
  76. FuriHalSubGhzPreset preset;
  77. SubGhzHistory* history;
  78. uint16_t idx_menu_chosen;
  79. SubGhzTxRxState txrx_state;
  80. SubGhzHopperState hopper_state;
  81. uint8_t hopper_timeout;
  82. uint8_t hopper_idx_frequency;
  83. SubGhzRxKeyState rx_key_state;
  84. };
  85. typedef struct SubGhzTxRx SubGhzTxRx;
  86. struct SubGhz {
  87. Gui* gui;
  88. NotificationApp* notifications;
  89. SubGhzTxRx* txrx;
  90. SceneManager* scene_manager;
  91. ViewDispatcher* view_dispatcher;
  92. Submenu* submenu;
  93. Popup* popup;
  94. TextInput* text_input;
  95. Widget* widget;
  96. DialogsApp* dialogs;
  97. char file_name[SUBGHZ_MAX_LEN_NAME + 1];
  98. char file_name_tmp[SUBGHZ_MAX_LEN_NAME + 1];
  99. SubGhzNotificationState state_notifications;
  100. SubGhzViewReceiver* subghz_receiver;
  101. SubGhzViewTransmitter* subghz_transmitter;
  102. VariableItemList* variable_item_list;
  103. SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
  104. SubGhzReadRAW* subghz_read_raw;
  105. SubGhzTestStatic* subghz_test_static;
  106. SubGhzTestCarrier* subghz_test_carrier;
  107. SubGhzTestPacket* subghz_test_packet;
  108. string_t error_str;
  109. SubGhzSetting* setting;
  110. };
  111. typedef enum {
  112. SubGhzViewIdMenu,
  113. SubGhzViewIdReceiver,
  114. SubGhzViewIdPopup,
  115. SubGhzViewIdTextInput,
  116. SubGhzViewIdWidget,
  117. SubGhzViewIdTransmitter,
  118. SubGhzViewIdVariableItemList,
  119. SubGhzViewIdFrequencyAnalyzer,
  120. SubGhzViewIdReadRAW,
  121. SubGhzViewIdStatic,
  122. SubGhzViewIdTestCarrier,
  123. SubGhzViewIdTestPacket,
  124. } SubGhzViewId;
  125. bool subghz_set_preset(SubGhz* subghz, const char* preset);
  126. void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_t modulation);
  127. void subghz_begin(SubGhz* subghz, FuriHalSubGhzPreset preset);
  128. uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
  129. void subghz_rx_end(SubGhz* subghz);
  130. void subghz_sleep(SubGhz* subghz);
  131. bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
  132. void subghz_tx_stop(SubGhz* subghz);
  133. void subghz_dialog_message_show_only_rx(SubGhz* subghz);
  134. bool subghz_key_load(SubGhz* subghz, const char* file_path);
  135. bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
  136. bool subghz_save_protocol_to_file(
  137. SubGhz* subghz,
  138. FlipperFormat* flipper_format,
  139. const char* dev_name);
  140. bool subghz_load_protocol_from_file(SubGhz* subghz);
  141. bool subghz_rename_file(SubGhz* subghz);
  142. bool subghz_delete_file(SubGhz* subghz);
  143. void subghz_file_name_clear(SubGhz* subghz);
  144. uint32_t subghz_random_serial(void);
  145. void subghz_hopper_update(SubGhz* subghz);