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