From bd87afeabfb59f129bf1833ceeaf03fe265deb63 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 15 Jun 2021 10:15:36 +0200 Subject: [PATCH] Add command ``MqttWifiTimeout 100..20000`` Add command ``MqttWifiTimeout 100..20000`` to control MQTT Wi-Fi connection timeout default set to 200 mS (#12222) --- CHANGELOG.md | 28 ++++---- MODULES.md | 128 ++++++++++++++++++------------------- RELEASENOTES.md | 3 +- tasmota/i18n.h | 1 + tasmota/my_user_config.h | 31 ++++----- tasmota/settings.h | 4 +- tasmota/settings.ino | 4 ++ tasmota/tasmota_globals.h | 3 + tasmota/tasmota_version.h | 2 +- tasmota/xdrv_02_9_mqtt.ino | 24 ++++--- 10 files changed, 123 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715d15caa..9584e513f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -## [9.4.0.5] +## [9.4.0.6] +### Added +- Command ``MqttWifiTimeout 100..20000`` to control MQTT Wi-Fi connection timeout default set to 200 mS (#12222) + +## [9.4.0.5] 20210615 ### Added - Preliminary support for Esp32C3 - RiscV based @@ -16,13 +20,13 @@ All notable changes to this project will be documented in this file. - I2C extended MPU6886 to also support MPU9250 (found in Legacy M5Stack Fire) - ESP32 increase log buffer from 4k to 6k to support longer messages - Move Settings from DRAM to heap -- WifiManager save wificonfig from settings, do it only once (#12242) +- WifiManager save Wi-Fi configuration from settings, do it only once (#12242) - Improving SI7021 reading reliability by adjusting timers (#12256) - Refactor ESP32 partition selection, now via boards (#12257) - Refactor platformio configurations by Jason2866 - Use correct template for Home Assistant light (#12317) -## [9.4.0.4] +## [9.4.0.4] 20210610 ### Added - Version bump to signal new features to Hass - Command ``Status0`` providing all status information on a single line @@ -93,7 +97,7 @@ All notable changes to this project will be documented in this file. ## [9.4.0.1] 20210423 ### Added -- Command ``Wifi 0/1`` for ESP8266 to turn wifi Off and On. When wifi is Off it is always returned On after a restart except for a wake-up from deepsleep (#11839) +- Command ``Wifi 0/1`` for ESP8266 to turn Wi-Fi Off and On. When Wi-Fi is Off it is always returned On after a restart except for a wake-up from deepsleep (#11839) ### Changed - Zigbee refactored storage for device configuration and device last known data (#11838) @@ -119,7 +123,7 @@ All notable changes to this project will be documented in this file. ### Changed - In tasmota-sensors.bin enabled support for VL53L0X and disabled TSL2561 (#11711) - Add HLW8012/BL0937 average pulse calculation by Alex Lovett (#11722) -- Redesigned initial GUI wifi configuration by Adrian Scillato (#11693) +- Redesigned initial GUI Wi-Fi configuration by Adrian Scillato (#11693) - Redesigned GUI by moving non-configuration buttons from ``Configuration`` to new submenu ``Consoles`` ### Fixed @@ -288,8 +292,8 @@ All notable changes to this project will be documented in this file. - ESP8266 until now NOT SUPPORTED linker files 2MB and up. Current settings will be overwritten once LittleFS is enabled ### Changed -- Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal (#10395) -- Command ``Sleep 0`` removes any sleep from wifi modem except when ESP32 BLE is active +- Force initial default state ``SetOption57 1`` to scan Wi-Fi network every 44 minutes for strongest signal (#10395) +- Command ``Sleep 0`` removes any sleep from Wi-Fi modem except when ESP32 BLE is active - PubSubClient MQTT_SOCKET_TIMEOUT from 15 to 4 seconds - Domoticz fixed 2 decimals resolution by user selectable ``TempRes``, ``HumRes`` and ``PressRes`` resolutions @@ -328,7 +332,7 @@ All notable changes to this project will be documented in this file. - Gpio ``Option A1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs (#10196) - Support for FTC532 8-button touch controller by Peter Franck (#10222) - Support character `#` to be replaced by `space`-character in command ``Publish`` topic (#10258) -- BSSID and Signal Strength Indicator to GUI wifi scan result (#10253) +- BSSID and Signal Strength Indicator to GUI Wi-Fi scan result (#10253) - Support for Afrikaans language translations by Christiaan Heerze - Support for IR inverted leds using ``#define IR_SEND_INVERTED true`` (#10301) - Support for disabling 38kHz IR modulation using ``#define IR_SEND_USE_MODULATION false`` (#10301) @@ -374,7 +378,7 @@ All notable changes to this project will be documented in this file. ### Changed - Core library from v2.7.4.7 to v2.7.4.9 - Shelly Dimmer fw upgrade using WebGUI Firmware Upgrade and file from folder `tools/fw_shd_stm32/` -- MQTT Wifi connection timeout from 5000 to 200 mSec (#9886) +- MQTT Wi-Fi connection timeout from 5000 to 200 mSec (#9886) - Platformio compiler option `-free -fipa-pta` enabled (#9875) - IRremoteESP8266 library from v2.7.12 to v2.7.13 - Shelly Dimmer 1 and 2 stm32 firmware from v51.4 to v51.5 @@ -678,7 +682,7 @@ All notable changes to this project will be documented in this file. ### Added - Initial support for Telegram bot (#8619) - Support for HP303B Temperature and Pressure sensor by Robert Jaakke (#8638) -- Rule trigger ``System#Init`` to allow early rule execution without wifi and mqtt initialized yet +- Rule trigger ``System#Init`` to allow early rule execution without Wi-Fi and mqtt initialized yet - Serial to TCP bridge, ``TCPStart`` and ``TCPBaudRate`` (needs #define USE_TCP_BRIDGE) ## [8.3.1.2] - 20200522 @@ -793,7 +797,7 @@ All notable changes to this project will be documented in this file. - Command ``Ping`` (#7176) - Command ``Palette`` to add the ability to specify a palette of colors (#8150) - Commands ``GlobalTemp`` and ``GlobalHum`` to init sensor data (#8152) -- Quick wifi reconnect using saved AP parameters when ``SetOption56 0`` (#3189) +- Quick Wi-Fi reconnect using saved AP parameters when ``SetOption56 0`` (#3189) - More accuracy to GPS NTP server (#8088) - Support for an iAQ sensor (#8107) - Support for Seven Segment display using HT16K33 (#8116) @@ -807,7 +811,7 @@ All notable changes to this project will be documented in this file. - IRremoteESP8266 library updated to v2.7.5 ### Fixed -- PWM flickering during wifi connection (#8046) +- PWM flickering during Wi-Fi connection (#8046) - Zigbee crash with Occupancy sensor (#8089) - Prevent multiple pings to run concurrently - Scheme 2-4 brightness when SetOption68 1 (#8058) diff --git a/MODULES.md b/MODULES.md index 721ccafbf..116c7e454 100644 --- a/MODULES.md +++ b/MODULES.md @@ -5,80 +5,80 @@ The following ESP8266 based hardware modules are supported. Module | LCode | Description -------------------|-------|----------------------- -01 Sonoff Basic | | Sonoff Basic Wifi Smart Switch -02 Sonoff RF | | Sonoff RF Wifi Smart Switch with RF (434MHz) receiver -03 Sonoff SV | | Sonoff SV Safe Voltage Wifi Smart Switch -04 Sonoff TH | | Sonoff TH10/TH16 Wifi Smart Switch with Sensor connection -05 Sonoff Dual | x | Sonoff Dual Wifi Smart Switch -06 Sonoff Pow | | Sonoff Pow Wifi Smart Switch with Energy Monitoring -07 Sonoff 4CH | | Sonoff 4CH 4-gang Wifi Smart Switch -08 Sonoff S2X | | Sonoff S20/S26 Wifi Smart Socket -09 Slampher | | Sonoff Slampher Wifi Smart Light Bulb Socket with RF (434MHz) receiver -10 Sonoff Touch | x | Sonoff Touch Wifi Light Switch -11 Sonoff LED | x | Sonoff Led Wifi Led Pack (Retired) -12 1 Channel | | 1 Channel Inching/Self Locking Wifi Switch 5V/12V -13 4 Channel | x | 4 Channel Inching/Self Locking Wifi Switch (Retired) -14 Motor C/AC | x | Motor Clockwise/Antoclockwise Wifi Switch (Retired) -15 ElectroDragon | | Electrodragon Wifi IoT Board -16 EXS Relay(s) | x | Electronic Experience Store 1 or 2-gang Wifi Module -17 WiOn | | WiOn Wifi Smart Socket +01 Sonoff Basic | | Sonoff Basic Wi-Fi Smart Switch +02 Sonoff RF | | Sonoff RF Wi-Fi Smart Switch with RF (434MHz) receiver +03 Sonoff SV | | Sonoff SV Safe Voltage Wi-Fi Smart Switch +04 Sonoff TH | | Sonoff TH10/TH16 Wi-Fi Smart Switch with Sensor connection +05 Sonoff Dual | x | Sonoff Dual Wi-Fi Smart Switch +06 Sonoff Pow | | Sonoff Pow Wi-Fi Smart Switch with Energy Monitoring +07 Sonoff 4CH | | Sonoff 4CH 4-gang Wi-Fi Smart Switch +08 Sonoff S2X | | Sonoff S20/S26 Wi-Fi Smart Socket +09 Slampher | | Sonoff Slampher Wi-Fi Smart Light Bulb Socket with RF (434MHz) receiver +10 Sonoff Touch | x | Sonoff Touch Wi-Fi Light Switch +11 Sonoff LED | x | Sonoff Led Wi-Fi Led Pack (Retired) +12 1 Channel | | 1 Channel Inching/Self Locking Wi-Fi Switch 5V/12V +13 4 Channel | x | 4 Channel Inching/Self Locking Wi-Fi Switch (Retired) +14 Motor C/AC | x | Motor Clockwise/Antoclockwise Wi-Fi Switch (Retired) +15 ElectroDragon | | Electrodragon Wi-Fi IoT Board +16 EXS Relay(s) | x | Electronic Experience Store 1 or 2-gang Wi-Fi Module +17 WiOn | | WiOn Wi-Fi Smart Socket 18 Generic | x | Any ESP8266/ESP8285 device like WeMos and NodeMCU -19 Sonoff Dev | | Sonoff Dev Wifi Development Board -20 H801 | x | H801 Wifi 5 Channel LED Controller -21 Sonoff SC | x | Sonoff SC Wifi Environmental Monitor -22 Sonoff BN-SZ | x | Sonoff BN-SZ01 Wifi Ceiling Led (Retired) -23 Sonoff 4CH Pro | x | Sonoff 4CH Pro 4-gang Wifi Smart Switch -24 Huafan SS | | HuaFan Wifi Smart Socket -25 Sonoff Bridge | x | Sonoff RF (434MHz) transceive to Wifi Bridge -26 Sonoff B1 | x | Sonoff B1 Wifi RGBWW Led Bulb +19 Sonoff Dev | | Sonoff Dev Wi-Fi Development Board +20 H801 | x | H801 Wi-Fi 5 Channel LED Controller +21 Sonoff SC | x | Sonoff SC Wi-Fi Environmental Monitor +22 Sonoff BN-SZ | x | Sonoff BN-SZ01 Wi-Fi Ceiling Led (Retired) +23 Sonoff 4CH Pro | x | Sonoff 4CH Pro 4-gang Wi-Fi Smart Switch +24 Huafan SS | | HuaFan Wi-Fi Smart Socket +25 Sonoff Bridge | x | Sonoff RF (434MHz) transceive to Wi-Fi Bridge +26 Sonoff B1 | x | Sonoff B1 Wi-Fi RGBWW Led Bulb 27 AiLight | x | Ai-Thinker RGBW Led Bulb -28 Sonoff T1 1CH | x | Sonoff T1 1-gang Wifi Light Switch -29 Sonoff T1 2CH | x | Sonoff T1 2-gang Wifi Light Switch -30 Sonoff T1 3CH | x | Sonoff T1 3-gang Wifi Light Switch -31 Supla Espablo | | 2-gang Wifi Module -32 Witty Cloud | | Witty Cloud ESP8266 Wifi Development Board -33 Yunshan Relay | | ESP8266 Wifi Network Relay Module +28 Sonoff T1 1CH | x | Sonoff T1 1-gang Wi-Fi Light Switch +29 Sonoff T1 2CH | x | Sonoff T1 2-gang Wi-Fi Light Switch +30 Sonoff T1 3CH | x | Sonoff T1 3-gang Wi-Fi Light Switch +31 Supla Espablo | | 2-gang Wi-Fi Module +32 Witty Cloud | | Witty Cloud ESP8266 Wi-Fi Development Board +33 Yunshan Relay | | ESP8266 Wi-Fi Network Relay Module 34 MagicHome | | MagicHome, Flux-light and some Arilux LC10 RGB(W) Led Controller -35 Luani HVIO | | Luani ESP8266 Wifi I/O Module -36 KMC 70011 | | KMC Wifi Smart Socket with Energy Monitoring +35 Luani HVIO | | Luani ESP8266 Wi-Fi I/O Module +36 KMC 70011 | | KMC Wi-Fi Smart Socket with Energy Monitoring 37 Arilux LC01 | | Arilux AL-LC01 RGB Led Controller 38 Arilux LC11 | | Arilux AL-LC11 RGBWW Led Controller -39 Sonoff Dual R2 | x | Sonoff Dual R2 Wifi Smart Switch +39 Sonoff Dual R2 | x | Sonoff Dual R2 Wi-Fi Smart Switch 40 Arilux LC06 | | Arilux AL-LC06 RGB(WW) Led Controller -41 Sonoff S31 | | Sonoff S31 Wifi Smart Socket with Energy Monitoring -42 Zengge WF017 | | Zengge WF017 Wifi RGB(W) Led Controller -43 Sonoff Pow R2 | | Sonoff Pow R2 Wifi Smart Switch with Energy Monitoring -44 Sonoff iFan02 | x | Sonoff iFan02 Wifi Smart Ceiling Fan with Light -45 BlitzWolf SHP | | BlitzWolf BW-SHP2, BW-SHP6, HomeCube SP1, Gosund SP111, Teckin SP22 Wifi Smart Switch with Energy Monitoring -46 Shelly 1 | | Shelly 1 Open Source Wifi Relay Module -47 Shelly 2 | | Shelly 2 Wifi 2-gang Relay Module with Energy Monitoring -48 Xiaomi Philips | x | Xiaomi Philips Wifi WW Led Bulb -49 Neo Coolcam | | Neo Coolcam Wifi Smart Socket -50 ESP Switch | | ESP Switch 4-gang Wifi Switch with Leds -51 OBI Socket | | OBI Wifi Smart Socket -52 Teckin | | Teckin SP22 Wifi Smart Switch with Energy Monitoring -53 AplicWDP303075 | | Aplic WDP 303075 CSL Wifi Smart Switch with Energy Monitoring +41 Sonoff S31 | | Sonoff S31 Wi-Fi Smart Socket with Energy Monitoring +42 Zengge WF017 | | Zengge WF017 Wi-Fi RGB(W) Led Controller +43 Sonoff Pow R2 | | Sonoff Pow R2 Wi-Fi Smart Switch with Energy Monitoring +44 Sonoff iFan02 | x | Sonoff iFan02 Wi-Fi Smart Ceiling Fan with Light +45 BlitzWolf SHP | | BlitzWolf BW-SHP2, BW-SHP6, HomeCube SP1, Gosund SP111, Teckin SP22 Wi-Fi Smart Switch with Energy Monitoring +46 Shelly 1 | | Shelly 1 Open Source Wi-Fi Relay Module +47 Shelly 2 | | Shelly 2 Wi-Fi 2-gang Relay Module with Energy Monitoring +48 Xiaomi Philips | x | Xiaomi Philips Wi-Fi WW Led Bulb +49 Neo Coolcam | | Neo Coolcam Wi-Fi Smart Socket +50 ESP Switch | | ESP Switch 4-gang Wi-Fi Switch with Leds +51 OBI Socket | | OBI Wi-Fi Smart Socket +52 Teckin | | Teckin SP22 Wi-Fi Smart Switch with Energy Monitoring +53 AplicWDP303075 | | Aplic WDP 303075 CSL Wi-Fi Smart Switch with Energy Monitoring 54 TuyaMCU | x | Devices with an MCU using Tuya communication protocol for control -55 Gosund SP1 v23 | | Gosund SP1 v2.3 Wifi Smart Switch with Energy Monitoring -56 ARMTR Dimmer | x | ARMtronix Wifi dimmer for Incandescent Lights and Led -57 SK03 Outdoor | x | SK03 Outdoor Wifi Smart Switch with Energy Monitoring -58 PS-16-DZ | x | PS-16-DZ Wifi dimmer for Incandescent Lights and Led -59 Teckin US | | Teckin SP20 and ZooZee SA102 Wifi Smart Switch with Energy Monitoring -60 Manzoku strip | | Manzoku Wifi Smart Power Strip with four Relays -61 OBI Socket 2 | | OBI 2 Wifi Smart Socket +55 Gosund SP1 v23 | | Gosund SP1 v2.3 Wi-Fi Smart Switch with Energy Monitoring +56 ARMTR Dimmer | x | ARMtronix Wi-Fi dimmer for Incandescent Lights and Led +57 SK03 Outdoor | x | SK03 Outdoor Wi-Fi Smart Switch with Energy Monitoring +58 PS-16-DZ | x | PS-16-DZ Wi-Fi dimmer for Incandescent Lights and Led +59 Teckin US | | Teckin SP20 and ZooZee SA102 Wi-Fi Smart Switch with Energy Monitoring +60 Manzoku strip | | Manzoku Wi-Fi Smart Power Strip with four Relays +61 OBI Socket 2 | | OBI 2 Wi-Fi Smart Socket 62 YTF IR Bridge | x | YTF Universal IR Bridge -63 Digoo DG-SP202 | | Digoo DG-SP202 Dual Wifi Smart Switch with Energy Monitoring -64 KA10 | | Smanergy KA10 Wifi Smart Wall Switch with Energy Monitoring -65 Luminea ZX2820 | | Luminea ZX2820 Wifi Smart Switch with Energy Monitoring -66 Mi Desk Lamp | | Mi Desk Lamp with rotary switch and Wifi -67 SP10 | | Tuya SP10 Wifi Smart Switch with Energy Monitoring -68 WAGA CHCZ02MB | | WAGA life CHCZ02MB Wifi Smart Switch with Energy Monitoring -69 SYF05 | | Sunyesmart SYF05 RGBWW Wifi Led Bulb +63 Digoo DG-SP202 | | Digoo DG-SP202 Dual Wi-Fi Smart Switch with Energy Monitoring +64 KA10 | | Smanergy KA10 Wi-Fi Smart Wall Switch with Energy Monitoring +65 Luminea ZX2820 | | Luminea ZX2820 Wi-Fi Smart Switch with Energy Monitoring +66 Mi Desk Lamp | | Mi Desk Lamp with rotary switch and Wi-Fi +67 SP10 | | Tuya SP10 Wi-Fi Smart Switch with Energy Monitoring +68 WAGA CHCZ02MB | | WAGA life CHCZ02MB Wi-Fi Smart Switch with Energy Monitoring +69 SYF05 | | Sunyesmart SYF05 RGBWW Wi-Fi Led Bulb 70 Sonoff L1 | x | Sonoff L1 light strip -71 Sonoff iFan03 | x | Sonoff iFan03 Wifi Smart Ceiling Fan with Light -72 EXS Dimmer | x | EXS Wifi Dimmer v4 +71 Sonoff iFan03 | x | Sonoff iFan03 Wi-Fi Smart Ceiling Fan with Light +72 EXS Dimmer | x | EXS Wi-Fi Dimmer v4 73 PWM Dimmer | x | Martin Jerry/acenx/Tessan/NTONPOWER SD0x PWM Dimmer Switches -74 Sonoff D1 | x | Sonoff D1 Wifi and RF Dimmer +74 Sonoff D1 | x | Sonoff D1 Wi-Fi and RF Dimmer 75 Sonoff ZbBridge | x | Sonoff Zigbee bridge ### ESP32 based diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8341b67cc..e22a4b236 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -99,6 +99,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ### Added - Command ``Status0`` providing all status information on a single line - Command ``TuyaSend5`` for hex string [#12211](https://github.com/arendst/Tasmota/issues/12211) +- Command ``MqttWifiTimeout 100..20000`` to control MQTT Wi-Fi connection timeout default set to 200 mS [#12222](https://github.com/arendst/Tasmota/issues/12222) - Commands ``Color2`` and ``Dimmer4`` to allow retaining brightness ratio between white and color channels when setting dimmer for linked lights [#12072](https://github.com/arendst/Tasmota/issues/12072) - Extend command ``Wifi`` with Wi-Fi Mode Control [#12292](https://github.com/arendst/Tasmota/issues/12292) - Defines ``USER_RULE1``, ``USER_RULE2`` and ``USER_RULE3`` to store rules at compile time @@ -137,7 +138,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - ESP32 increase log buffer from 4k to 6k to support longer messages - Move Settings from DRAM to heap - Refactor platformio configurations by Jason2866 -- WifiManager save wificonfig from settings, do it only once [#12242](https://github.com/arendst/Tasmota/issues/12242) +- WifiManager save Wi-Fi configuration from settings, do it only once [#12242](https://github.com/arendst/Tasmota/issues/12242) - Improving SI7021 reading reliability by adjusting timers [#12256](https://github.com/arendst/Tasmota/issues/12256) - Refactor ESP32 partition selection, now via boards [#12257](https://github.com/arendst/Tasmota/issues/12257) - Use correct template for Home Assistant light [#12317](https://github.com/arendst/Tasmota/issues/12317) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index f22aa1c4d..c5922dd7d 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -378,6 +378,7 @@ #define D_CMND_MQTTPASSWORD "MqttPassword" #define D_CMND_MQTTKEEPALIVE "MqttKeepAlive" #define D_CMND_MQTTTIMEOUT "MqttTimeout" +#define D_CMND_MQTTWIFITIMEOUT "MqttWifiTimeout" #define D_CMND_TLSKEY "TLSKey" #define D_CMND_FULLTOPIC "FullTopic" #define D_CMND_PREFIX "Prefix" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index c884c70ad..867e17482 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -64,23 +64,23 @@ #define SAVE_STATE true // [SetOption0] Save changed power state to Flash (false = disable, true = enable) #define BOOT_LOOP_OFFSET 1 // [SetOption36] Number of boot loops before starting restoring defaults (0 = disable, 1..200 = boot loops offset) -// -- Wifi ---------------------------------------- +// -- Wi-Fi --------------------------------------- #define WIFI_IP_ADDRESS "0.0.0.0" // [IpAddress1] Set to 0.0.0.0 for using DHCP or enter a static IP address #define WIFI_GATEWAY "192.168.1.1" // [IpAddress2] If not using DHCP set Gateway IP address #define WIFI_SUBNETMASK "255.255.255.0" // [IpAddress3] If not using DHCP set Network mask #define WIFI_DNS "192.168.1.1" // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY) -#define STA_SSID1 "" // [Ssid1] Wifi SSID -#define STA_PASS1 "" // [Password1] Wifi password -#define STA_SSID2 "" // [Ssid2] Optional alternate AP Wifi SSID -#define STA_PASS2 "" // [Password2] Optional alternate AP Wifi password +#define STA_SSID1 "" // [Ssid1] Wi-Fi SSID +#define STA_PASS1 "" // [Password1] Wi-Fi password +#define STA_SSID2 "" // [Ssid2] Optional alternate AP Wi-Fi SSID +#define STA_PASS2 "" // [Password2] Optional alternate AP Wi-Fi password #define WIFI_AP_PASSPHRASE "" // AccessPoint passphrase. For WPA2 min 8 char, for open use "" (max 63 char). -#define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if wifi fails to connect (default option: 4 - WIFI_RETRY) +#define WIFI_CONFIG_TOOL WIFI_RETRY // [WifiConfig] Default tool if Wi-Fi fails to connect (default option: 4 - WIFI_RETRY) // (WIFI_RESTART, WIFI_MANAGER, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY) // The configuration can be changed after first setup using WifiConfig 0, 2, 4, 5, 6 and 7. #define WIFI_ARP_INTERVAL 0 // [SetOption41] Send gratuitous ARP interval -#define WIFI_SCAN_AT_RESTART false // [SetOption56] Scan wifi network at restart for configured AP's -#define WIFI_SCAN_REGULARLY true // [SetOption57] Scan wifi network every 44 minutes for configured AP's +#define WIFI_SCAN_AT_RESTART false // [SetOption56] Scan Wi-Fi network at restart for configured AP's +#define WIFI_SCAN_REGULARLY true // [SetOption57] Scan Wi-Fi network every 44 minutes for configured AP's // -- Syslog -------------------------------------- #define SYS_LOG_HOST "" // [LogHost] (Linux) syslog host @@ -101,8 +101,9 @@ // -- MQTT ---------------------------------------- #define MQTT_USE true // [SetOption3] Select default MQTT use (false = Off, true = On) -#define MQTT_KEEPALIVE 30 // [MqttKeepAlive] -#define MQTT_SOCKET_TIMEOUT 4 // [MqttTimeout] +#define MQTT_KEEPALIVE 30 // [MqttKeepAlive] Number of seconds between KeepAlive messages +#define MQTT_SOCKET_TIMEOUT 4 // [MqttTimeout] Number of seconds before Mqtt connection timeout +#define MQTT_WIFI_CLIENT_TIMEOUT 200 // [MqttWifiTimeout] Number of milliseconds before Mqtt Wi-Fi timeout #define MQTT_HOST "" // [MqttHost] #define MQTT_FINGERPRINT1 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // [MqttFingerprint1] (auto-learn) @@ -379,7 +380,7 @@ //#define MY_LANGUAGE zh_TW // Chinese (Traditional) in Taiwan // -- Wifi Config tools --------------------------- -#define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 13 as used by Wifi Manager web GUI +#define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 13 as used by Wi-Fi Manager web GUI // -- OTA ----------------------------------------- //#define USE_ARDUINO_OTA // Add optional support for Arduino OTA (+13k code) @@ -438,11 +439,11 @@ #define USE_KNX_WEB_MENU // Enable KNX WEB MENU (+8.3k code, +144 mem) // -- HTTP ---------------------------------------- -#define USE_WEBSERVER // Enable web server and Wifi Manager (+66k code, +8k mem) +#define USE_WEBSERVER // Enable web server and Wi-Fi Manager (+66k code, +8k mem) #define WEB_PORT 80 // Web server Port for User and Admin mode #define WEB_USERNAME "admin" // Web server Admin mode user name // #define USE_JAVASCRIPT_ES6 // Enable ECMAScript6 syntax using less JavaScript code bytes (fails on IE11) - #define USE_ENHANCED_GUI_WIFI_SCAN // Enable wifi scan output with BSSID (+0k5 code) + #define USE_ENHANCED_GUI_WIFI_SCAN // Enable Wi-Fi scan output with BSSID (+0k5 code) // #define USE_WEBSEND_RESPONSE // Enable command WebSend response message (+1k code) #define USE_EMULATION_HUE // Enable Hue Bridge emulation for Alexa (+14k code, +2k mem common) #define USE_EMULATION_WEMO // Enable Belkin WeMo emulation for Alexa (+6k code, +2k mem common) @@ -496,7 +497,7 @@ #define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code, 252 iram (non 2.3.0)) #define USE_SHUTTER // Add Shutter support for up to 4 shutter with different motortypes (+11k code) #define USE_DEEPSLEEP // Add support for deepsleep (+1k code) -#define USE_EXS_DIMMER // Add support for ES-Store WiFi Dimmer (+1k5 code) +#define USE_EXS_DIMMER // Add support for ES-Store Wi-Fi Dimmer (+1k5 code) // #define EXS_MCU_CMNDS // Add command to send MCU commands (+0k8 code) //#define USE_HOTPLUG // Add support for sensor HotPlug #define USE_DEVICE_GROUPS // Add support for device groups (+5k5 code) @@ -583,7 +584,7 @@ // #define USE_CCS811_V2 // [I2cDriver24] Enable CCS811 sensor (I2C addresses 0x5A and 0x5B) (+2k8 code) // #define USE_MPU6050 // [I2cDriver25] Enable MPU6050 sensor (I2C address 0x68 AD0 low or 0x69 AD0 high) (+3K3 of code and 188 Bytes of RAM) // #define USE_MPU6050_DMP // Enable in MPU6050 to use the DMP on the chip, should create better results (+8k6 of code) -// #define USE_DS3231 // [I2cDriver26] Enable DS3231 external RTC in case no Wifi is avaliable. See docs in the source file (+1k2 code) +// #define USE_DS3231 // [I2cDriver26] Enable DS3231 external RTC in case no Wi-Fi is avaliable. See docs in the source file (+1k2 code) // #define USE_RTC_ADDR 0x68 // Default I2C address 0x68 // #define USE_MGC3130 // [I2cDriver27] Enable MGC3130 Electric Field Effect Sensor (I2C address 0x42) (+2k7 code, 0k3 mem) // #define USE_MAX44009 // [I2cDriver28] Enable MAX44009 Ambient Light sensor (I2C addresses 0x4A and 0x4B) (+0k8 code) diff --git a/tasmota/settings.h b/tasmota/settings.h index 89f01e80e..075759b71 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -588,9 +588,7 @@ typedef struct { uint16_t mqtt_keepalive; // 52C uint16_t mqtt_socket_timeout; // 52E - - uint8_t free_530[1]; // 530 - + uint8_t mqtt_wifi_timeout; // 530 uint8_t ina219_mode; // 531 uint16_t pulse_timer[MAX_PULSETIMERS]; // 532 uint16_t button_debounce; // 542 diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 37ead7630..5569f2deb 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -932,6 +932,7 @@ void SettingsDefaultSet2(void) { Settings->mqttlog_level = MQTT_LOG_LEVEL; Settings->mqtt_keepalive = MQTT_KEEPALIVE; Settings->mqtt_socket_timeout = MQTT_SOCKET_TIMEOUT; + Settings->mqtt_wifi_timeout = MQTT_WIFI_CLIENT_TIMEOUT / 100; // Energy flag.no_power_on_check |= ENERGY_VOLTAGE_ALWAYS; @@ -1356,6 +1357,9 @@ void SettingsDelta(void) { if (Settings->version < 0x09040002) { Settings->sbflag1.data = 0; } + if (Settings->version < 0x09040006) { + Settings->mqtt_wifi_timeout = MQTT_WIFI_CLIENT_TIMEOUT / 100; + } Settings->version = VERSION; SettingsSave(1); diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index f3b58d864..abb925aee 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -273,6 +273,9 @@ String EthernetMacAddress(void); #ifndef MQTT_SOCKET_TIMEOUT #define MQTT_SOCKET_TIMEOUT 4 // Seconds #endif +#ifndef MQTT_WIFI_CLIENT_TIMEOUT +#define MQTT_WIFI_CLIENT_TIMEOUT 200 // Wifi TCP connection timeout (default is 5000 mSec) +#endif #ifndef MQTT_CLEAN_SESSION #define MQTT_CLEAN_SESSION 1 // 0 = No clean session, 1 = Clean session (default) #endif diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index 71a84887f..7e17c5b76 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x09040005; +const uint32_t VERSION = 0x09040006; #endif // _TASMOTA_VERSION_H_ diff --git a/tasmota/xdrv_02_9_mqtt.ino b/tasmota/xdrv_02_9_mqtt.ino index d5ac70fc8..30789fa2f 100644 --- a/tasmota/xdrv_02_9_mqtt.ino +++ b/tasmota/xdrv_02_9_mqtt.ino @@ -19,10 +19,6 @@ #define XDRV_02 2 -#ifndef MQTT_WIFI_CLIENT_TIMEOUT -#define MQTT_WIFI_CLIENT_TIMEOUT 200 // Wifi TCP connection timeout (default is 5000 mSec) -#endif - #define USE_MQTT_NEW_PUBSUBCLIENT // #define DEBUG_DUMP_TLS // allow dumping of TLS Flash keys @@ -59,7 +55,7 @@ const char kMqttCommands[] PROGMEM = "|" // No prefix #if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT) D_CMND_MQTTFINGERPRINT "|" #endif - D_CMND_MQTTUSER "|" D_CMND_MQTTPASSWORD "|" D_CMND_MQTTKEEPALIVE "|" D_CMND_MQTTTIMEOUT "|" + D_CMND_MQTTUSER "|" D_CMND_MQTTPASSWORD "|" D_CMND_MQTTKEEPALIVE "|" D_CMND_MQTTTIMEOUT "|" D_CMND_MQTTWIFITIMEOUT "|" #if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT) D_CMND_TLSKEY "|" #endif @@ -88,7 +84,7 @@ void (* const MqttCommand[])(void) PROGMEM = { #if defined(USE_MQTT_TLS) && !defined(USE_MQTT_TLS_CA_CERT) &CmndMqttFingerprint, #endif - &CmndMqttUser, &CmndMqttPassword, &CmndMqttKeepAlive, &CmndMqttTimeout, + &CmndMqttUser, &CmndMqttPassword, &CmndMqttKeepAlive, &CmndMqttTimeout, &CmndMqttWifiTimeout, #if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT) &CmndTlsKey, #endif @@ -994,16 +990,16 @@ void MqttReconnect(void) { Response_P(S_LWT_OFFLINE); if (MqttClient.connected()) { MqttClient.disconnect(); } - EspClient.setTimeout(MQTT_WIFI_CLIENT_TIMEOUT); + EspClient.setTimeout(Settings->mqtt_wifi_timeout * 100); #ifdef USE_MQTT_TLS if (Mqtt.mqtt_tls) { tlsClient->stop(); } else { -// EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) +// EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) MqttClient.setClient(EspClient); } #else -// EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) +// EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) MqttClient.setClient(EspClient); #endif @@ -1215,6 +1211,7 @@ void CmndMqttKeepAlive(void) { } void CmndMqttTimeout(void) { + // Set timeout between 1 and 100 seconds if ((XdrvMailbox.payload >= 1) && (XdrvMailbox.payload <= 100)) { Settings->mqtt_socket_timeout = XdrvMailbox.payload; #ifdef USE_MQTT_NEW_PUBSUBCLIENT @@ -1224,6 +1221,15 @@ void CmndMqttTimeout(void) { ResponseCmndNumber(Settings->mqtt_socket_timeout); } +void CmndMqttWifiTimeout(void) { + // Set timeout between 100 and 20000 mSec + if ((XdrvMailbox.payload >= 100) && (XdrvMailbox.payload <= 20000)) { + Settings->mqtt_wifi_timeout = XdrvMailbox.payload / 100; + EspClient.setTimeout(Settings->mqtt_wifi_timeout * 100); + } + ResponseCmndNumber(Settings->mqtt_wifi_timeout * 100); +} + void CmndMqttlog(void) { if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { Settings->mqttlog_level = XdrvMailbox.payload;