Fixed save crash

This commit is contained in:
Gunnar Skjold 2021-11-16 20:40:21 +01:00
parent 4c92e592d6
commit 254e010594
2 changed files with 9 additions and 3 deletions

View File

@ -68,6 +68,7 @@ AmsMqttHandler* mqttHandler = NULL;
HanReader hanReader;
Stream *hanSerial;
SoftwareSerial *swSerial = NULL;
GpioConfig gpioConfig;
MeterConfig meterConfig;
@ -497,7 +498,12 @@ void setupHanPort(int pin, int newMeterType) {
} else {
debugD("Software serial");
Serial.flush();
SoftwareSerial *swSerial = new SoftwareSerial(pin);
if(swSerial != NULL) {
swSerial->end();
delete swSerial;
}
swSerial = new SoftwareSerial(pin);
switch(newMeterType) {
case METER_TYPE_KAMSTRUP:

View File

@ -191,7 +191,7 @@ void AmsWebServer::temperaturePost() {
delay(1);
}
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
if(config->save()) {
printD("Successfully saved temperature sensors");
server.sendHeader("Location", String("/temperature"), true);
@ -1068,7 +1068,7 @@ void AmsWebServer::handleSave() {
printI("Saving configuration now...");
if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
//if (debugger->isActive(RemoteDebug::DEBUG)) config->print(debugger);
if (config->save()) {
printI("Successfully saved.");
if(config->isWifiChanged()) {