#pragma once #include "helpers/subghz_types.h" #include "helpers/subghz_error_type.h" #include #include "subghz.h" #include "views/receiver.h" #include "views/transmitter.h" #include "views/subghz_frequency_analyzer.h" #include "views/subghz_read_raw.h" #include "views/subghz_test_carrier.h" #if FURI_DEBUG #include "views/subghz_test_static.h" #include "views/subghz_test_packet.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "subghz_history.h" #include "subghz_last_settings.h" #include #include #include "rpc/rpc_app.h" #include "helpers/subghz_threshold_rssi.h" #define SUBGHZ_MAX_LEN_NAME 64 #define SUBGHZ_EXT_PRESET_NAME true typedef struct { uint8_t fix[4]; uint8_t cnt[3]; uint8_t seed[4]; } SecureData; typedef enum { SubGhzDecodeRawStateStart, SubGhzDecodeRawStateLoading, SubGhzDecodeRawStateLoaded, } SubGhzDecodeRawState; struct SubGhzTxRx { SubGhzWorker* worker; SubGhzEnvironment* environment; SubGhzReceiver* receiver; SubGhzTransmitter* transmitter; SubGhzProtocolFlag filter; SubGhzProtocolDecoderBase* decoder_result; FlipperFormat* fff_data; SecureData* secure_data; SubGhzRadioPreset* preset; SubGhzHistory* history; uint16_t idx_menu_chosen; uint8_t hopper_timeout; uint8_t hopper_idx_frequency; SubGhzHopperState hopper_state; SubGhzSpeakerState speaker_state; SubGhzTxRxState txrx_state; bool ignore_starline; bool ignore_auto_alarms; bool ignore_magellan; SubGhzLoadTypeFile load_type_file; bool debug_pin_state; }; typedef struct SubGhzTxRx SubGhzTxRx; struct SubGhz { Gui* gui; NotificationApp* notifications; SubGhzTxRx* txrx; SceneManager* scene_manager; ViewDispatcher* view_dispatcher; Submenu* submenu; Popup* popup; TextInput* text_input; ByteInput* byte_input; Widget* widget; DialogsApp* dialogs; FuriString* file_path; FuriString* file_path_tmp; char file_name_tmp[SUBGHZ_MAX_LEN_NAME]; SubGhzNotificationState state_notifications; SubGhzViewReceiver* subghz_receiver; SubGhzViewTransmitter* subghz_transmitter; VariableItemList* variable_item_list; SubGhzFrequencyAnalyzer* subghz_frequency_analyzer; SubGhzReadRAW* subghz_read_raw; bool raw_send_only; SubGhzTestCarrier* subghz_test_carrier; #if FURI_DEBUG SubGhzTestStatic* subghz_test_static; SubGhzTestPacket* subghz_test_packet; #endif SubGhzSetting* setting; SubGhzLastSettings* last_settings; FuriString* error_str; SubGhzLock lock; bool in_decoder_scene; bool in_decoder_scene_skip; SubGhzDecodeRawState decode_raw_state; SubGhzFileEncoderWorker* decode_raw_file_worker_encoder; SubGhzThresholdRssi* threshold_rssi; SubGhzRxKeyState rx_key_state; void* rpc_ctx; }; void subghz_preset_init( void* context, const char* preset_name, uint32_t frequency, uint8_t* preset_data, size_t preset_data_size); bool subghz_set_preset(SubGhz* subghz, const char* preset); void subghz_get_frequency_modulation(SubGhz* subghz, FuriString* frequency, FuriString* modulation); void subghz_begin(SubGhz* subghz, uint8_t* preset_data); uint32_t subghz_rx(SubGhz* subghz, uint32_t frequency); void subghz_rx_end(SubGhz* subghz); void subghz_sleep(SubGhz* subghz); void subghz_blink_start(SubGhz* instance); void subghz_blink_stop(SubGhz* instance); bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format); void subghz_tx_stop(SubGhz* subghz); void subghz_dialog_message_show_only_rx(SubGhz* subghz); bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog); bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len); bool subghz_save_protocol_to_file( SubGhz* subghz, FlipperFormat* flipper_format, const char* dev_file_name); bool subghz_load_protocol_from_file(SubGhz* subghz); bool subghz_rename_file(SubGhz* subghz); bool subghz_file_available(SubGhz* subghz); bool subghz_delete_file(SubGhz* subghz); void subghz_file_name_clear(SubGhz* subghz); bool subghz_path_is_file(FuriString* path); uint32_t subghz_random_serial(void); void subghz_hopper_update(SubGhz* subghz); void subghz_speaker_on(SubGhz* subghz); void subghz_speaker_off(SubGhz* subghz); void subghz_speaker_mute(SubGhz* subghz); void subghz_speaker_unmute(SubGhz* subghz); void subghz_speaker_set_state(SubGhz* subghz, SubGhzSpeakerState state); SubGhzSpeakerState subghz_speaker_get_state(SubGhz* subghz); void subghz_txrx_stop(SubGhz* subghz); SubGhzTxRxState subghz_txrx_get_state(SubGhz* subghz); SubGhzHopperState subghz_hopper_get_state(SubGhz* subghz); void subghz_hopper_set_state(SubGhz* subghz, SubGhzHopperState state); void subghz_hopper_remove_pause(SubGhz* subghz); void subghz_subghz_hopper_set_pause(SubGhz* subghz); void subghz_lock(SubGhz* subghz); void subghz_unlock(SubGhz* subghz); bool subghz_is_locked(SubGhz* subghz); SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz); void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state); SubGhzRxKeyState subghz_rx_key_state_get(SubGhz* subghz); //#############Create new Key############## bool subghz_gen_data_protocol( void* context, const char* preset_name, uint32_t frequency, const char* protocol_name, uint64_t key, uint32_t bit); bool subghz_gen_data_protocol_and_te( SubGhz* subghz, const char* preset_name, uint32_t frequency, const char* protocol_name, uint64_t key, uint32_t bit, uint32_t te); bool subghz_scene_set_type_submenu_gen_data_keeloq( void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt, const char* manufacture_name); bool subghz_scene_set_type_submenu_gen_data_keeloq_bft( //TODO rename void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt, uint32_t seed, const char* manufacture_name); bool subghz_scene_set_type_submenu_gen_data_nice_flor( //TODO rename void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt, bool nice_one); bool subghz_scene_set_type_submenu_gen_data_faac_slh( //TODO rename void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt, uint32_t seed, const char* manufacture_name); bool subghz_scene_set_type_submenu_gen_data_alutech_at_4n( //TODO rename void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt); bool subghz_scene_set_type_submenu_gen_data_somfy_telis( //TODO rename void* context, const char* preset_name, uint32_t frequency, uint32_t serial, uint8_t btn, uint16_t cnt); bool subghz_gen_secplus_v2_protocol( SubGhz* subghz, const char* name_preset, uint32_t frequency, uint32_t serial, uint8_t btn, uint32_t cnt); bool subghz_gen_secplus_v1_protocol(SubGhz* subghz, const char* name_preset, uint32_t frequency); extern const NotificationSequence subghz_sequence_rx; extern const NotificationSequence subghz_sequence_rx_locked;