| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- #pragma once
- #include <lib/subghz/subghz_worker.h>
- #include <lib/subghz/subghz_setting.h>
- #include <lib/subghz/receiver.h>
- #include <lib/subghz/transmitter.h>
- #include <lib/subghz/protocols/raw.h>
- #include <lib/subghz/devices/devices.h>
- typedef struct SubGhzTxRx SubGhzTxRx;
- typedef void (*SubGhzTxRxNeedSaveCallback)(void* context);
- typedef enum {
- SubGhzTxRxStartTxStateOk,
- SubGhzTxRxStartTxStateErrorOnlyRx,
- SubGhzTxRxStartTxStateErrorParserOthers,
- } SubGhzTxRxStartTxState;
- // Type from subghz_types.h need for txrx working
- /** SubGhzTxRx state */
- typedef enum {
- SubGhzTxRxStateIDLE,
- SubGhzTxRxStateRx,
- SubGhzTxRxStateTx,
- SubGhzTxRxStateSleep,
- } SubGhzTxRxState;
- /** SubGhzHopperState state */
- typedef enum {
- SubGhzHopperStateOFF,
- SubGhzHopperStateRunning,
- SubGhzHopperStatePause,
- SubGhzHopperStateRSSITimeOut,
- } SubGhzHopperState;
- /** SubGhzSpeakerState state */
- typedef enum {
- SubGhzSpeakerStateDisable,
- SubGhzSpeakerStateShutdown,
- SubGhzSpeakerStateEnable,
- } SubGhzSpeakerState;
- /** SubGhzRadioDeviceType */
- typedef enum {
- SubGhzRadioDeviceTypeAuto,
- SubGhzRadioDeviceTypeInternal,
- SubGhzRadioDeviceTypeExternalCC1101,
- } SubGhzRadioDeviceType;
- /**
- * Allocate SubGhzTxRx
- *
- * @return SubGhzTxRx* pointer to SubGhzTxRx
- */
- SubGhzTxRx* subghz_txrx_alloc(void);
- /**
- * Free SubGhzTxRx
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_free(SubGhzTxRx* instance);
- /**
- * Check if the database is loaded
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return bool True if the database is loaded
- */
- bool subghz_txrx_is_database_loaded(SubGhzTxRx* instance);
- /**
- * Set preset
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param preset_name Name of preset
- * @param frequency Frequency in Hz
- * @param preset_data Data of preset
- * @param preset_data_size Size of preset data
- */
- void subghz_txrx_set_preset(
- SubGhzTxRx* instance,
- const char* preset_name,
- uint32_t frequency,
- uint8_t* preset_data,
- size_t preset_data_size);
- /**
- * Get name of preset
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param preset String of preset
- * @return const char* Name of preset
- */
- const char* subghz_txrx_get_preset_name(SubGhzTxRx* instance, const char* preset);
- /**
- * Get of preset
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzRadioPreset Preset
- */
- SubGhzRadioPreset subghz_txrx_get_preset(SubGhzTxRx* instance);
- /**
- * Get string frequency and modulation
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param frequency Pointer to a string frequency
- * @param modulation Pointer to a string modulation
- */
- void subghz_txrx_get_frequency_and_modulation(
- SubGhzTxRx* instance,
- FuriString* frequency,
- FuriString* modulation,
- bool long_name);
- /**
- * Start TX CC1101
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param flipper_format Pointer to a FlipperFormat
- * @return SubGhzTxRxStartTxState
- */
- SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format);
- /**
- * Start RX CC1101
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_rx_start(SubGhzTxRx* instance);
- /**
- * Stop TX/RX CC1101
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_stop(SubGhzTxRx* instance);
- /**
- * Set sleep mode CC1101
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_sleep(SubGhzTxRx* instance);
- /**
- * Update frequency CC1101 in automatic mode (hopper)
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_hopper_update(SubGhzTxRx* instance);
- /**
- * Get state hopper
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzHopperState
- */
- SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance);
- /**
- * Set state hopper
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param state State hopper
- */
- void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
- /**
- * Unpause hopper
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_hopper_unpause(SubGhzTxRx* instance);
- /**
- * Set pause hopper
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_hopper_pause(SubGhzTxRx* instance);
- /**
- * Speaker on
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_speaker_on(SubGhzTxRx* instance);
- /**
- * Speaker off
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_speaker_off(SubGhzTxRx* instance);
- /**
- * Speaker mute
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_speaker_mute(SubGhzTxRx* instance);
- /**
- * Speaker unmute
- *
- * @param instance Pointer to a SubGhzTxRx
- */
- void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
- /**
- * Set state speaker
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param state State speaker
- */
- void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state);
- /**
- * Get state speaker
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzSpeakerState
- */
- SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance);
- /**
- * load decoder by name protocol
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param name_protocol Name protocol
- * @return bool True if the decoder is loaded
- */
- bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol);
- /**
- * Get decoder
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzProtocolDecoderBase* Pointer to a SubGhzProtocolDecoderBase
- */
- SubGhzProtocolDecoderBase* subghz_txrx_get_decoder(SubGhzTxRx* instance);
- /**
- * Set callback for save data
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param callback Callback for save data
- * @param context Context for callback
- */
- void subghz_txrx_set_need_save_callback(
- SubGhzTxRx* instance,
- SubGhzTxRxNeedSaveCallback callback,
- void* context);
- /**
- * Get pointer to a load data key
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return FlipperFormat*
- */
- FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance);
- /**
- * Get pointer to a SugGhzSetting
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzSetting*
- */
- SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* instance);
- /**
- * Is it possible to save this protocol
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return bool True if it is possible to save this protocol
- */
- bool subghz_txrx_protocol_is_serializable(SubGhzTxRx* instance);
- /**
- * Is it possible to send this protocol
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return bool True if it is possible to send this protocol
- */
- bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type);
- /**
- * Set filter, what types of decoder to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param filter Filter
- */
- void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter);
- /**
- * Set callback for receive data
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param callback Callback for receive data
- * @param context Context for callback
- */
- void subghz_txrx_set_rx_calback(
- SubGhzTxRx* instance,
- SubGhzReceiverCallback callback,
- void* context);
- /**
- * Set callback for Raw decoder, end of data transfer
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param callback Callback for Raw decoder, end of data transfer
- * @param context Context for callback
- */
- void subghz_txrx_set_raw_file_encoder_worker_callback_end(
- SubGhzTxRx* instance,
- SubGhzProtocolEncoderRAWCallbackEnd callback,
- void* context);
- /* Checking if an external radio device is connected
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param name Name of external radio device
- * @return bool True if is connected to the external radio device
- */
- bool subghz_txrx_radio_device_is_external_connected(SubGhzTxRx* instance, const char* name);
- /* Set the selected radio device to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @param radio_device_type Radio device type
- * @return SubGhzRadioDeviceType Type of installed radio device
- */
- SubGhzRadioDeviceType
- subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type);
- /* Get the selected radio device to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return SubGhzRadioDeviceType Type of installed radio device
- */
- SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance);
- /* Get RSSI the selected radio device to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return float RSSI
- */
- float subghz_txrx_radio_device_get_rssi(SubGhzTxRx* instance);
- /* Get name the selected radio device to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return const char* Name of installed radio device
- */
- const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance);
- /* Get get intelligence whether frequency the selected radio device to use
- *
- * @param instance Pointer to a SubGhzTxRx
- * @return bool True if the frequency is valid
- */
- bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency);
- bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency);
- void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state);
- bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);
- #ifndef FW_ORIGIN_Official
- void subghz_txrx_reset_dynamic_and_custom_btns(SubGhzTxRx* instance);
- #endif
- SubGhzReceiver* subghz_txrx_get_receiver(SubGhzTxRx* instance); // TODO use only in DecodeRaw
|