mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-03-14 06:17:40 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d6df03c94 |
@@ -77,7 +77,7 @@ protected:
|
|||||||
unsigned long lastList2 = 0;
|
unsigned long lastList2 = 0;
|
||||||
uint8_t listType = 0, meterType = AmsTypeUnknown;
|
uint8_t listType = 0, meterType = AmsTypeUnknown;
|
||||||
time_t packageTimestamp = 0;
|
time_t packageTimestamp = 0;
|
||||||
String listId, meterId, meterModel;
|
String listId = "", meterId = "", meterModel = "";
|
||||||
time_t meterTimestamp = 0;
|
time_t meterTimestamp = 0;
|
||||||
uint16_t activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0;
|
uint16_t activeImportPower = 0, reactiveImportPower = 0, activeExportPower = 0, reactiveExportPower = 0;
|
||||||
float l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0;
|
float l1voltage = 0, l2voltage = 0, l3voltage = 0, l1current = 0, l2current = 0, l3current = 0;
|
||||||
|
|||||||
@@ -31,7 +31,9 @@
|
|||||||
<option value={13}>GPIO13</option>
|
<option value={13}>GPIO13</option>
|
||||||
<option value={14}>GPIO14</option>
|
<option value={14}>GPIO14</option>
|
||||||
<option value={15}>GPIO15</option>
|
<option value={15}>GPIO15</option>
|
||||||
|
{#if chip == 'esp32s2'}
|
||||||
|
<option value={16}>GPIO16</option>
|
||||||
|
{/if}
|
||||||
{#if chip.startsWith('esp32')}
|
{#if chip.startsWith('esp32')}
|
||||||
<option value={17}>GPIO17</option>
|
<option value={17}>GPIO17</option>
|
||||||
{#if chip != 'esp32s2'}
|
{#if chip != 'esp32s2'}
|
||||||
|
|||||||
@@ -241,10 +241,12 @@ void AmsWebServer::sysinfoJson() {
|
|||||||
config->getUiConfig(ui);
|
config->getUiConfig(ui);
|
||||||
|
|
||||||
String meterModel = meterState->getMeterModel();
|
String meterModel = meterState->getMeterModel();
|
||||||
meterModel.replace("\\", "\\\\");
|
if(!meterModel.isEmpty())
|
||||||
|
meterModel.replace("\\", "\\\\");
|
||||||
|
|
||||||
String meterId = meterState->getMeterId();
|
String meterId = meterState->getMeterId();
|
||||||
meterId.replace("\\", "\\\\");
|
if(!meterId.isEmpty())
|
||||||
|
meterId.replace("\\", "\\\\");
|
||||||
|
|
||||||
int size = snprintf_P(buf, BufferSize, SYSINFO_JSON,
|
int size = snprintf_P(buf, BufferSize, SYSINFO_JSON,
|
||||||
VERSION,
|
VERSION,
|
||||||
|
|||||||
@@ -577,13 +577,14 @@ void loop() {
|
|||||||
if(readHanPort() || now - meterState.getLastUpdateMillis() > 30000) {
|
if(readHanPort() || now - meterState.getLastUpdateMillis() > 30000) {
|
||||||
if(now - lastTemperatureRead > 15000) {
|
if(now - lastTemperatureRead > 15000) {
|
||||||
unsigned long start = millis();
|
unsigned long start = millis();
|
||||||
hw.updateTemperatures();
|
if(hw.updateTemperatures()) {
|
||||||
lastTemperatureRead = now;
|
lastTemperatureRead = now;
|
||||||
|
|
||||||
if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) {
|
if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) {
|
||||||
mqttHandler->publishTemperatures(&config, &hw);
|
mqttHandler->publishTemperatures(&config, &hw);
|
||||||
|
}
|
||||||
|
debugD("Used %ld ms to update temperature", millis()-start);
|
||||||
}
|
}
|
||||||
debugD("Used %ld ms to update temperature", millis()-start);
|
|
||||||
}
|
}
|
||||||
if(now - lastSysupdate > 60000) {
|
if(now - lastSysupdate > 60000) {
|
||||||
if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) {
|
if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) {
|
||||||
@@ -862,9 +863,9 @@ bool readHanPort() {
|
|||||||
pos = unwrapData((uint8_t *) hanBuffer, ctx);
|
pos = unwrapData((uint8_t *) hanBuffer, ctx);
|
||||||
if(ctx.type > 0 && pos >= 0) {
|
if(ctx.type > 0 && pos >= 0) {
|
||||||
if(ctx.type == DATA_TAG_DLMS) {
|
if(ctx.type == DATA_TAG_DLMS) {
|
||||||
debugV("Received valid DLMS at %d", pos);
|
debugD("Received valid DLMS at %d", pos);
|
||||||
} else if(ctx.type == DATA_TAG_DSMR) {
|
} else if(ctx.type == DATA_TAG_DSMR) {
|
||||||
debugV("Received valid DSMR at %d", pos);
|
debugD("Received valid DSMR at %d", pos);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Move this so that payload is sent to MQTT
|
// TODO: Move this so that payload is sent to MQTT
|
||||||
debugE("Unknown tag %02X at pos %d", ctx.type, pos);
|
debugE("Unknown tag %02X at pos %d", ctx.type, pos);
|
||||||
@@ -879,7 +880,7 @@ bool readHanPort() {
|
|||||||
meterState.setLastError(pos);
|
meterState.setLastError(pos);
|
||||||
debugV("Unknown data payload:");
|
debugV("Unknown data payload:");
|
||||||
len = len + hanSerial->readBytes(hanBuffer+len, BUF_SIZE_HAN-len);
|
len = len + hanSerial->readBytes(hanBuffer+len, BUF_SIZE_HAN-len);
|
||||||
debugPrint(hanBuffer, 0, len);
|
if(Debug.isActive(RemoteDebug::VERBOSE)) debugPrint(hanBuffer, 0, len);
|
||||||
len = 0;
|
len = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -962,7 +963,7 @@ bool readHanPort() {
|
|||||||
|
|
||||||
bool saveData = false;
|
bool saveData = false;
|
||||||
if(!ds.isHappy() && now > BUILD_EPOCH) {
|
if(!ds.isHappy() && now > BUILD_EPOCH) {
|
||||||
debugV("Its time to update data storage");
|
debugD("Its time to update data storage");
|
||||||
tmElements_t tm;
|
tmElements_t tm;
|
||||||
breakTime(now, tm);
|
breakTime(now, tm);
|
||||||
if(tm.Minute == 0) {
|
if(tm.Minute == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user