From 07f107981d282baa084c28626966b1515e1fb21d Mon Sep 17 00:00:00 2001 From: BBBits Date: Mon, 7 Dec 2020 18:18:29 +1300 Subject: [PATCH] IR rx Igore min bits if unknown 1st draft Code should be in IRrecv.cpp --- tasmota/settings.h | 6 +++--- tasmota/xdrv_05_irremote.ino | 12 +++++++++--- tasmota/xdrv_05_irremote_full.ino | 8 ++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index 02dd5cba3..8f8d6e9d4 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -142,9 +142,9 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t mqtt_switches : 1; // bit 0 (v9.0.0.3) - SetOption114 - (Switch) Detach Switches from relays and enable MQTT action state for all the SwitchModes (1) uint32_t mi32_enable : 1; // bit 1 (v9.1.0.1) - SetOption115 - (ESP32 BLE) Enable ESP32 MI32 BLE (1) uint32_t zb_disable_autoquery : 1; // bit 2 (v9.1.0.1) - SetOption116 - (Zigbee) Disable auto-query of zigbee lights and devices (1) - uint32_t spare03 : 1; // bit 3 - uint32_t spare04 : 1; // bit 4 - uint32_t spare05 : 1; // bit 5 + uint32_t ir_rx_min_unknown_bits_8 : 1; // bit 3 SetOption117 + uint32_t ir_rx_min_unknown_bits_16 : 1;// bit 4 SetOption118 + uint32_t ir_rx_min_unknown_bits_32 : 1;// bit 5 SetOption119 uint32_t spare06 : 1; // bit 6 uint32_t spare07 : 1; // bit 7 uint32_t spare08 : 1; // bit 8 diff --git a/tasmota/xdrv_05_irremote.ino b/tasmota/xdrv_05_irremote.ino index cd401d7c0..6c7e934b5 100644 --- a/tasmota/xdrv_05_irremote.ino +++ b/tasmota/xdrv_05_irremote.ino @@ -19,7 +19,7 @@ /* Below is the Pyhton3 code to decompress IR comact format. - +Resolve this {"Protocol":"UNKNOWN","Bits":4,"Hash":"0xC1E490FF"}} ====================================================================== import re @@ -170,7 +170,14 @@ void IrReceiveCheck(void) iridx = results.decode_type; if ((iridx < 0) || (iridx > MAX_STANDARD_IR)) { iridx = 0; } // UNKNOWN - + uint8_t min_bits = 0; + if(Settings.flag5.ir_rx_min_unknown_bits_8) { min_bits += 8; } + if(Settings.flag5.ir_rx_min_unknown_bits_16) { min_bits += 16; } + if(Settings.flag5.ir_rx_min_unknown_bits_32) { min_bits += 32; } + if (results.bits < min_bits){ + irrecv->resume(); + return; + } if (iridx) { if (results.bits > 64) { // This emulates IRutils resultToHexidecimal and may needs a larger IR_RCV_BUFFER_SIZE @@ -247,7 +254,6 @@ void IrReceiveCheck(void) } #endif // USE_DOMOTICZ } - irrecv->resume(); } } diff --git a/tasmota/xdrv_05_irremote_full.ino b/tasmota/xdrv_05_irremote_full.ino index ce75d09db..bf1d8c790 100644 --- a/tasmota/xdrv_05_irremote_full.ino +++ b/tasmota/xdrv_05_irremote_full.ino @@ -287,6 +287,14 @@ void IrReceiveCheck(void) decode_results results; if (irrecv->decode(&results)) { + uint8_t min_bits = 0; + if(Settings.flag5.ir_rx_min_unknown_bits_8) { min_bits += 8; } + if(Settings.flag5.ir_rx_min_unknown_bits_16) { min_bits += 16; } + if(Settings.flag5.ir_rx_min_unknown_bits_32) { min_bits += 32; } + if (results.bits < min_bits){ + irrecv->resume(); + return; + } uint32_t now = millis(); // if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) {