Various changes during testing

This commit is contained in:
Gunnar Skjold 2020-03-26 20:55:23 +01:00
parent d9b45d037b
commit bf13965a9e
3 changed files with 18 additions and 14 deletions

View File

@ -280,6 +280,7 @@ bool AmsConfiguration::hasConfig() {
case 81:
return true;
default:
configVersion = 0;
return false;
}
}
@ -362,7 +363,7 @@ bool AmsConfiguration::loadConfig72(int address) {
ackWifiChange();
setDebugLevel(5); // 5=Error
setDebugLevel(3); // 3=Info
setDebugTelnet(false);
setDebugSerial(false);
@ -433,7 +434,7 @@ bool AmsConfiguration::loadConfig75(int address) {
ackWifiChange();
setDebugLevel(5); // 5=Error
setDebugLevel(3); // 3=Info
setDebugTelnet(false);
setDebugSerial(false);
@ -508,7 +509,7 @@ bool AmsConfiguration::loadConfig80(int address) {
ackWifiChange();
setDebugLevel(5); // 5=Error
setDebugLevel(3); // 3=Info
setDebugTelnet(false);
setDebugSerial(false);

View File

@ -82,7 +82,7 @@ public:
protected:
private:
int configVersion;
int configVersion = 0;
String wifiSsid;
String wifiPassword;
@ -92,26 +92,26 @@ private:
String wifiDns1;
String wifiDns2;
String wifiHostname;
bool wifiChanged;
bool wifiChanged = false;
String mqttHost;
int mqttPort;
int mqttPort = 1883;
String mqttClientId;
String mqttPublishTopic;
String mqttSubscribeTopic;
String mqttUser;
String mqttPassword;
int mqttPayloadFormat;
bool mqttChanged;
int mqttPayloadFormat = 0;
bool mqttChanged = false;
byte authSecurity;
String authUser;
String authPassword;
int meterType, distributionSystem, mainFuse, productionCapacity;
int meterType = 0, distributionSystem = 0, mainFuse = 0, productionCapacity = 0;
bool debugTelnet, debugSerial;
int debugLevel;
bool debugTelnet = false, debugSerial = false;
int debugLevel = 3;
const int EEPROM_SIZE = 512;
const int EEPROM_CHECK_SUM = 81; // Used to check if config is stored. Change if structure changes

View File

@ -60,7 +60,7 @@ void setup() {
if(config.hasConfig()) {
config.load();
}
#if DEBUG_MODE
#if HW_ROARFRED
if(config.getMeterType() == 3) {
Serial.begin(2400, SERIAL_8N1);
@ -69,6 +69,7 @@ void setup() {
}
#else
Serial.begin(115200);
#endif
#endif
if(config.hasConfig()) {
@ -91,7 +92,7 @@ void setup() {
if (Debug.isActive(RemoteDebug::INFO)) {
debugI("AMS bridge started");
debugI("Voltage: %dV", vcc);
debugI("Voltage: %.2fV", vcc);
}
if (vcc > 0 && vcc < 3.1) {
@ -171,7 +172,8 @@ void setup() {
}
}
if(config.getConfigVersion() < 81) {
if(!config.hasConfig() || config.getConfigVersion() < 81) {
debugI("Setting default hostname");
uint16_t chipId;
#if defined(ARDUINO_ARCH_ESP32)
chipId = ESP.getEfuseMac();
@ -548,6 +550,7 @@ void readHanPort() {
if(config.getMeterType() == 0 && millis() - lastSuccessfulRead > 10000) {
lastSuccessfulRead = millis();
if(Debug.isActive(RemoteDebug::DEBUG)) debugD("No data for current setting, switching parity");
Serial.flush();
#if SOFTWARE_SERIAL
if(even) {
hanSerial->begin(2400, SWSERIAL_8N1);