Fix possible wifi connection problem

Fix possible wifi connection problem (#1366)
This commit is contained in:
Theo Arends 2018-06-28 12:25:50 +02:00
parent 12b3acd60d
commit 20a53950ff
5 changed files with 12 additions and 6 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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);
}

View File

@ -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; }