mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Add command `SetOption35 0..255
`
Add command ``SetOption35 0..255`` to skip number of received messages in Serial Bridge (default 0) (#17140)
This commit is contained in:
parent
7d1e5cf487
commit
4f31e7a1b2
@ -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)
|
- 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)
|
- 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 ``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
|
### Breaking Changed
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||||||
|
|
||||||
## Changelog v12.2.0.5
|
## Changelog v12.2.0.5
|
||||||
### Added
|
### 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 ``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 ``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)
|
- Command ``RgxPort [tcp|udp], gateway_port, client_mac, client_port`` for range extender port forwardings [#17092](https://github.com/arendst/Tasmota/issues/17092)
|
||||||
|
@ -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)
|
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_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_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_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_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)
|
P_IR_UNKNOW_THRESHOLD, // SetOption38 - (IR) Set the smallest sized "UNKNOWN" message packets we actually care about (default 6, max 255)
|
||||||
|
@ -323,6 +323,7 @@ struct TasmotaGlobal_t {
|
|||||||
uint8_t light_driver; // Light module configured
|
uint8_t light_driver; // Light module configured
|
||||||
uint8_t light_type; // Light types
|
uint8_t light_type; // Light types
|
||||||
uint8_t serial_in_byte; // Received byte
|
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 devices_present; // Max number of devices supported
|
||||||
uint8_t masterlog_level; // Master log level used to override set log level
|
uint8_t masterlog_level; // Master log level used to override set log level
|
||||||
uint8_t seriallog_level; // Current copy of Settings->seriallog_level
|
uint8_t seriallog_level; // Current copy of Settings->seriallog_level
|
||||||
|
@ -1609,6 +1609,7 @@ void SettingsDelta(void) {
|
|||||||
}
|
}
|
||||||
if (Settings->version < 0x0C020005) { // 12.2.0.5
|
if (Settings->version < 0x0C020005) { // 12.2.0.5
|
||||||
Settings->modbus_sbaudrate = Settings->ex_modbus_sbaudrate;
|
Settings->modbus_sbaudrate = Settings->ex_modbus_sbaudrate;
|
||||||
|
Settings->param[P_SERIAL_SKIP] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings->version = VERSION;
|
Settings->version = VERSION;
|
||||||
|
@ -27,19 +27,11 @@ struct {
|
|||||||
|
|
||||||
#ifdef USE_DISCOVERY
|
#ifdef USE_DISCOVERY
|
||||||
void StartMdns(void) {
|
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 (Settings->flag3.mdns_enabled) { // SetOption55 - Control mDNS service
|
||||||
if (!Mdns.begun) {
|
if (!Mdns.begun) {
|
||||||
// if (mdns_delayed_start) {
|
MDNS.end(); // close existing or MDNS.begin will fail
|
||||||
// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION));
|
Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname);
|
||||||
// mdns_delayed_start--;
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED));
|
||||||
// } 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));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,20 +203,13 @@ void WiFiSetSleepMode(void)
|
|||||||
WifiSetOutputPower();
|
WifiSetOutputPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WifiBegin(uint8_t flag, uint8_t channel)
|
void WifiBegin(uint8_t flag, uint8_t channel) {
|
||||||
{
|
|
||||||
#ifdef USE_EMULATION
|
#ifdef USE_EMULATION
|
||||||
UdpDisconnect();
|
UdpDisconnect();
|
||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
|
||||||
WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083)
|
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
|
#ifdef USE_WIFI_RANGE_EXTENDER
|
||||||
if (WiFi.getMode() != WIFI_AP_STA) { // Preserve range extender connections (#17103)
|
if (WiFi.getMode() != WIFI_AP_STA) { // Preserve range extender connections (#17103)
|
||||||
WiFi.disconnect(true); // Delete SDK wifi config
|
WiFi.disconnect(true); // Delete SDK wifi config
|
||||||
|
@ -95,7 +95,7 @@ void SerialBridgeInput(void) {
|
|||||||
static bool serial_bridge_overrun = false;
|
static bool serial_bridge_overrun = false;
|
||||||
|
|
||||||
if (isprint(serial_in_byte)) { // Any char between 32 and 127
|
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;
|
serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte;
|
||||||
} else {
|
} else {
|
||||||
serial_bridge_overrun = true; // Signal overrun but continue reading input to flush until '\n' (EOL)
|
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
|
((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
|
!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
|
!in_byte_is_delimiter) { // Char is not a delimiter
|
||||||
serial_bridge_buffer[serial_bridge_in_byte_counter++] = serial_in_byte;
|
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
|
in_byte_is_delimiter) { // Char is delimiter
|
||||||
serial_bridge_polling_window = 0; // Publish now
|
serial_bridge_polling_window = 0; // Publish now
|
||||||
break;
|
break;
|
||||||
@ -156,25 +156,31 @@ void SerialBridgeInput(void) {
|
|||||||
serial_bridge_buffer[serial_bridge_in_byte_counter] = 0; // Serial data completed
|
serial_bridge_buffer[serial_bridge_in_byte_counter] = 0; // Serial data completed
|
||||||
bool assume_json = (!serial_bridge_raw && (serial_bridge_buffer[0] == '{'));
|
bool assume_json = (!serial_bridge_raw && (serial_bridge_buffer[0] == '{'));
|
||||||
|
|
||||||
Response_P(PSTR("{\"" D_JSON_SSERIALRECEIVED "\":"));
|
TasmotaGlobal.serial_skip++; // SetOption35 Skip number of serial messages received (default 0)
|
||||||
if (assume_json) {
|
if (TasmotaGlobal.serial_skip >= Settings->param[P_SERIAL_SKIP]) { // Handle intermediate changes to SetOption35
|
||||||
ResponseAppend_P(serial_bridge_buffer);
|
TasmotaGlobal.serial_skip = 0;
|
||||||
} 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
|
Response_P(PSTR("{\"" D_JSON_SSERIALRECEIVED "\":"));
|
||||||
XdrvRulesProcess(0);
|
if (assume_json) {
|
||||||
} else {
|
ResponseAppend_P(serial_bridge_buffer);
|
||||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_SSERIALRECEIVED));
|
} 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;
|
serial_bridge_in_byte_counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user