From 2d6ced95214298abea3492ecaf91874477a5f47a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 10 Mar 2020 16:11:34 +0100 Subject: [PATCH 1/2] Try to fix intermittent watchdog reset Try to fix intermittent watchdog reset on GUI emulation change (#7886) --- tasmota/support_udp.ino | 2 +- tasmota/xdrv_01_webserver.ino | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/support_udp.ino b/tasmota/support_udp.ino index 9ff745364..d638c162a 100644 --- a/tasmota/support_udp.ino +++ b/tasmota/support_udp.ino @@ -58,7 +58,7 @@ bool UdpDisconnect(void) bool UdpConnect(void) { - if (!udp_connected) { + if (!udp_connected && !restart_flag) { // Simple Service Discovery Protocol (SSDP) if (PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), 1900)) { AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 2dff240ad..1c5201cb9 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -1935,6 +1935,7 @@ void OtherSaveSettings(void) SettingsUpdateText(SET_WEBPWD, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? SettingsText(SET_WEBPWD) : tmp); Settings.flag.mqtt_enabled = WebServer->hasArg("b1"); // SetOption3 - Enable MQTT #ifdef USE_EMULATION + UdpDisconnect(); #if defined(USE_EMULATION_WEMO) || defined(USE_EMULATION_HUE) WebGetArg("b2", tmp, sizeof(tmp)); Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp); From eaf0e352a9d6e897236d362b3c5b3fc47b11ef69 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 10 Mar 2020 16:54:06 +0100 Subject: [PATCH 2/2] Fix DS18x20 driver (#7879) Fix DS18x20 driver (#7879) --- tasmota/xsns_05_ds18x20.ino | 75 +++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/tasmota/xsns_05_ds18x20.ino b/tasmota/xsns_05_ds18x20.ino index 5ecf39122..046fb11c4 100644 --- a/tasmota/xsns_05_ds18x20.ino +++ b/tasmota/xsns_05_ds18x20.ino @@ -89,6 +89,10 @@ uint8_t OneWireReset(void) digitalWrite(ds18x20_pin, LOW); delayMicroseconds(480); pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor + delayMicroseconds(70); + uint8_t r = !digitalRead(ds18x20_pin); + delayMicroseconds(410); + return r; } else { digitalWrite(ds18x20_pin_out, HIGH); do { @@ -100,11 +104,11 @@ uint8_t OneWireReset(void) digitalWrite(ds18x20_pin_out, LOW); delayMicroseconds(480); digitalWrite(ds18x20_pin_out, HIGH); + delayMicroseconds(70); + uint8_t r = !digitalRead(ds18x20_pin); + delayMicroseconds(410); + return r; } - delayMicroseconds(70); - uint8_t r = !digitalRead(ds18x20_pin); - delayMicroseconds(410); - return r; } void OneWireWriteBit(uint8_t v) @@ -126,26 +130,27 @@ void OneWireWriteBit(uint8_t v) delayMicroseconds(delay_high[v]); } -uint8_t OneWireReadBit(void) +uint8_t OneWire1ReadBit(void) { - if (!ds18x20_dual_mode) { - pinMode(ds18x20_pin, OUTPUT); - digitalWrite(ds18x20_pin, LOW); - delayMicroseconds(3); - pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor - delayMicroseconds(10); - uint8_t r = digitalRead(ds18x20_pin); - delayMicroseconds(53); - return r; - } else { - digitalWrite(ds18x20_pin_out, LOW); - delayMicroseconds(3); - digitalWrite(ds18x20_pin_out, HIGH); - delayMicroseconds(10); - uint8_t r = digitalRead(ds18x20_pin); - delayMicroseconds(53); - return r; - } + pinMode(ds18x20_pin, OUTPUT); + digitalWrite(ds18x20_pin, LOW); + delayMicroseconds(3); + pinMode(ds18x20_pin, Settings.flag3.ds18x20_internal_pullup ? INPUT_PULLUP : INPUT); // SetOption74 - Enable internal pullup for single DS18x20 sensor + delayMicroseconds(10); + uint8_t r = digitalRead(ds18x20_pin); + delayMicroseconds(53); + return r; +} + +uint8_t OneWire2ReadBit(void) +{ + digitalWrite(ds18x20_pin_out, LOW); + delayMicroseconds(3); + digitalWrite(ds18x20_pin_out, HIGH); + delayMicroseconds(10); + uint8_t r = digitalRead(ds18x20_pin); + delayMicroseconds(53); + return r; } /*------------------------------------------------------------------------------------------*/ @@ -161,9 +166,17 @@ uint8_t OneWireRead(void) { uint8_t r = 0; - for (uint8_t bit_mask = 0x01; bit_mask; bit_mask <<= 1) { - if (OneWireReadBit()) { - r |= bit_mask; + if (!ds18x20_dual_mode) { + for (uint8_t bit_mask = 0x01; bit_mask; bit_mask <<= 1) { + if (OneWire1ReadBit()) { + r |= bit_mask; + } + } + } else { + for (uint8_t bit_mask = 0x01; bit_mask; bit_mask <<= 1) { + if (OneWire2ReadBit()) { + r |= bit_mask; + } } } return r; @@ -207,9 +220,13 @@ uint8_t OneWireSearch(uint8_t *newAddr) } OneWireWrite(W1_SEARCH_ROM); do { - id_bit = OneWireReadBit(); - cmp_id_bit = OneWireReadBit(); - + if (!ds18x20_dual_mode) { + id_bit = OneWire1ReadBit(); + cmp_id_bit = OneWire1ReadBit(); + } else { + id_bit = OneWire2ReadBit(); + cmp_id_bit = OneWire2ReadBit(); + } if ((id_bit == 1) && (cmp_id_bit == 1)) { break; } else {