diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 0b7d00dff..dc1de954a 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -19,6 +19,7 @@ * Fix Pzem004T checksum error * Fix KNX bug when doing reply of sensors values * Fix rules induced LWT message + * Fix possible wifi connection problem (#1366) * * 5.14.0b * Add Console Commands to send KNX Commands diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index c2ade9636..fd5e91275 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1146,8 +1146,8 @@ boolean SendKey(byte key, byte device, byte state) char *tmp = (key) ? Settings.switch_topic : Settings.button_topic; Format(key_topic, tmp, sizeof(key_topic)); if (Settings.flag.mqtt_enabled && MqttIsConnected() && (strlen(key_topic) != 0) && strcmp(key_topic, "0")) { - if (!key && (device > devices_present)) device = 1; - GetTopic_P(stopic, CMND, key_topic, GetPowerDevice(scommand, device, sizeof(scommand), key)); + if (!key && (device > devices_present)) device = 1; // Only allow number of buttons up to number of devices + GetTopic_P(stopic, CMND, key_topic, GetPowerDevice(scommand, device, sizeof(scommand), key)); // cmnd/switchtopic/POWERx if (9 == state) { mqtt_data[0] = '\0'; } else { diff --git a/sonoff/support.ino b/sonoff/support.ino index 067c8c291..c052e2487 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -368,10 +368,10 @@ char* GetPowerDevice(char* dest, uint8_t idx, size_t size, uint8_t option) { char sidx[8]; - strncpy_P(dest, S_RSLT_POWER, size); + strncpy_P(dest, S_RSLT_POWER, size); // POWER if ((devices_present + option) > 1) { - snprintf_P(sidx, sizeof(sidx), PSTR("%d"), idx); - strncat(dest, sidx, size); + snprintf_P(sidx, sizeof(sidx), PSTR("%d"), idx); // x + strncat(dest, sidx, size); // POWERx } return dest; } @@ -1009,7 +1009,6 @@ void WifiBegin(uint8_t flag) WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186 #endif - WiFi.persistent(false); // Solve possible wifi init errors WiFi.disconnect(true); // Delete SDK wifi config delay(200); WiFi.mode(WIFI_STA); // Disable AP mode diff --git a/sonoff/xdrv_02_webserver.ino b/sonoff/xdrv_02_webserver.ino index 1f699cfb0..da47b2223 100644 --- a/sonoff/xdrv_02_webserver.ino +++ b/sonoff/xdrv_02_webserver.ino @@ -488,6 +488,9 @@ void ShowPage(String &page, bool auth) page += FPSTR(HTTP_END); page.replace(F("{mv"), my_version); SetHeader(); + + ShowFreeMem(PSTR("ShowPage")); + WebServer->send(200, FPSTR(HDR_CTYPE_HTML), page); } diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 28037de8b..23c693ef7 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -357,6 +357,9 @@ bool RulesProcessEvent(char *json_event) String event_saved = json_event; event_saved.toUpperCase(); +//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event %s"), event_saved.c_str()); +//AddLog(LOG_LEVEL_DEBUG); + for (byte i = 0; i < MAX_RULE_SETS; i++) { if (strlen(Settings.rules[i]) && bitRead(Settings.rule_enabled, i)) { if (RuleSetProcess(i, event_saved)) { serviced = true; }