#3 - update signal for serialize/deserialize
This commit is contained in:
parent
885c465b44
commit
435aad3ecf
@ -30,7 +30,7 @@
|
|||||||
// last 8 bits are inverted from previous 8 bits.
|
// last 8 bits are inverted from previous 8 bits.
|
||||||
//
|
//
|
||||||
// Format: SSSSXBXX ssssxbxx DBOQBXXX dboqbxxx
|
// Format: SSSSXBXX ssssxbxx DBOQBXXX dboqbxxx
|
||||||
// S - The serial number (Channel) is encoded in the first four bits that were sent.
|
// S - The serial number (Channel) is encoded in the first four bits that were sent.
|
||||||
// x - Unused bits
|
// x - Unused bits
|
||||||
// B - Bit 6 is set if the button should be button 9-16, instead of buttons 1-8.
|
// B - Bit 6 is set if the button should be button 9-16, instead of buttons 1-8.
|
||||||
// DQ - The 1st bit of byte 3 is 1 if DIMMER. (bit 4=0 for BRIGHT, bit 4=1 for DIM)
|
// DQ - The 1st bit of byte 3 is 1 if DIMMER. (bit 4=0 for BRIGHT, bit 4=1 for DIM)
|
||||||
@ -119,14 +119,14 @@ void subghz_protocol_decoder_x10_reset(void* context) {
|
|||||||
|
|
||||||
bool subghz_protocol_x10_validate(void* context) {
|
bool subghz_protocol_x10_validate(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
|
||||||
SubGhzProtocolDecoderX10* instance = context;
|
SubGhzProtocolDecoderX10* instance = context;
|
||||||
SubGhzBlockDecoder* decoder = &instance->decoder;
|
SubGhzBlockDecoder* decoder = &instance->decoder;
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -255,8 +256,8 @@ void subghz_protocol_decoder_x10_get_string(void* context, FuriString* output) {
|
|||||||
|
|
||||||
uint32_t code_button = 1 + (
|
uint32_t code_button = 1 + (
|
||||||
((instance->generic.btn&0x10) >> 4) |
|
((instance->generic.btn&0x10) >> 4) |
|
||||||
((instance->generic.btn&0x8) >> 2) |
|
((instance->generic.btn&0x8) >> 2) |
|
||||||
((instance->generic.btn&0x40)>>4) |
|
((instance->generic.btn&0x40)>>4) |
|
||||||
((instance->generic.btn&4)<<1));
|
((instance->generic.btn&4)<<1));
|
||||||
|
|
||||||
char* code_action = (instance->generic.btn & 0x20) == 0x20 ? "Off" : "On";
|
char* code_action = (instance->generic.btn & 0x20) == 0x20 ? "Off" : "On";
|
||||||
|
@ -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…
Reference in New Issue
Block a user