From f4a205142d9d8a3ba94169d898525b305ee22bc8 Mon Sep 17 00:00:00 2001 From: Skorpionm <85568270+Skorpionm@users.noreply.github.com> Date: Thu, 5 May 2022 02:34:44 +0400 Subject: [PATCH] SubGhz: bug fixes (#1192) * Subghz: fix simultaneous detection of Princeton and GateTx * SubGhz: fix phantom frequencies in the Frequency Analyzer --- .../subghz_frequency_analyzer_worker.c | 1 + lib/subghz/protocols/firefly.c | 6 ------ lib/subghz/protocols/keeloq.c | 2 +- lib/subghz/protocols/nero_sketch.c | 6 ------ lib/subghz/protocols/nice_flo.c | 6 ------ lib/subghz/protocols/nice_flor_s.c | 1 + lib/subghz/protocols/princeton.c | 20 +++++++++++-------- lib/subghz/protocols/princeton_for_testing.c | 1 + 8 files changed, 16 insertions(+), 27 deletions(-) diff --git a/applications/subghz/helpers/subghz_frequency_analyzer_worker.c b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c index b6b3a1edc..8d8ad0b65 100644 --- a/applications/subghz/helpers/subghz_frequency_analyzer_worker.c +++ b/applications/subghz/helpers/subghz_frequency_analyzer_worker.c @@ -71,6 +71,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) { furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async); furi_hal_subghz_set_frequency(433920000); furi_hal_subghz_flush_rx(); + furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate); furi_hal_subghz_rx(); while(instance->worker_running) { diff --git a/lib/subghz/protocols/firefly.c b/lib/subghz/protocols/firefly.c index e872d5580..3a339e0a9 100644 --- a/lib/subghz/protocols/firefly.c +++ b/lib/subghz/protocols/firefly.c @@ -6,12 +6,6 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -/* - * Help - * https://phreakerclub.com/447 - * - */ - #define TAG "SubGhzProtocolFirefly" #define DIP_PATTERN "%c%c%c%c%c%c%c%c%c%c" diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 975cd29c8..9c6673e82 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -11,7 +11,7 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -#define TAG "SubGhzProtocolkeeloq" +#define TAG "SubGhzProtocolKeeloq" static const SubGhzBlockConst subghz_protocol_keeloq_const = { .te_short = 400, diff --git a/lib/subghz/protocols/nero_sketch.c b/lib/subghz/protocols/nero_sketch.c index 12a1a5476..474b742ad 100644 --- a/lib/subghz/protocols/nero_sketch.c +++ b/lib/subghz/protocols/nero_sketch.c @@ -6,12 +6,6 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -/* - * Help - * https://phreakerclub.com/447 - * - */ - #define TAG "SubGhzProtocolNeroSketch" static const SubGhzBlockConst subghz_protocol_nero_sketch_const = { diff --git a/lib/subghz/protocols/nice_flo.c b/lib/subghz/protocols/nice_flo.c index 01371b735..6f94e8fdf 100644 --- a/lib/subghz/protocols/nice_flo.c +++ b/lib/subghz/protocols/nice_flo.c @@ -5,12 +5,6 @@ #include "../blocks/generic.h" #include "../blocks/math.h" -/* - * Help - * https://phreakerclub.com/447 - * - */ - #define TAG "SubGhzProtocolNiceFLO" static const SubGhzBlockConst subghz_protocol_nice_flo_const = { diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index 8a3e26a8a..1fe5876da 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -5,6 +5,7 @@ #include "../blocks/encoder.h" #include "../blocks/generic.h" #include "../blocks/math.h" + /* * https://phreakerclub.com/1615 * https://phreakerclub.com/forum/showthread.php?t=2360 diff --git a/lib/subghz/protocols/princeton.c b/lib/subghz/protocols/princeton.c index 4fa2b4810..49d9a9cd3 100644 --- a/lib/subghz/protocols/princeton.c +++ b/lib/subghz/protocols/princeton.c @@ -12,7 +12,7 @@ * */ -#define TAG "SubGhzProtocolCAME" +#define TAG "SubGhzProtocolPrinceton" static const SubGhzBlockConst subghz_protocol_princeton_const = { .te_short = 400, @@ -28,6 +28,7 @@ struct SubGhzProtocolDecoderPrinceton { SubGhzBlockGeneric generic; uint32_t te; + uint32_t last_data; }; struct SubGhzProtocolEncoderPrinceton { @@ -241,15 +242,18 @@ void subghz_protocol_decoder_princeton_feed(void* context, bool level, uint32_t instance->decoder.parser_step = PrincetonDecoderStepSaveDuration; if(instance->decoder.decode_count_bit == subghz_protocol_princeton_const.min_count_bit_for_found) { - instance->te /= (instance->decoder.decode_count_bit * 4 + 1); + if(instance->last_data == instance->decoder.decode_data) { + instance->te /= (instance->decoder.decode_count_bit * 4 + 1); - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - instance->generic.serial = instance->decoder.decode_data >> 4; - instance->generic.btn = (uint8_t)instance->decoder.decode_data & 0x00000F; + instance->generic.data = instance->decoder.decode_data; + instance->generic.data_count_bit = instance->decoder.decode_count_bit; + instance->generic.serial = instance->decoder.decode_data >> 4; + instance->generic.btn = (uint8_t)instance->decoder.decode_data & 0x00000F; - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); + if(instance->base.callback) + instance->base.callback(&instance->base, instance->base.context); + } + instance->last_data = instance->decoder.decode_data; } instance->decoder.decode_data = 0; instance->decoder.decode_count_bit = 0; diff --git a/lib/subghz/protocols/princeton_for_testing.c b/lib/subghz/protocols/princeton_for_testing.c index 1c4552f46..bdf5f4292 100644 --- a/lib/subghz/protocols/princeton_for_testing.c +++ b/lib/subghz/protocols/princeton_for_testing.c @@ -2,6 +2,7 @@ #include "furi_hal.h" #include "../blocks/math.h" + /* * Help * https://phreakerclub.com/447