2022-03-03 09:48:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../types.h"
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
typedef struct SubGhzProtocolDecoderBase SubGhzProtocolDecoderBase;
|
|
|
|
|
|
|
|
typedef void (
|
|
|
|
*SubGhzProtocolDecoderBaseRxCallback)(SubGhzProtocolDecoderBase* instance, void* context);
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
typedef void (*SubGhzProtocolDecoderBaseSerialize)(
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
FuriString* output);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
|
|
|
struct SubGhzProtocolDecoderBase {
|
|
|
|
// Decoder general section
|
|
|
|
const SubGhzProtocol* protocol;
|
|
|
|
|
|
|
|
// Callback section
|
|
|
|
SubGhzProtocolDecoderBaseRxCallback callback;
|
|
|
|
void* context;
|
|
|
|
};
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Set a callback upon completion of successful decoding of one of the protocols.
|
|
|
|
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
* @param callback Callback, SubGhzProtocolDecoderBaseRxCallback
|
|
|
|
* @param context Context
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_protocol_decoder_base_set_decoder_callback(
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
SubGhzProtocolDecoderBaseRxCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Getting a textual representation of the received data.
|
|
|
|
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
* @param output Resulting text
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
bool subghz_protocol_decoder_base_get_string(
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* output);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Serialize data SubGhzProtocolDecoderBase.
|
|
|
|
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
* @param flipper_format Pointer to a FlipperFormat instance
|
2022-10-19 15:52:21 +00:00
|
|
|
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
2022-03-16 09:18:48 +00:00
|
|
|
* @return true On success
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
bool subghz_protocol_decoder_base_serialize(
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
FlipperFormat* flipper_format,
|
2022-10-19 15:52:21 +00:00
|
|
|
SubGhzRadioPreset* preset);
|
2022-03-03 09:48:56 +00:00
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Deserialize data SubGhzProtocolDecoderBase.
|
|
|
|
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
* @param flipper_format Pointer to a FlipperFormat instance
|
|
|
|
* @return true On success
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
bool subghz_protocol_decoder_base_deserialize(
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
FlipperFormat* flipper_format);
|
|
|
|
|
2022-03-16 09:18:48 +00:00
|
|
|
/**
|
|
|
|
* Getting the hash sum of the last randomly received parcel.
|
|
|
|
* @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
|
|
|
|
* @return hash Hash sum
|
|
|
|
*/
|
2022-03-03 09:48:56 +00:00
|
|
|
uint8_t subghz_protocol_decoder_base_get_hash_data(SubGhzProtocolDecoderBase* decoder_base);
|
|
|
|
|
|
|
|
// Encoder Base
|
|
|
|
typedef struct SubGhzProtocolEncoderBase SubGhzProtocolEncoderBase;
|
|
|
|
|
|
|
|
struct SubGhzProtocolEncoderBase {
|
|
|
|
// Decoder general section
|
|
|
|
const SubGhzProtocol* protocol;
|
|
|
|
|
|
|
|
// Callback section
|
|
|
|
};
|
2022-09-14 16:11:38 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|