2022-03-03 09:48:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include "protocols/base.h"
|
|
|
|
|
|
|
|
typedef struct SubGhzReceiver SubGhzReceiver;
|
|
|
|
|
|
|
|
typedef void (*SubGhzReceiverCallback)(
|
|
|
|
SubGhzReceiver* decoder,
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
void* context);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Allocate and init SubGhzReceiver.
|
|
|
|
* @param environment Pointer to a SubGhzEnvironment instance
|
|
|
|
* @return SubGhzReceiver* pointer to a SubGhzReceiver instance
|
|
|
|
*/
|
|
|
|
SubGhzReceiver* subghz_receiver_alloc_init(SubGhzEnvironment* environment);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Free SubGhzReceiver.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_receiver_free(SubGhzReceiver* instance);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Parse a raw sequence of levels and durations received from the air.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
* @param level Signal level true-high false-low
|
|
|
|
* @param duration Duration of this level in, us
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_receiver_decode(SubGhzReceiver* instance, bool level, uint32_t duration);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Reset decoder SubGhzReceiver.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_receiver_reset(SubGhzReceiver* instance);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Set a callback upon completion of successful decoding of one of the protocols.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
* @param callback Callback, SubGhzReceiverCallback
|
|
|
|
* @param context Context
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_receiver_set_rx_callback(
|
|
|
|
SubGhzReceiver* instance,
|
|
|
|
SubGhzReceiverCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Set the filter of receivers that will work at the moment.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
* @param filter Filter, SubGhzProtocolFlag
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag filter);
|
2022-03-16 09:18:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Search for a cattery by his name.
|
|
|
|
* @param instance Pointer to a SubGhzReceiver instance
|
|
|
|
* @param decoder_name Receiver name
|
|
|
|
* @return SubGhzProtocolDecoderBase* pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
SubGhzProtocolDecoderBase*
|
|
|
|
subghz_receiver_search_decoder_base_by_name(SubGhzReceiver* instance, const char* decoder_name);
|