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

View File

@@ -82,7 +82,7 @@ public:
protected: protected:
private: private:
int configVersion; int configVersion = 0;
String wifiSsid; String wifiSsid;
String wifiPassword; String wifiPassword;
@@ -92,26 +92,26 @@ private:
String wifiDns1; String wifiDns1;
String wifiDns2; String wifiDns2;
String wifiHostname; String wifiHostname;
bool wifiChanged; bool wifiChanged = false;
String mqttHost; String mqttHost;
int mqttPort; int mqttPort = 1883;
String mqttClientId; String mqttClientId;
String mqttPublishTopic; String mqttPublishTopic;
String mqttSubscribeTopic; String mqttSubscribeTopic;
String mqttUser; String mqttUser;
String mqttPassword; String mqttPassword;
int mqttPayloadFormat; int mqttPayloadFormat = 0;
bool mqttChanged; bool mqttChanged = false;
byte authSecurity; byte authSecurity;
String authUser; String authUser;
String authPassword; String authPassword;
int meterType, distributionSystem, mainFuse, productionCapacity; int meterType = 0, distributionSystem = 0, mainFuse = 0, productionCapacity = 0;
bool debugTelnet, debugSerial; bool debugTelnet = false, debugSerial = false;
int debugLevel; int debugLevel = 3;
const int EEPROM_SIZE = 512; const int EEPROM_SIZE = 512;
const int EEPROM_CHECK_SUM = 81; // Used to check if config is stored. Change if structure changes 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()) { if(config.hasConfig()) {
config.load(); config.load();
} }
#if DEBUG_MODE
#if HW_ROARFRED #if HW_ROARFRED
if(config.getMeterType() == 3) { if(config.getMeterType() == 3) {
Serial.begin(2400, SERIAL_8N1); Serial.begin(2400, SERIAL_8N1);
@@ -69,6 +69,7 @@ void setup() {
} }
#else #else
Serial.begin(115200); Serial.begin(115200);
#endif
#endif #endif
if(config.hasConfig()) { if(config.hasConfig()) {
@@ -91,7 +92,7 @@ void setup() {
if (Debug.isActive(RemoteDebug::INFO)) { if (Debug.isActive(RemoteDebug::INFO)) {
debugI("AMS bridge started"); debugI("AMS bridge started");
debugI("Voltage: %dV", vcc); debugI("Voltage: %.2fV", vcc);
} }
if (vcc > 0 && vcc < 3.1) { 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; uint16_t chipId;
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
chipId = ESP.getEfuseMac(); chipId = ESP.getEfuseMac();
@@ -548,6 +550,7 @@ void readHanPort() {
if(config.getMeterType() == 0 && millis() - lastSuccessfulRead > 10000) { if(config.getMeterType() == 0 && millis() - lastSuccessfulRead > 10000) {
lastSuccessfulRead = millis(); lastSuccessfulRead = millis();
if(Debug.isActive(RemoteDebug::DEBUG)) debugD("No data for current setting, switching parity"); if(Debug.isActive(RemoteDebug::DEBUG)) debugD("No data for current setting, switching parity");
Serial.flush();
#if SOFTWARE_SERIAL #if SOFTWARE_SERIAL
if(even) { if(even) {
hanSerial->begin(2400, SWSERIAL_8N1); hanSerial->begin(2400, SWSERIAL_8N1);