mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-27 10:40:45 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea91248e67 | ||
|
|
271ce2081f |
@@ -102,10 +102,17 @@ bool AmsMqttHandler::connect() {
|
|||||||
}
|
}
|
||||||
actualClient = mqttClient;
|
actualClient = mqttClient;
|
||||||
}
|
}
|
||||||
int clientTimeout = mqttConfig.timeout / 1000;
|
|
||||||
if(clientTimeout > 3) clientTimeout = 3; // 3000ms is default, see WiFiClient.cpp WIFI_CLIENT_DEF_CONN_TIMEOUT_MS
|
// This section helps with power saving on ESP32 devices by reducing timeouts
|
||||||
actualClient->setTimeout(clientTimeout);
|
// The timeout is multiplied by 10 because WiFiClient is retrying 10 times internally
|
||||||
// Why can't we set number of retries for write here? WiFiClient defaults to 10 (10*3s == 30s)
|
// Power drain for this timeout is too great when using the default 3s timeout
|
||||||
|
// On ESP8266 the timeout is used differently and the following code causes MQTT instability
|
||||||
|
#if defined(ESP32)
|
||||||
|
int clientTimeout = mqttConfig.timeout / 1000;
|
||||||
|
if(clientTimeout > 3) clientTimeout = 3; // 3000ms is default, see WiFiClient.cpp WIFI_CLIENT_DEF_CONN_TIMEOUT_MS
|
||||||
|
actualClient->setTimeout(clientTimeout);
|
||||||
|
// Why can't we set number of retries for write here? WiFiClient defaults to 10 (10*3s == 30s)
|
||||||
|
#endif
|
||||||
|
|
||||||
mqttConfigChanged = false;
|
mqttConfigChanged = false;
|
||||||
mqtt.setTimeout(mqttConfig.timeout);
|
mqtt.setTimeout(mqttConfig.timeout);
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ public:
|
|||||||
bool isConfigChanged();
|
bool isConfigChanged();
|
||||||
void ackConfigChanged();
|
void ackConfigChanged();
|
||||||
void getCurrentConfig(MeterConfig& meterConfig);
|
void getCurrentConfig(MeterConfig& meterConfig);
|
||||||
|
void setTimezone(Timezone* tz) {
|
||||||
|
this->tz = tz;
|
||||||
|
};
|
||||||
|
|
||||||
HardwareSerial* getHwSerial();
|
HardwareSerial* getHwSerial();
|
||||||
void rxerr(int err);
|
void rxerr(int err);
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ IEC6205675::IEC6205675(const char* d, Timezone* tz, uint8_t useMeterType, MeterC
|
|||||||
|
|
||||||
// Kaifa special case...
|
// Kaifa special case...
|
||||||
if(useMeterType == AmsTypeKaifa && data->base.type == CosemTypeDLongUnsigned) {
|
if(useMeterType == AmsTypeKaifa && data->base.type == CosemTypeDLongUnsigned) {
|
||||||
this->packageTimestamp = this->packageTimestamp > 0 ? tz->toUTC(this->packageTimestamp) : 0;
|
this->packageTimestamp = this->packageTimestamp > 0 && tz != NULL ? tz->toUTC(this->packageTimestamp) : 0;
|
||||||
listType = 1;
|
listType = 1;
|
||||||
meterType = AmsTypeKaifa;
|
meterType = AmsTypeKaifa;
|
||||||
activeImportPower = ntohl(data->dlu.data);
|
activeImportPower = ntohl(data->dlu.data);
|
||||||
lastUpdateMillis = millis64();
|
lastUpdateMillis = millis64();
|
||||||
} else if(data->base.type == CosemTypeOctetString) {
|
} else if(data->base.type == CosemTypeOctetString) {
|
||||||
this->packageTimestamp = this->packageTimestamp > 0 ? tz->toUTC(this->packageTimestamp) : 0;
|
this->packageTimestamp = this->packageTimestamp > 0 && tz != NULL ? tz->toUTC(this->packageTimestamp) : 0;
|
||||||
|
|
||||||
memcpy(str, data->oct.data, data->oct.length);
|
memcpy(str, data->oct.data, data->oct.length);
|
||||||
str[data->oct.length] = 0x00;
|
str[data->oct.length] = 0x00;
|
||||||
@@ -123,7 +123,7 @@ IEC6205675::IEC6205675(const char* d, Timezone* tz, uint8_t useMeterType, MeterC
|
|||||||
if(data->oct.length == 0x0C) {
|
if(data->oct.length == 0x0C) {
|
||||||
AmsOctetTimestamp* amst = (AmsOctetTimestamp*) data;
|
AmsOctetTimestamp* amst = (AmsOctetTimestamp*) data;
|
||||||
time_t ts = decodeCosemDateTime(amst->dt);
|
time_t ts = decodeCosemDateTime(amst->dt);
|
||||||
meterTimestamp = tz->toUTC(ts);
|
meterTimestamp = tz != NULL ? tz->toUTC(ts) : ts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1121,7 +1121,7 @@ time_t IEC6205675::adjustForKnownIssues(CosemDateTime dt, Timezone* tz, uint8_t
|
|||||||
// 21.09.24, the clock is now correct for Aidon
|
// 21.09.24, the clock is now correct for Aidon
|
||||||
// 23.10.25, the clock is now correct for Kamstrup
|
// 23.10.25, the clock is now correct for Kamstrup
|
||||||
ts -= 3600;
|
ts -= 3600;
|
||||||
} else {
|
} else if(tz != NULL) {
|
||||||
// Adjust from localtime to UTC
|
// Adjust from localtime to UTC
|
||||||
ts = tz->toUTC(ts);
|
ts = tz->toUTC(ts);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
"day" : "day",
|
"day" : "day",
|
||||||
"days" : "days",
|
"days" : "days",
|
||||||
"month" : "month",
|
"month" : "month",
|
||||||
"unknown" : "Unknown"
|
"unknown" : "Unknown",
|
||||||
|
"now" : "Now"
|
||||||
},
|
},
|
||||||
"btn" : {
|
"btn" : {
|
||||||
"reboot" : "Reboot",
|
"reboot" : "Reboot",
|
||||||
|
|||||||
@@ -809,6 +809,9 @@ void handleNtp() {
|
|||||||
ds.setTimezone(tz);
|
ds.setTimezone(tz);
|
||||||
ea.setTimezone(tz);
|
ea.setTimezone(tz);
|
||||||
ps->setTimezone(tz);
|
ps->setTimezone(tz);
|
||||||
|
if(passiveMc != NULL) {
|
||||||
|
passiveMc->setTimezone(tz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.ackNtpChange();
|
config.ackNtpChange();
|
||||||
|
|||||||
Reference in New Issue
Block a user