[FL-2919] SubGhz: CAME Wrong number of bits in key (add protocol Airforce) (#1890)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm 2022-10-18 18:24:53 +04:00 committed by GitHub
parent 02c27becb0
commit 68009c6230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@
#define CAME_24_COUNT_BIT 24 #define CAME_24_COUNT_BIT 24
#define PRASTEL_COUNT_BIT 25 #define PRASTEL_COUNT_BIT 25
#define PRASTEL_NAME "Prastel" #define PRASTEL_NAME "Prastel"
#define AIRFORCE_COUNT_BIT 18
#define AIRFORCE_NAME "Airforce"
static const SubGhzBlockConst subghz_protocol_came_const = { static const SubGhzBlockConst subghz_protocol_came_const = {
.te_short = 320, .te_short = 320,
@ -86,7 +88,7 @@ void* subghz_protocol_encoder_came_alloc(SubGhzEnvironment* environment) {
instance->generic.protocol_name = instance->base.protocol->name; instance->generic.protocol_name = instance->base.protocol->name;
instance->encoder.repeat = 10; instance->encoder.repeat = 10;
instance->encoder.size_upload = 52; //max 24bit*2 + 2 (start, stop) instance->encoder.size_upload = 128;
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration)); instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
instance->encoder.is_running = false; instance->encoder.is_running = false;
return instance; return instance;
@ -151,10 +153,7 @@ bool subghz_protocol_encoder_came_deserialize(void* context, FlipperFormat* flip
FURI_LOG_E(TAG, "Deserialize error"); FURI_LOG_E(TAG, "Deserialize error");
break; break;
} }
if((instance->generic.data_count_bit != if((instance->generic.data_count_bit > PRASTEL_COUNT_BIT)) {
subghz_protocol_came_const.min_count_bit_for_found) &&
(instance->generic.data_count_bit != CAME_24_COUNT_BIT) &&
(instance->generic.data_count_bit != PRASTEL_COUNT_BIT)) {
FURI_LOG_E(TAG, "Wrong number of bits in key"); FURI_LOG_E(TAG, "Wrong number of bits in key");
break; break;
} }
@ -310,10 +309,7 @@ bool subghz_protocol_decoder_came_deserialize(void* context, FlipperFormat* flip
if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) { if(!subghz_block_generic_deserialize(&instance->generic, flipper_format)) {
break; break;
} }
if((instance->generic.data_count_bit != if((instance->generic.data_count_bit > PRASTEL_COUNT_BIT)) {
subghz_protocol_came_const.min_count_bit_for_found) &&
(instance->generic.data_count_bit != CAME_24_COUNT_BIT) &&
(instance->generic.data_count_bit != PRASTEL_COUNT_BIT)) {
FURI_LOG_E(TAG, "Wrong number of bits in key"); FURI_LOG_E(TAG, "Wrong number of bits in key");
break; break;
} }
@ -338,8 +334,11 @@ void subghz_protocol_decoder_came_get_string(void* context, FuriString* output)
"%s %dbit\r\n" "%s %dbit\r\n"
"Key:0x%08lX\r\n" "Key:0x%08lX\r\n"
"Yek:0x%08lX\r\n", "Yek:0x%08lX\r\n",
(instance->generic.data_count_bit == PRASTEL_COUNT_BIT ? PRASTEL_NAME : (instance->generic.data_count_bit == PRASTEL_COUNT_BIT ?
instance->generic.protocol_name), PRASTEL_NAME :
(instance->generic.data_count_bit == AIRFORCE_COUNT_BIT ?
AIRFORCE_NAME :
instance->generic.protocol_name)),
instance->generic.data_count_bit, instance->generic.data_count_bit,
code_found_lo, code_found_lo,
code_found_reverse_lo); code_found_reverse_lo);