From 828a73bbd1a92a697310280b4bce729d54b39516 Mon Sep 17 00:00:00 2001 From: WillyJL Date: Tue, 26 Aug 2025 01:59:47 +0200 Subject: [PATCH 1/5] Sub-GHz: Only fix Linear inverted bits in user interface, keep old remotes compatible --- lib/subghz/protocols/linear.c | 43 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/subghz/protocols/linear.c b/lib/subghz/protocols/linear.c index 7d9f12d42..520d1d34e 100644 --- a/lib/subghz/protocols/linear.c +++ b/lib/subghz/protocols/linear.c @@ -115,33 +115,33 @@ static bool subghz_protocol_encoder_linear_get_upload(SubGhzProtocolEncoderLinea for(uint8_t i = instance->generic.data_count_bit; i > 1; i--) { if(bit_read(instance->generic.data, i - 1)) { //send bit 1 - instance->encoder.upload[index++] = - level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_short); - instance->encoder.upload[index++] = - level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_long); - } else { - //send bit 0 instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_long); instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_short); + } else { + //send bit 0 + instance->encoder.upload[index++] = + level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_short); + instance->encoder.upload[index++] = + level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_long); } } //Send end bit if(bit_read(instance->generic.data, 0)) { //send bit 1 - instance->encoder.upload[index++] = - level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_short); - //Send gap - instance->encoder.upload[index++] = - level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_short * 44); - } else { - //send bit 0 instance->encoder.upload[index++] = level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_long); //Send gap instance->encoder.upload[index++] = level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_short * 42); + } else { + //send bit 0 + instance->encoder.upload[index++] = + level_duration_make(true, (uint32_t)subghz_protocol_linear_const.te_short); + //Send gap + instance->encoder.upload[index++] = + level_duration_make(false, (uint32_t)subghz_protocol_linear_const.te_short * 44); } return true; @@ -249,11 +249,11 @@ void subghz_protocol_decoder_linear_feed(void* context, bool level, uint32_t dur } if(DURATION_DIFF(instance->decoder.te_last, subghz_protocol_linear_const.te_short) < subghz_protocol_linear_const.te_delta) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); + subghz_protocol_blocks_add_bit(&instance->decoder, 0); } else if( DURATION_DIFF(instance->decoder.te_last, subghz_protocol_linear_const.te_long) < subghz_protocol_linear_const.te_delta) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); + subghz_protocol_blocks_add_bit(&instance->decoder, 1); } if(instance->decoder.decode_count_bit == subghz_protocol_linear_const.min_count_bit_for_found) { @@ -273,14 +273,14 @@ void subghz_protocol_decoder_linear_feed(void* context, bool level, uint32_t dur subghz_protocol_linear_const.te_delta) && (DURATION_DIFF(duration, subghz_protocol_linear_const.te_long) < subghz_protocol_linear_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); + subghz_protocol_blocks_add_bit(&instance->decoder, 0); instance->decoder.parser_step = LinearDecoderStepSaveDuration; } else if( (DURATION_DIFF(instance->decoder.te_last, subghz_protocol_linear_const.te_long) < subghz_protocol_linear_const.te_delta) && (DURATION_DIFF(duration, subghz_protocol_linear_const.te_short) < subghz_protocol_linear_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); + subghz_protocol_blocks_add_bit(&instance->decoder, 1); instance->decoder.parser_step = LinearDecoderStepSaveDuration; } else { instance->decoder.parser_step = LinearDecoderStepReset; @@ -321,12 +321,15 @@ void subghz_protocol_decoder_linear_get_string(void* context, FuriString* output furi_assert(context); SubGhzProtocolDecoderLinear* instance = context; - uint32_t code_found_lo = instance->generic.data & 0x00000000ffffffff; + // Protocol is actually implemented wrong way around, bits are inverted. + // Instead of fixing it and breaking old saved remotes, + // only the display here is inverted to show correct values. + uint32_t code_found_reverse_lo = instance->generic.data & 0x00000000ffffffff; - uint64_t code_found_reverse = subghz_protocol_blocks_reverse_key( + uint64_t code_found = subghz_protocol_blocks_reverse_key( instance->generic.data, instance->generic.data_count_bit); - uint32_t code_found_reverse_lo = code_found_reverse & 0x00000000ffffffff; + uint32_t code_found_lo = code_found & 0x00000000ffffffff; furi_string_cat_printf( output, From db4a613f6cc89c800f5a1334192944a40038c03b Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 27 Aug 2025 02:59:00 +0300 Subject: [PATCH 2/5] upd changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e65eaab3e..5875b26ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Main changes - Current API: 86.0 -* SubGHz: Tune Linear (add better EZCode support), Dickert MAHS decoders +* SubGHz: Tune Linear (edited by @WillyJL in PR #919) (add better EZCode support), Dickert MAHS decoders * SubGHz: Add ZKTeco 430.5 MHz add manually support * SubGHz: Add variant of 'Add Manually' menu with manual editing for each value (PR #909 #911 #914 | by @MrLego8-9) * OFW PR 4251: CLI: Fix long delay with quick connect/disconnect (by @WillyJL) From 5f7aaf2a04722ef3f9e8078fc46ae580effea96a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 27 Aug 2025 03:09:52 +0300 Subject: [PATCH 3/5] NFC: Fix read crash with unexpectedly large MFC AUTH(0) response by WillyJL https://github.com/flipperdevices/flipperzero-firmware/pull/4265/files --- lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c index 2cf66edba..5795c1bfa 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c @@ -42,7 +42,13 @@ static Iso14443_3aError iso14443_3a_poller_standard_frame_exchange( break; } + if(bit_buffer_get_capacity_bytes(rx_buffer) < + bit_buffer_get_size_bytes(instance->rx_buffer)) { + ret = Iso14443_3aErrorBufferOverflow; + break; + } bit_buffer_copy(rx_buffer, instance->rx_buffer); + if(!iso14443_crc_check(Iso14443CrcTypeA, instance->rx_buffer)) { ret = Iso14443_3aErrorWrongCrc; break; From 8e650f06881d0566dbc4a84726dee61778be7599 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 27 Aug 2025 03:11:01 +0300 Subject: [PATCH 4/5] upd changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5875b26ce..06a3728aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * SubGHz: Tune Linear (edited by @WillyJL in PR #919) (add better EZCode support), Dickert MAHS decoders * SubGHz: Add ZKTeco 430.5 MHz add manually support * SubGHz: Add variant of 'Add Manually' menu with manual editing for each value (PR #909 #911 #914 | by @MrLego8-9) +* OFW PR 4265: NFC: Fix read crash with unexpectedly large MFC AUTH(0) response (by @WillyJL) * OFW PR 4251: CLI: Fix long delay with quick connect/disconnect (by @WillyJL) * LFRFID: Add additional procotols supported by EM4305 chipset (by @jamisonderek) * Apps: **Check out more Apps updates and fixes by following** [this link](https://github.com/xMasterX/all-the-plugins/commits/dev) From c091a58486b574b06852e09e2ce82805451e02d2 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 27 Aug 2025 03:42:01 +0300 Subject: [PATCH 5/5] fix linear again --- lib/subghz/protocols/linear.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/subghz/protocols/linear.c b/lib/subghz/protocols/linear.c index 520d1d34e..4b6114b98 100644 --- a/lib/subghz/protocols/linear.c +++ b/lib/subghz/protocols/linear.c @@ -10,10 +10,10 @@ #define DIP_PATTERN "%c%c%c%c%c%c%c%c%c%c" #define DATA_TO_DIP(dip) \ - (dip & 0x0200 ? '1' : '0'), (dip & 0x0100 ? '1' : '0'), (dip & 0x0080 ? '1' : '0'), \ - (dip & 0x0040 ? '1' : '0'), (dip & 0x0020 ? '1' : '0'), (dip & 0x0010 ? '1' : '0'), \ - (dip & 0x0008 ? '1' : '0'), (dip & 0x0004 ? '1' : '0'), (dip & 0x0002 ? '1' : '0'), \ - (dip & 0x0001 ? '1' : '0') + (dip & 0x0200 ? '0' : '1'), (dip & 0x0100 ? '0' : '1'), (dip & 0x0080 ? '0' : '1'), \ + (dip & 0x0040 ? '0' : '1'), (dip & 0x0020 ? '0' : '1'), (dip & 0x0010 ? '0' : '1'), \ + (dip & 0x0008 ? '0' : '1'), (dip & 0x0004 ? '0' : '1'), (dip & 0x0002 ? '0' : '1'), \ + (dip & 0x0001 ? '0' : '1') static const SubGhzBlockConst subghz_protocol_linear_const = { .te_short = 500, @@ -341,5 +341,5 @@ void subghz_protocol_decoder_linear_get_string(void* context, FuriString* output instance->generic.data_count_bit, code_found_lo, code_found_reverse_lo, - DATA_TO_DIP(code_found_lo)); + DATA_TO_DIP(code_found_reverse_lo)); }