#3 - update signal for serialize/deserialize
This commit is contained in:
parent
885c465b44
commit
435aad3ecf
@ -125,8 +125,8 @@ bool subghz_protocol_x10_validate(void* context) {
|
||||
uint64_t data = decoder->decode_data;
|
||||
|
||||
return decoder->decode_count_bit >= subghz_protocol_x10_const.min_count_bit_for_found &&
|
||||
((((data >> 24) ^ (data >> 16)) & 0xFF) == 0xFF) &&
|
||||
((((data >> 8) ^ (data )) & 0xFF) == 0xFF);
|
||||
((((data >> 24) ^ (data >> 16)) & 0xFF) == 0xFF) &&
|
||||
((((data >> 8) ^ (data )) & 0xFF) == 0xFF);
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_x10_feed(void* context, bool level, uint32_t duration) {
|
||||
@ -152,27 +152,27 @@ void subghz_protocol_decoder_x10_feed(void* context, bool level, uint32_t durati
|
||||
break;
|
||||
case X10DecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_x10_const.te_short) <
|
||||
subghz_protocol_x10_const.te_delta) {
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_x10_const.min_count_bit_for_found) {
|
||||
instance->decoder.parser_step = X10DecoderStepReset;
|
||||
if (subghz_protocol_x10_validate(context)) {
|
||||
FURI_LOG_E(TAG, "Decoded a signal!");
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
|
||||
if(DURATION_DIFF(duration, subghz_protocol_x10_const.te_short) <
|
||||
subghz_protocol_x10_const.te_delta) {
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_x10_const.min_count_bit_for_found) {
|
||||
instance->decoder.parser_step = X10DecoderStepReset;
|
||||
if (subghz_protocol_x10_validate(context)) {
|
||||
FURI_LOG_E(TAG, "Decoded a signal!");
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit = instance->decoder.decode_count_bit;
|
||||
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
}
|
||||
subghz_protocol_decoder_x10_reset(context);
|
||||
} else {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = X10DecoderStepCheckDuration;
|
||||
}
|
||||
} else {
|
||||
subghz_protocol_decoder_x10_reset(context);
|
||||
}
|
||||
if(instance->base.callback)
|
||||
instance->base.callback(&instance->base, instance->base.context);
|
||||
}
|
||||
subghz_protocol_decoder_x10_reset(context);
|
||||
} else {
|
||||
instance->decoder.te_last = duration;
|
||||
instance->decoder.parser_step = X10DecoderStepCheckDuration;
|
||||
}
|
||||
} else {
|
||||
subghz_protocol_decoder_x10_reset(context);
|
||||
}
|
||||
} else {
|
||||
subghz_protocol_decoder_x10_reset(context);
|
||||
}
|
||||
@ -218,7 +218,7 @@ uint8_t subghz_protocol_decoder_x10_get_hash_data(void* context) {
|
||||
&instance->decoder, (instance->decoder.decode_count_bit / 8) + 1);
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_x10_serialize(
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_x10_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset) {
|
||||
@ -227,7 +227,8 @@ bool subghz_protocol_decoder_x10_serialize(
|
||||
return subghz_block_generic_serialize(&instance->generic, flipper_format, preset);
|
||||
}
|
||||
|
||||
bool subghz_protocol_decoder_x10_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_x10_deserialize(void* context, FlipperFormat* flipper_format) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderX10* instance = context;
|
||||
bool ret = false;
|
||||
@ -236,7 +237,7 @@ bool subghz_protocol_decoder_x10_deserialize(void* context, FlipperFormat* flipp
|
||||
break;
|
||||
}
|
||||
if(instance->generic.data_count_bit !=
|
||||
subghz_protocol_x10_const.min_count_bit_for_found) {
|
||||
subghz_protocol_x10_const.min_count_bit_for_found) {
|
||||
FURI_LOG_E(TAG, "Wrong number of bits in key");
|
||||
break;
|
||||
}
|
||||
|
@ -59,9 +59,9 @@ uint8_t subghz_protocol_decoder_x10_get_hash_data(void* context);
|
||||
* @param context Pointer to a SubGhzProtocolDecoderX10 instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param preset The modulation on which the signal was received, SubGhzRadioPreset
|
||||
* @return true On success
|
||||
* @return SubGhzProtocolStatus
|
||||
*/
|
||||
bool subghz_protocol_decoder_x10_serialize(
|
||||
SubGhzProtocolStatus subghz_protocol_decoder_x10_serialize(
|
||||
void* context,
|
||||
FlipperFormat* flipper_format,
|
||||
SubGhzRadioPreset* preset);
|
||||
@ -70,9 +70,10 @@ bool subghz_protocol_decoder_x10_serialize(
|
||||
* Deserialize data SubGhzProtocolDecoderX10.
|
||||
* @param context Pointer to a SubGhzProtocolDecoderX10 instance
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @return true On success
|
||||
* @return SubGhzProtocolStatus
|
||||
*/
|
||||
bool subghz_protocol_decoder_x10_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
SubGhzProtocolStatus
|
||||
subghz_protocol_decoder_x10_deserialize(void* context, FlipperFormat* flipper_format);
|
||||
|
||||
/**
|
||||
* Getting a textual representation of the received data.
|
||||
|
Loading…
Reference in New Issue
Block a user