diff --git a/CHANGELOG.md b/CHANGELOG.md index 742e3e45d..8e221c91b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - ESP32 DS18x20 parasitic power usage when defining W1_PARASITE_POWER (#17112) - Optional define ``SERIAL_BRIDGE_BUFFER_SIZE`` to set Serial Bridge internal buffer size (Default ESP8266 = 256, ESP32 = 800) - Command ``SSerialBuffer 256..SERIAL_BRIDGE_BUFFER_SIZE`` to change serial bridge rx buffer size (#17120) +- Command ``SetOption35 0..255`` to skip number of received messages in Serial Bridge (default 0) (#17140) ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 230f65435..acf2fb682 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -109,6 +109,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ## Changelog v12.2.0.5 ### Added +- Command ``SetOption35 0..255`` to skip number of received messages in Serial Bridge (default 0) [#17140](https://github.com/arendst/Tasmota/issues/17140) - Command ``SetOption47 1..255`` to delay power on relay state in seconds reducing power surge. ``SO47 1`` delays until network connected. ``SO47 2`` delays until mqtt connected - Command ``RgxClients`` for range extender clients list [#17048](https://github.com/arendst/Tasmota/issues/17048) - Command ``RgxPort [tcp|udp], gateway_port, client_mac, client_port`` for range extender port forwardings [#17092](https://github.com/arendst/Tasmota/issues/17092) diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index d00ee6295..911df0171 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -359,7 +359,7 @@ enum Shortcuts { SC_CLEAR, SC_DEFAULT, SC_USER }; enum SO32_49Index { P_HOLD_TIME, // SetOption32 - (Button/Switch) Key hold time detection in decaseconds (default 40) P_MAX_POWER_RETRY, // SetOption33 - (Energy) Maximum number of retries before deciding power limit overflow (default 5) P_BACKLOG_DELAY, // SetOption34 - (Backlog) Minimal delay in milliseconds between executing backlog commands (default 200) - P_MDNS_DELAYED_START, // SetOption35 - (mDNS) Number of seconds before mDNS is started (default 0) - Obsolete + P_SERIAL_SKIP, // SetOption35 - (SerialBridge) Skip number of serial messages received (default 0) P_BOOT_LOOP_OFFSET, // SetOption36 - (Restart) Number of restarts to start detecting boot loop (default 1) P_RGB_REMAP, // SetOption37 - (Light) RGB and White channel separation (default 0) P_IR_UNKNOW_THRESHOLD, // SetOption38 - (IR) Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index a9c6f6ba9..137bd80c2 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -323,6 +323,7 @@ struct TasmotaGlobal_t { uint8_t light_driver; // Light module configured uint8_t light_type; // Light types uint8_t serial_in_byte; // Received byte + uint8_t serial_skip; // Skip number of received messages uint8_t devices_present; // Max number of devices supported uint8_t masterlog_level; // Master log level used to override set log level uint8_t seriallog_level; // Current copy of Settings->seriallog_level diff --git a/tasmota/tasmota_support/settings.ino b/tasmota/tasmota_support/settings.ino index d3c4fd907..4837cbdaa 100644 --- a/tasmota/tasmota_support/settings.ino +++ b/tasmota/tasmota_support/settings.ino @@ -1609,6 +1609,7 @@ void SettingsDelta(void) { } if (Settings->version < 0x0C020005) { // 12.2.0.5 Settings->modbus_sbaudrate = Settings->ex_modbus_sbaudrate; + Settings->param[P_SERIAL_SKIP] = 0; } Settings->version = VERSION; diff --git a/tasmota/tasmota_support/support_network.ino b/tasmota/tasmota_support/support_network.ino index a6975c750..f03edbd75 100644 --- a/tasmota/tasmota_support/support_network.ino +++ b/tasmota/tasmota_support/support_network.ino @@ -27,19 +27,11 @@ struct { #ifdef USE_DISCOVERY void StartMdns(void) { -// static uint8_t mdns_delayed_start = Settings->param[P_MDNS_DELAYED_START]; - if (Settings->flag3.mdns_enabled) { // SetOption55 - Control mDNS service if (!Mdns.begun) { -// if (mdns_delayed_start) { -// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION)); -// mdns_delayed_start--; -// } else { -// mdns_delayed_start = Settings->param[P_MDNS_DELAYED_START]; - MDNS.end(); // close existing or MDNS.begin will fail - Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname); - AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED)); -// } + MDNS.end(); // close existing or MDNS.begin will fail + Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED)); } } } diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 692822384..c7218a505 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -203,20 +203,13 @@ void WiFiSetSleepMode(void) WifiSetOutputPower(); } -void WifiBegin(uint8_t flag, uint8_t channel) -{ +void WifiBegin(uint8_t flag, uint8_t channel) { #ifdef USE_EMULATION UdpDisconnect(); #endif // USE_EMULATION WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083) -/* - // Replaced by below code (20221117) - WiFi.disconnect(true); // Delete SDK wifi config - delay(200); - WifiSetMode(WIFI_STA); // Disable AP mode -*/ #ifdef USE_WIFI_RANGE_EXTENDER if (WiFi.getMode() != WIFI_AP_STA) { // Preserve range extender connections (#17103) WiFi.disconnect(true); // Delete SDK wifi config diff --git a/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino b/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino index 92bbeceb5..fda65d687 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino @@ -95,7 +95,7 @@ void SerialBridgeInput(void) { static bool serial_bridge_overrun = false; if (isprint(serial_in_byte)) { // Any char between 32 and 127 - if (serial_bridge_in_byte_counter < SERIAL_BRIDGE_BUFSIZE -1) { // Add char to string if it still fits + if (serial_bridge_in_byte_counter < SERIAL_BRIDGE_BUFSIZE -1) { // Add char to string if it still fits serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte; } else { serial_bridge_overrun = true; // Signal overrun but continue reading input to flush until '\n' (EOL) @@ -129,12 +129,12 @@ void SerialBridgeInput(void) { ((Settings->serial_delimiter == 128) && !isprint(serial_in_byte))) && // Any char not between 32 and 127 !serial_bridge_raw; // In raw mode (CMND_SERIALSEND3) there is never a delimiter - if ((serial_bridge_in_byte_counter < SERIAL_BRIDGE_BUFSIZE -1) && // Add char to string if it still fits and ... + if ((serial_bridge_in_byte_counter < SERIAL_BRIDGE_BUFSIZE -1) && // Add char to string if it still fits and ... !in_byte_is_delimiter) { // Char is not a delimiter serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte; } - if ((serial_bridge_in_byte_counter >= SERIAL_BRIDGE_BUFSIZE -1) || // Send message when buffer is full or ... + if ((serial_bridge_in_byte_counter >= SERIAL_BRIDGE_BUFSIZE -1) || // Send message when buffer is full or ... in_byte_is_delimiter) { // Char is delimiter serial_bridge_polling_window = 0; // Publish now break; @@ -156,25 +156,31 @@ void SerialBridgeInput(void) { serial_bridge_buffer[serial_bridge_in_byte_counter] = 0; // Serial data completed bool assume_json = (!serial_bridge_raw && (serial_bridge_buffer[0] == '{')); - Response_P(PSTR("{\"" D_JSON_SSERIALRECEIVED "\":")); - if (assume_json) { - ResponseAppend_P(serial_bridge_buffer); - } else { - ResponseAppend_P(PSTR("\"")); - if (serial_bridge_raw) { - ResponseAppend_P(PSTR("%*_H"), serial_bridge_in_byte_counter, serial_bridge_buffer); - } else { - ResponseAppend_P(EscapeJSONString(serial_bridge_buffer).c_str()); - } - ResponseAppend_P(PSTR("\"")); - } - ResponseJsonEnd(); + TasmotaGlobal.serial_skip++; // SetOption35 Skip number of serial messages received (default 0) + if (TasmotaGlobal.serial_skip >= Settings->param[P_SERIAL_SKIP]) { // Handle intermediate changes to SetOption35 + TasmotaGlobal.serial_skip = 0; - if (Settings->flag6.mqtt_disable_sserialrec ) { // SetOption147 If it is activated, Tasmota will not publish SSerialReceived MQTT messages, but it will proccess event trigger rules - XdrvRulesProcess(0); - } else { - MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED)); + Response_P(PSTR("{\"" D_JSON_SSERIALRECEIVED "\":")); + if (assume_json) { + ResponseAppend_P(serial_bridge_buffer); + } else { + ResponseAppend_P(PSTR("\"")); + if (serial_bridge_raw) { + ResponseAppend_P(PSTR("%*_H"), serial_bridge_in_byte_counter, serial_bridge_buffer); + } else { + ResponseAppend_P(EscapeJSONString(serial_bridge_buffer).c_str()); + } + ResponseAppend_P(PSTR("\"")); + } + ResponseJsonEnd(); + + if (Settings->flag6.mqtt_disable_sserialrec ) { // SetOption147 If it is activated, Tasmota will not publish SSerialReceived MQTT messages, but it will proccess event trigger rules + XdrvRulesProcess(0); + } else { + MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED)); + } } + serial_bridge_in_byte_counter = 0; } }