Merge pull request #4062 from andrethomas/development

Add Reset 4 command to reset defaults but keep wifi config
This commit is contained in:
Theo Arends 2018-10-14 22:45:04 +02:00 committed by GitHub
commit 203053e468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -1152,6 +1152,10 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
restart_flag = 210 + payload; restart_flag = 210 + payload;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}")); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}"));
break; break;
case 4:
restart_flag = 214;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_RESET "\":\"" D_JSON_ERASE ", " D_JSON_RESET_AND_RESTARTING "\"}"));
break;
default: default:
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESET); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESET);
} }
@ -2103,6 +2107,20 @@ void Every250mSeconds()
SettingsDefault(); SettingsDefault();
restart_flag = 2; restart_flag = 2;
} }
if (214 == restart_flag) {
char tmp_sta_ssid[2][33];
char tmp_sta_pwd[2][65];
strlcpy(tmp_sta_ssid[0],Settings.sta_ssid[0],sizeof(Settings.sta_ssid[0]));
strlcpy(tmp_sta_pwd[0],Settings.sta_pwd[0],sizeof(Settings.sta_pwd[0]));
strlcpy(tmp_sta_ssid[1],Settings.sta_ssid[1],sizeof(Settings.sta_ssid[1]));
strlcpy(tmp_sta_pwd[1],Settings.sta_pwd[1],sizeof(Settings.sta_pwd[1]));
SettingsDefault();
strlcpy(Settings.sta_ssid[0],tmp_sta_ssid[0],sizeof(Settings.sta_ssid[0]));
strlcpy(Settings.sta_pwd[0],tmp_sta_pwd[0],sizeof(Settings.sta_pwd[0]));
strlcpy(Settings.sta_ssid[1],tmp_sta_ssid[1],sizeof(Settings.sta_ssid[1]));
strlcpy(Settings.sta_pwd[1],tmp_sta_pwd[1],sizeof(Settings.sta_pwd[1]));
restart_flag = 2;
}
SettingsSaveAll(); SettingsSaveAll();
restart_flag--; restart_flag--;
if (restart_flag <= 0) { if (restart_flag <= 0) {