mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-13 19:45:12 +00:00
Fixed api key overwrite
This commit is contained in:
@@ -571,6 +571,14 @@ bool AmsConfiguration::hasConfig() {
|
||||
configVersion = 0;
|
||||
return false;
|
||||
}
|
||||
case 90:
|
||||
configVersion = -1; // Prevent loop
|
||||
if(relocateConfig90()) {
|
||||
configVersion = 91;
|
||||
} else {
|
||||
configVersion = 0;
|
||||
return false;
|
||||
}
|
||||
case EEPROM_CHECK_SUM:
|
||||
return true;
|
||||
default:
|
||||
@@ -831,6 +839,17 @@ bool AmsConfiguration::relocateConfig89() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AmsConfiguration::relocateConfig90() {
|
||||
EntsoeConfig entsoe;
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
EEPROM.get(CONFIG_ENTSOE_START_90, entsoe);
|
||||
EEPROM.put(CONFIG_ENTSOE_START, entsoe);
|
||||
EEPROM.put(EEPROM_CONFIG_ADDRESS, 91);
|
||||
bool ret = EEPROM.commit();
|
||||
EEPROM.end();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AmsConfiguration::save() {
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
EEPROM.put(EEPROM_CONFIG_ADDRESS, EEPROM_CHECK_SUM);
|
||||
@@ -1013,13 +1032,13 @@ void AmsConfiguration::print(Print* debugger)
|
||||
debugger->printf("Temp analog pin: %i\r\n", gpio.tempAnalogSensorPin);
|
||||
debugger->printf("Vcc pin: %i\r\n", gpio.vccPin);
|
||||
if(gpio.vccMultiplier > 0) {
|
||||
debugger->printf("Vcc multiplier: %f\r\n", gpio.vccMultiplier / 1000.0);
|
||||
debugger->printf("Vcc multiplier: %f\r\n", gpio.vccMultiplier / 1000.0);
|
||||
}
|
||||
if(gpio.vccOffset > 0) {
|
||||
debugger->printf("Vcc offset: %f\r\n", gpio.vccOffset / 100.0);
|
||||
debugger->printf("Vcc offset: %f\r\n", gpio.vccOffset / 100.0);
|
||||
}
|
||||
if(gpio.vccBootLimit > 0) {
|
||||
debugger->printf("Vcc boot limit: %f\r\n", gpio.vccBootLimit / 10.0);
|
||||
debugger->printf("Vcc boot limit: %f\r\n", gpio.vccBootLimit / 10.0);
|
||||
}
|
||||
debugger->printf("GND resistor: %i\r\n", gpio.vccResistorGnd);
|
||||
debugger->printf("Vcc resistor: %i\r\n", gpio.vccResistorVcc);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
#define EEPROM_SIZE 1024*3
|
||||
#define EEPROM_CHECK_SUM 90 // Used to check if config is stored. Change if structure changes
|
||||
#define EEPROM_CHECK_SUM 91 // Used to check if config is stored. Change if structure changes
|
||||
#define EEPROM_CONFIG_ADDRESS 0
|
||||
#define EEPROM_TEMP_CONFIG_ADDRESS 2048
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define CONFIG_WIFI_START 16
|
||||
#define CONFIG_METER_START 224
|
||||
#define CONFIG_GPIO_START 266
|
||||
#define CONFIG_ENTSOE_START 286
|
||||
#define CONFIG_ENTSOE_START 290
|
||||
#define CONFIG_WEB_START 648
|
||||
#define CONFIG_DEBUG_START 824
|
||||
#define CONFIG_DOMOTICZ_START 856
|
||||
@@ -23,6 +23,7 @@
|
||||
#define CONFIG_METER_START_87 784
|
||||
#define CONFIG_GPIO_START_88 832
|
||||
#define CONFIG_ENTSOE_START_89 944
|
||||
#define CONFIG_ENTSOE_START_90 286
|
||||
|
||||
|
||||
struct SystemConfig {
|
||||
@@ -325,6 +326,7 @@ private:
|
||||
bool relocateConfig87();
|
||||
bool relocateConfig88(); // dev 1.6
|
||||
bool relocateConfig89(); // dev 1.6
|
||||
bool relocateConfig90(); // 2.0.0
|
||||
|
||||
int readString(int pAddress, char* pString[]);
|
||||
int readInt(int pAddress, int *pValue);
|
||||
|
||||
@@ -8,21 +8,27 @@ void AmsData::apply(AmsData& other) {
|
||||
|
||||
if(ms > 0) {
|
||||
if(other.getActiveImportPower() > 0)
|
||||
activeImportCounter += (((float) ms) * other.getActiveImportPower()) / 3600000000;
|
||||
activeImportCounter += (((float) ms) * other.getActiveImportPower()) / 3600000000.0;
|
||||
|
||||
if(other.getListType() > 1) {
|
||||
ms = this->lastUpdateMillis > other.getLastUpdateMillis() ? 0 : other.getLastUpdateMillis() - this->lastList2;
|
||||
if(other.getActiveExportPower() > 0)
|
||||
activeExportCounter += (((float) ms*2) * other.getActiveExportPower()) / 3600000000;
|
||||
activeExportCounter += (((float) ms) * other.getActiveExportPower()) / 3600000000.0;
|
||||
if(other.getReactiveImportPower() > 0)
|
||||
reactiveImportCounter += (((float) ms*2) * other.getReactiveImportPower()) / 3600000000;
|
||||
reactiveImportCounter += (((float) ms) * other.getReactiveImportPower()) / 3600000000.0;
|
||||
if(other.getReactiveExportPower() > 0)
|
||||
reactiveExportCounter += (((float) ms*2) * other.getReactiveExportPower()) / 3600000000;
|
||||
reactiveExportCounter += (((float) ms) * other.getReactiveExportPower()) / 3600000000.0;
|
||||
}
|
||||
counterEstimated = true;
|
||||
}
|
||||
} else {
|
||||
Serial.printf("\nDeviation: %.4f\n", other.getActiveImportCounter() - activeImportCounter);
|
||||
}
|
||||
|
||||
this->lastUpdateMillis = other.getLastUpdateMillis();
|
||||
if(other.getListType() > 1) {
|
||||
this->lastList2 = this->lastUpdateMillis;
|
||||
}
|
||||
this->packageTimestamp = other.getPackageTimestamp();
|
||||
if(other.getListType() > this->listType)
|
||||
this->listType = other.getListType();
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
|
||||
protected:
|
||||
unsigned long lastUpdateMillis = 0;
|
||||
unsigned long lastList2 = 0;
|
||||
uint8_t listType = 0, meterType = AmsTypeUnknown;
|
||||
time_t packageTimestamp = 0;
|
||||
String listId, meterId, meterModel;
|
||||
|
||||
Reference in New Issue
Block a user