[FL-2230] SubGhz: protocol API refactoring (#969)
* SubGhz: protocols library refactoring * SubGhz: new architecture and refactoring * SubGhz: simplify protocol structure, remove unused types * SubGhz: rename Subghz to SubGhz * SubGhz: add environment concept Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com> Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
64
lib/subghz/protocols/base.c
Normal file
64
lib/subghz/protocols/base.c
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "base.h"
|
||||
#include "registry.h"
|
||||
|
||||
void subghz_protocol_decoder_base_set_decoder_callback(
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
SubGhzProtocolDecoderBaseRxCallback callback,
|
||||
void* context) {
|
||||
decoder_base->callback = callback;
|
||||
decoder_base->context = context;
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_base_get_string(
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
string_t output) {
|
||||
bool status = false;
|
||||
|
||||
if(decoder_base->protocol && decoder_base->protocol->decoder &&
|
||||
decoder_base->protocol->decoder->get_string) {
|
||||
decoder_base->protocol->decoder->get_string(decoder_base, output);
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_base_serialize(
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
FlipperFormat* flipper_format,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset) {
|
||||
bool status = false;
|
||||
|
||||
if(decoder_base->protocol && decoder_base->protocol->decoder &&
|
||||
decoder_base->protocol->decoder->serialize) {
|
||||
status = decoder_base->protocol->decoder->serialize(
|
||||
decoder_base, flipper_format, frequency, preset);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_base_deserialize(
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
FlipperFormat* flipper_format) {
|
||||
bool status = false;
|
||||
|
||||
if(decoder_base->protocol && decoder_base->protocol->decoder &&
|
||||
decoder_base->protocol->decoder->deserialize) {
|
||||
status = decoder_base->protocol->decoder->deserialize(decoder_base, flipper_format);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t subghz_protocol_decoder_base_get_hash_data(SubGhzProtocolDecoderBase* decoder_base) {
|
||||
uint8_t hash = 0;
|
||||
|
||||
if(decoder_base->protocol && decoder_base->protocol->decoder &&
|
||||
decoder_base->protocol->decoder->get_hash_data) {
|
||||
hash = decoder_base->protocol->decoder->get_hash_data(decoder_base);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
Reference in New Issue
Block a user