subghz_i.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #pragma once
  2. #include "subghz.h"
  3. #include "views/subghz_receiver.h"
  4. #include "views/subghz_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 <gui/scene_manager.h>
  14. #include <notification/notification-messages.h>
  15. #include <gui/view_dispatcher.h>
  16. #include <gui/modules/submenu.h>
  17. #include <gui/modules/popup.h>
  18. #include <gui/modules/text_input.h>
  19. #include <gui/modules/widget.h>
  20. #include <subghz/scenes/subghz_scene.h>
  21. #include <lib/subghz/subghz_worker.h>
  22. #include <lib/subghz/subghz_parser.h>
  23. #include <lib/subghz/protocols/subghz_protocol_common.h>
  24. #include "subghz_history.h"
  25. #include <gui/modules/variable-item-list.h>
  26. #define SUBGHZ_TEXT_STORE_SIZE 40
  27. #define NOTIFICATION_STARTING_STATE 0u
  28. #define NOTIFICATION_IDLE_STATE 1u
  29. #define NOTIFICATION_TX_STATE 2u
  30. #define NOTIFICATION_RX_STATE 3u
  31. extern const char* const subghz_frequencies_text[];
  32. extern const uint32_t subghz_frequencies[];
  33. extern const uint32_t subghz_hopper_frequencies[];
  34. extern const uint32_t subghz_frequencies_count;
  35. extern const uint32_t subghz_hopper_frequencies_count;
  36. extern const uint32_t subghz_frequencies_433_92;
  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. SubGhzRxKeyStateAddKey,
  57. SubGhzRxKeyStateExit,
  58. } SubGhzRxKeyState;
  59. struct SubGhzTxRx {
  60. SubGhzWorker* worker;
  61. SubGhzParser* parser;
  62. SubGhzProtocolCommon* protocol_result;
  63. SubGhzProtocolCommonEncoder* encoder;
  64. uint32_t frequency;
  65. FuriHalSubGhzPreset preset;
  66. SubGhzHistory* history;
  67. uint16_t idx_menu_chosen;
  68. SubGhzTxRxState txrx_state;
  69. SubGhzHopperState hopper_state;
  70. uint8_t hopper_timeout;
  71. uint8_t hopper_idx_frequency;
  72. SubGhzRxKeyState rx_key_state;
  73. };
  74. typedef struct SubGhzTxRx SubGhzTxRx;
  75. struct SubGhz {
  76. Gui* gui;
  77. NotificationApp* notifications;
  78. SubGhzTxRx* txrx;
  79. SceneManager* scene_manager;
  80. ViewDispatcher* view_dispatcher;
  81. Submenu* submenu;
  82. Popup* popup;
  83. TextInput* text_input;
  84. Widget* widget;
  85. char file_name[SUBGHZ_TEXT_STORE_SIZE + 1];
  86. char file_name_tmp[SUBGHZ_TEXT_STORE_SIZE + 1];
  87. uint8_t state_notifications;
  88. SubghzReceiver* subghz_receiver;
  89. SubghzTransmitter* subghz_transmitter;
  90. VariableItemList* variable_item_list;
  91. SubghzFrequencyAnalyzer* subghz_frequency_analyzer;
  92. SubghzReadRAW* subghz_read_raw;
  93. SubghzTestStatic* subghz_test_static;
  94. SubghzTestCarrier* subghz_test_carrier;
  95. SubghzTestPacket* subghz_test_packet;
  96. string_t error_str;
  97. };
  98. typedef enum {
  99. SubGhzViewMenu,
  100. SubGhzViewReceiver,
  101. SubGhzViewPopup,
  102. SubGhzViewTextInput,
  103. SubGhzViewWidget,
  104. SubGhzViewTransmitter,
  105. SubGhzViewVariableItemList,
  106. SubGhzViewFrequencyAnalyzer,
  107. SubGhzViewReadRAW,
  108. SubGhzViewStatic,
  109. SubGhzViewTestCarrier,
  110. SubGhzViewTestPacket,
  111. } SubGhzView;
  112. void subghz_begin(SubGhz* subghz, FuriHalSubGhzPreset preset);
  113. uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency);
  114. void subghz_rx_end(SubGhz* subghz);
  115. void subghz_sleep(SubGhz* subghz);
  116. bool subghz_tx_start(SubGhz* subghz);
  117. void subghz_tx_stop(SubGhz* subghz);
  118. bool subghz_key_load(SubGhz* subghz, const char* file_path);
  119. bool subghz_get_next_name_file(SubGhz* subghz);
  120. bool subghz_save_protocol_to_file(SubGhz* subghz, const char* dev_name);
  121. bool subghz_load_protocol_from_file(SubGhz* subghz);
  122. bool subghz_rename_file(SubGhz* subghz);
  123. bool subghz_delete_file(SubGhz* subghz);
  124. void subghz_file_name_clear(SubGhz* subghz);
  125. uint32_t subghz_random_serial(void);
  126. void subghz_hopper_update(SubGhz* subghz);