diff --git a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c index 5f96c0c0d..5148ca20d 100644 --- a/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c +++ b/applications/main/subghz/helpers/subghz_txrx_create_protocol_key.c @@ -81,11 +81,11 @@ bool subghz_txrx_gen_data_protocol_and_te( ret = true; } } - if(ret == SubGhzProtocolStatusOk) { + if(ret) { uint32_t guard_time = 30; if(!flipper_format_update_uint32( instance->fff_data, "Guard_time", (uint32_t*)&guard_time, 1)) { - ret = SubGhzProtocolStatusErrorParserOthers; + ret = false; FURI_LOG_E(TAG, "Unable to update Guard_time"); } } diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index 966f33e70..247ac3fc6 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -14,6 +14,7 @@ #define TAG "SubGhzProtocolPrinceton" #define PRINCETON_GUARD_TIME_DEFALUT 30 //GUARD_TIME = PRINCETON_GUARD_TIME_DEFALUT * TE +// Guard Time value should be between 15 -> 72 otherwise default value will be used static const SubGhzBlockConst subghz_protocol_princeton_const = { .te_short = 390, @@ -172,6 +173,11 @@ SubGhzProtocolStatus if(!flipper_format_read_uint32( flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) { instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } else { + // Guard Time value should be between 15 -> 72 otherwise default value will be used + if((instance->guard_time < 15) || (instance->guard_time > 72)) { + instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } } flipper_format_read_uint32( @@ -268,7 +274,8 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t instance->generic.data = instance->decoder.decode_data; instance->generic.data_count_bit = instance->decoder.decode_count_bit; instance->guard_time = roundf((float)duration / instance->te); - if(instance->guard_time > 900) { + // Guard Time value should be between 15 -> 72 otherwise default value will be used + if((instance->guard_time < 15) || (instance->guard_time > 72)) { instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; } @@ -372,7 +379,13 @@ SubGhzProtocolStatus if(!flipper_format_read_uint32( flipper_format, "Guard_time", (uint32_t*)&instance->guard_time, 1)) { instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } else { + // Guard Time value should be between 15 -> 72 otherwise default value will be used + if((instance->guard_time < 15) || (instance->guard_time > 72)) { + instance->guard_time = PRINCETON_GUARD_TIME_DEFALUT; + } } + } while(false); return ret; @@ -391,7 +404,7 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out "Key:0x%08lX\r\n" "Yek:0x%08lX\r\n" "Sn:0x%05lX Btn:%01X\r\n" - "Te:%luus GdTime:%lu\r\n", + "Te:%luus GT:Te*%lu\r\n", instance->generic.protocol_name, instance->generic.data_count_bit, (uint32_t)(instance->generic.data & 0xFFFFFF),