From 2393d6770935626c0295cf769a9d58d94d4806fb Mon Sep 17 00:00:00 2001
From: mrWheel <5585427+mrWheel@users.noreply.github.com>
Date: Fri, 17 Apr 2020 11:55:22 +0200
Subject: [PATCH] v2.0.1 First Final Release
---
DSMRloggerAPI.h | 2 +-
DSMRloggerAPI.ino | 2 +-
Debug.h | 2 +-
FSexplorer.ino | 4 +--
MQTTstuff.ino | 2 +-
MinderGas.ino | 2 +-
README.md | 10 ++++++--
SPIFFSstuff.ino | 2 +-
convertPRD2RING.ino | 2 +-
data/DSMRindex.js | 5 ++--
data/DSMRversion.dat | 2 +-
edge/DSMRgraphics.js | 2 +-
edge/DSMRindex.css | 2 +-
handleSlimmeMeter.ino | 2 +-
helperStuff.ino | 2 +-
jsonStuff.ino | 57 ++++++++++++++++++++++++++++++++++++++++++-
menuStuff.ino | 2 +-
networkStuff.h | 2 +-
ntpStuff.ino | 2 +-
oledStuff.h | 2 +-
processTelegram.ino | 39 ++++++++++++++++++++++-------
restAPI.ino | 57 +++++++++++++++++++++++++++++++++++++++++--
settingsStuff.ino | 2 +-
timeStuff.ino | 2 +-
24 files changed, 172 insertions(+), 36 deletions(-)
diff --git a/DSMRloggerAPI.h b/DSMRloggerAPI.h
index a39e29c..8007493 100644
--- a/DSMRloggerAPI.h
+++ b/DSMRloggerAPI.h
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : DSMRloggerAPI.h - definitions for DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/DSMRloggerAPI.ino b/DSMRloggerAPI.ino
index a7d119d..c5db0ad 100644
--- a/DSMRloggerAPI.ino
+++ b/DSMRloggerAPI.ino
@@ -2,7 +2,7 @@
***************************************************************************
** Program : DSMRloggerAPI (restAPI)
*/
-#define _FW_VERSION "v1.2.4 (16-04-2020)"
+#define _FW_VERSION "v2.0.1 (17-04-2020)"
/*
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/Debug.h b/Debug.h
index 4425a32..e6132bb 100644
--- a/Debug.h
+++ b/Debug.h
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : Debug.h, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
** Met dank aan Erik
diff --git a/FSexplorer.ino b/FSexplorer.ino
index 47ec2a7..4d616d0 100644
--- a/FSexplorer.ino
+++ b/FSexplorer.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : FSexplorer, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Mostly stolen from https://www.arduinoforum.de/User-Fips
** For more information visit: https://fipsok.de
@@ -240,7 +240,7 @@ void updateFirmware()
DebugTln(F("Redirect to updateIndex .."));
doRedirect("wait ... ", 1, "/updateIndex", false);
#else
- doRedirect("UpdateServer not implemented", 10, "/", false);
+ doRedirect("UpdateServer not available", 10, "/", false);
#endif
} // updateFirmware()
diff --git a/MQTTstuff.ino b/MQTTstuff.ino
index 6fe2be3..5ee0135 100644
--- a/MQTTstuff.ino
+++ b/MQTTstuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : MQTTstuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/MinderGas.ino b/MinderGas.ino
index e9df982..33f383d 100644
--- a/MinderGas.ino
+++ b/MinderGas.ino
@@ -1,7 +1,7 @@
/*
**************************************************************************
** Program : MinderGas.ino
-** Version : v1.2.2
+** Version : v2.0.1
**
** Copyright (c) 2020 Robert van den Breemen
**
diff --git a/README.md b/README.md
index 80185f5..81979f7 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,14 @@ Documentation can be found [here](https://mrwheel-docs.gitbook.io/dsmrloggerapi/
Versie | Opmerking |
- 1.2.4 |
- Bug Fixes
+ | 2.0.1 |
+ First Final Release
+ Implementing DSMRloggerWS actual api (for bacwards compatibility)
+ More robust way to write hourly data to the RING-files
+ Bugfix PRE40 gasmeter reading
+ Remove validity check on meterstanden editor
+ Better FieldName transaltion
+ Bugfix mindergas processing
|
1.2.1 |
diff --git a/SPIFFSstuff.ino b/SPIFFSstuff.ino
index 6342c81..9b31508 100644
--- a/SPIFFSstuff.ino
+++ b/SPIFFSstuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : SPIFFSstuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/convertPRD2RING.ino b/convertPRD2RING.ino
index 83fa903..192fb40 100644
--- a/convertPRD2RING.ino
+++ b/convertPRD2RING.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : convertPRD2RING, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/data/DSMRindex.js b/data/DSMRindex.js
index 9567bec..81bc825 100644
--- a/data/DSMRindex.js
+++ b/data/DSMRindex.js
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : DSMRindex.js, part of DSMRfirmwareAPI
-** Version : v1.2.2
+** Version : v1.3.1
**
** Copyright (c) 2020 Willem Aandewiel
**
@@ -94,8 +94,8 @@
timeTimer = setInterval(refreshDevTime, 10 * 1000); // repeat every 10s
openPage("mainPage");
- openTab("ActualTab");
initActualGraph();
+ openTab("ActualTab");
setPresentationType('TAB');
readGitHubVersion();
@@ -1106,6 +1106,7 @@ http://DSMR-API.local/api/v1/dev/settings", false);
addAPIdoc("v1/sm/info", "Smart Meter info in JSON format", true);
addAPIdoc("v1/sm/actual", "Smart Meter Actual data in JSON format", true);
+ addAPIdoc("v0/sm/actual", "Smart Meter Actual data in JSON format (backwards compatibility)", true);
addAPIdoc("v1/sm/fields", "Smart Meter all fields data in JSON format\
JSON format: {\"fields\":[{\"name\":\"<fieldName>\",\"value\":<value>,\"unit\":\"<unit>\"}]} ", true);
addAPIdoc("v1/sm/fields/{fieldName}", "Smart Meter one field data in JSON format", false);
diff --git a/data/DSMRversion.dat b/data/DSMRversion.dat
index 566784d..0124570 100644
--- a/data/DSMRversion.dat
+++ b/data/DSMRversion.dat
@@ -1 +1 @@
-v1.2.1 - Third Official Release
+v2.0.1 - First Final Release
diff --git a/edge/DSMRgraphics.js b/edge/DSMRgraphics.js
index 1f68931..1b3bf5a 100644
--- a/edge/DSMRgraphics.js
+++ b/edge/DSMRgraphics.js
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : DSMRgraphics.js, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v0.3.5
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/edge/DSMRindex.css b/edge/DSMRindex.css
index 0b9c433..79e2708 100644
--- a/edge/DSMRindex.css
+++ b/edge/DSMRindex.css
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : DSMRindex.css, part of DSMRfirmwareAPI
-** Version : v1.1.0
+** Version : v1.2.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/handleSlimmeMeter.ino b/handleSlimmeMeter.ino
index 619759b..62983c7 100644
--- a/handleSlimmeMeter.ino
+++ b/handleSlimmeMeter.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : handleSlimmeMeter - part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/helperStuff.ino b/helperStuff.ino
index 0de28a4..c62ddac 100644
--- a/helperStuff.ino
+++ b/helperStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : helperStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/jsonStuff.ino b/jsonStuff.ino
index 0ec2e68..98325a3 100644
--- a/jsonStuff.ino
+++ b/jsonStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : jsonStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
@@ -218,6 +218,61 @@ void sendNestedJsonObj(const char *cName, float fValue)
} // sendNestedJsonObj(*char, float)
+//=======================================================================
+//----- v0 api ----------------------------------------------------------
+//=======================================================================
+void sendNestedJsonV0Obj(const char *cName, uint32_t uValue)
+{
+ char jsonBuff[200] = "";
+
+ snprintf(jsonBuff, sizeof(jsonBuff), "%s \"%s\": %u"
+ , objSprtr, cName, uValue);
+
+ httpServer.sendContent(jsonBuff);
+ sprintf(objSprtr, ",\r\n");
+
+} // sendNestedJsonV0Obj(*char, uint)
+
+//---------------------------------------------------------------
+void sendNestedJsonV0Obj(const char *cName, float fValue)
+{
+ char jsonBuff[200] = "";
+
+ snprintf(jsonBuff, sizeof(jsonBuff), "%s \"%s\": %.3f"
+ , objSprtr, cName, fValue);
+
+ httpServer.sendContent(jsonBuff);
+ sprintf(objSprtr, ",\r\n");
+
+} // sendNestedJsonV0Obj(*char, float)
+
+//---------------------------------------------------------------
+void sendNestedJsonV0Obj(const char *cName, int32_t iValue)
+{
+ char jsonBuff[200] = "";
+
+ snprintf(jsonBuff, sizeof(jsonBuff), "%s \"%s\": %u"
+ , objSprtr, cName, iValue);
+
+ httpServer.sendContent(jsonBuff);
+ sprintf(objSprtr, ",\r\n");
+
+} // sendNestedV0Obj(*char, int)
+
+//---------------------------------------------------------------
+void sendNestedJsonV0Obj(const char *cName, String sValue)
+{
+ char jsonBuff[200] = "";
+
+ snprintf(jsonBuff, sizeof(jsonBuff), "%s \"%s\": \"%s\""
+ , objSprtr, cName
+ , sValue.substring(0,(150 - (strlen(cName)))).c_str());
+
+ httpServer.sendContent(jsonBuff);
+ sprintf(objSprtr, ",\r\n");
+
+} // sendNestedJsonV0Obj(*char, String)
+
//=======================================================================
// ************ function to build Json Settings string ******************
diff --git a/menuStuff.ino b/menuStuff.ino
index 7f73c67..a35be05 100644
--- a/menuStuff.ino
+++ b/menuStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : menuStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/networkStuff.h b/networkStuff.h
index 3bf5b78..de8323e 100644
--- a/networkStuff.h
+++ b/networkStuff.h
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : networkStuff.h, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/ntpStuff.ino b/ntpStuff.ino
index c731ae4..203954c 100644
--- a/ntpStuff.ino
+++ b/ntpStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : ntpStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/oledStuff.h b/oledStuff.h
index 8e133be..630db14 100644
--- a/oledStuff.h
+++ b/oledStuff.h
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : oledStuff.h, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/processTelegram.ino b/processTelegram.ino
index a55f76d..5459e04 100644
--- a/processTelegram.ino
+++ b/processTelegram.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : processTelegram, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
@@ -28,26 +28,28 @@ void processTelegram()
}
strcpy(newTimestamp, DSMRdata.timestamp.c_str());
-
- newT = epoch(newTimestamp, strlen(newTimestamp), false); // do NOT update system time
+ //--- newTimestamp is the timestamp from the last telegram
+ newT = epoch(newTimestamp, strlen(newTimestamp), true); // update system time
+ //--- actTimestamp is the timestamp from the previous telegram
actT = epoch(actTimestamp, strlen(actTimestamp), false);
- // Skip first 3 telegrams .. just to settle down a bit ;-)
-
+ //--- Skip first 3 telegrams .. just to settle down a bit ;-)
if ((int32_t)(telegramCount - telegramErrors) < 3)
{
strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp);
- actT = epoch(actTimestamp, strlen(actTimestamp), true); // update system time
+ actT = epoch(actTimestamp, strlen(actTimestamp), false); // update system time
return;
}
DebugTf("actHour[%02d] -- newHour[%02d]\r\n", hour(actT), hour(newT));
+ //--- if we have a new hour() update the previous hour
if (hour(actT) != hour(newT)) {
writeToSysLog("actHour[%02d] -- newHour[%02d]", hour(actT), hour(newT));
}
- // has the hour changed (or the day or month)
- // in production testing on hour only would
- // suffice, but in testing I need all three
+ //--- has the hour changed (or the day or month)
+ //--- in production testing on hour only would
+ //--- suffice, but in testing I need all three
+ //--- if we have a new hour() update the previous hour(actT)
if ( (hour(actT) != hour(newT) )
|| (day(actT) != day(newT) )
|| (month(actT) != month(newT) ) )
@@ -55,6 +57,25 @@ void processTelegram()
writeToSysLog("Update RING-files");
writeDataToFiles();
writeLastStatus();
+ //--- now see if the day() has changed also
+ if ( day(actT) != day(newT) )
+ {
+ //--- YES! actTimestamp := newTimestamp
+ //--- and update the files with the actTimestamp
+ strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp);
+ writeDataToFiles();
+ }
+ else //--- NO, only the hour has changed
+ {
+ char record[DATA_RECLEN + 1] = "";
+ //--- actTimestamp := newTimestamp
+ strCopy(actTimestamp, sizeof(actTimestamp), newTimestamp);
+ buildDataRecordFromSM(record);
+ uint16_t recSlot = timestampToHourSlot(actTimestamp, strlen(actTimestamp));
+ //--- and update the files with the actTimestamp
+ writeDataToFile(HOURS_FILE, record, recSlot, HOURS);
+ DebugTf(">%s\r\n", record); // record ends in a \n
+ }
}
if ( DUE(publishMQTTtimer) )
diff --git a/restAPI.ino b/restAPI.ino
index c982bdc..82bb826 100644
--- a/restAPI.ino
+++ b/restAPI.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : restAPI, part of DSMRloggerAPI
-** Version : v1.2.4
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
@@ -85,6 +85,14 @@ void processAPI()
return;
}
+ if (words[2] == "v0" && words[3] == "sm" && words[4] == "actual")
+ {
+ //--- depreciated api. left here for backward compatibility
+ onlyIfPresent = true;
+ copyToFieldsArray(actualArray, actualElements);
+ sendJsonV0Fields();
+ return;
+ }
if (words[2] != "v1")
{
sendApiNotFound(URI);
@@ -504,9 +512,53 @@ void sendDeviceDebug(const char *URI, String tail)
} // sendDeviceDebug()
+//=======================================================================
+struct buildJsonApiV0SmActual
+{
+ bool skip = false;
+
+ template
+ void apply(Item &i) {
+ skip = false;
+ String Name = Item::name;
+ //-- for dsmr30 -----------------------------------------------
+#if defined( USE_PRE40_PROTOCOL )
+ if (Name.indexOf("gas_delivered2") == 0) Name = "gas_delivered";
+#endif
+ if (!isInFieldsArray(Name.c_str(), fieldsElements))
+ {
+ skip = true;
+ }
+ if (!skip)
+ {
+ if (i.present())
+ {
+ //String Unit = Item::unit();
+ sendNestedJsonV0Obj(Name.c_str(), typecastValue(i.val()));
+ }
+ }
+ }
+
+}; // buildJsonApiV0SmActual()
+
//=======================================================================
-struct buildJsonApi {
+void sendJsonV0Fields()
+{
+ objSprtr[0] = '\0';
+
+ httpServer.sendHeader("Access-Control-Allow-Origin", "*");
+ httpServer.setContentLength(CONTENT_LENGTH_UNKNOWN);
+ httpServer.send(200, "application/json", "{\r\n");
+ DSMRdata.applyEach(buildJsonApiV0SmActual());
+ httpServer.sendContent("\r\n}\r\n");
+
+} // sendJsonV0Fields()
+
+
+//=======================================================================
+struct buildJsonApi
+{
bool skip = false;
template
@@ -545,6 +597,7 @@ struct buildJsonApi {
}; // buildJsonApi()
+
//=======================================================================
void sendJsonFields(const char *Name)
{
diff --git a/settingsStuff.ino b/settingsStuff.ino
index 012a0f2..a7a831f 100644
--- a/settingsStuff.ino
+++ b/settingsStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : settingsStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**
diff --git a/timeStuff.ino b/timeStuff.ino
index 10c0527..f93f76c 100644
--- a/timeStuff.ino
+++ b/timeStuff.ino
@@ -1,7 +1,7 @@
/*
***************************************************************************
** Program : timeStuff, part of DSMRloggerAPI
-** Version : v1.2.1
+** Version : v2.0.1
**
** Copyright (c) 2020 Willem Aandewiel
**