diff --git a/html/about.htm b/html/about.htm index ed11c18..6b5137c 100644 --- a/html/about.htm +++ b/html/about.htm @@ -25,9 +25,6 @@ - diff --git a/html/about.min.htm b/html/about.min.htm index d590edd..36cdb1a 100644 --- a/html/about.min.htm +++ b/html/about.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Beer Gravity Monitor

This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Beer Gravity Monitor

This is a piece of software for the iSpindle hardware and will work in a similar way. No part of this software is copied from the iSpindle project.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/calibration.htm b/html/calibration.htm index a4ee866..807a7ea 100644 --- a/html/calibration.htm +++ b/html/calibration.htm @@ -26,9 +26,6 @@ - diff --git a/html/calibration.min.htm b/html/calibration.min.htm index 2ef9c23..c478364 100644 --- a/html/calibration.min.htm +++ b/html/calibration.min.htm @@ -1,4 +1,4 @@ -Beer Gravity Monitor

Here you can create your gravity formula by entering angles/tilt and the corresponding gravity. These values will be saved for future use. Angles with 0 (zero) will be skipped. The values below will be used to check the formula and if the deviation is more than 1.5SG / 0.38P on any of the provided points then the forumla will be rejected. On the bottom of the page you can see a graph over the entered values + values calcualated by the formula.



Here you can create your gravity formula by entering angles/tilt and the corresponding gravity. These values will be saved for future use. Angles with 0 (zero) will be skipped. The values below will be used to check the formula and if the deviation is more than 1.5SG / 0.38P on any of the provided points then the forumla will be rejected. On the bottom of the page you can see a graph over the entered values + values calcualated by the formula.



Temperature Format:





Gravity Format:


(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Temperature Format:





Gravity Format:


(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/device.htm b/html/device.htm deleted file mode 100644 index 46d84eb..0000000 --- a/html/device.htm +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - Beer Gravity Monitor - - - - - - - - - - - - - -
- -
- - - - - -
-
Current version:
-
Loading...
-
- -
-
Host name:
-
Loading...
-
-
-
Device ID:
-
Loading...
-
-
-
Platform:
-
Loading...
-
-
-
Average runtime:
-
Loading...
-
- -
- -
- - - -
-
-
-
-
- -
- -
- - - - - -
(C) Copyright 2021-22 Magnus Persson
- - \ No newline at end of file diff --git a/html/device.min.htm b/html/device.min.htm deleted file mode 100644 index 66a338c..0000000 --- a/html/device.min.htm +++ /dev/null @@ -1 +0,0 @@ -Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...
Platform:
Loading...
Average runtime:
Loading...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/index.htm b/html/index.htm index 70274f5..13a66a7 100644 --- a/html/index.htm +++ b/html/index.htm @@ -25,9 +25,6 @@ - @@ -72,7 +69,54 @@ }); - +
+
Current version:
+
Loading...
+
+ +
+
Host name:
+
Loading...
+
+
+
Device ID:
+
Loading...
+
+
+
Platform:
+
Loading...
+
+ + + +
+ +
+ +
+
+
+
+
+ +
Gravity:
@@ -91,6 +135,11 @@
Loading...
+
+
Average runtime:
+
Loading...
+
+
@@ -99,6 +148,7 @@

+

Gravity:
Loading...
Temperature:
Loading...
Angle/Tilt:
Loading...
Battery:
Loading...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Current version:
Loading...
Host name:
Loading...
Device ID:
Loading...
Platform:
Loading...

Gravity:
Loading...
Temperature:
Loading...
Angle/Tilt:
Loading...
Battery:
Loading...
Average runtime:
Loading...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/test.htm b/html/test.htm index 918aaaa..f3796e9 100644 --- a/html/test.htm +++ b/html/test.htm @@ -82,8 +82,8 @@ function getConfig() { appendLog( "Starting test of push targets" ); - var url = "/api/device"; - //var url = "/test/device.json"; + var url = "/api/status"; + //var url = "/test/status.json"; $('#spinner').show(); $.getJSON(url, function (cfg) { var id = cfg["id"]; diff --git a/html/test.min.htm b/html/test.min.htm index 2e3bceb..341f6bb 100644 --- a/html/test.min.htm +++ b/html/test.min.htm @@ -1 +1 @@ -Beer Gravity Monitor


(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor


(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/html/upload.htm b/html/upload.htm index 1835ad1..515cbbf 100644 --- a/html/upload.htm +++ b/html/upload.htm @@ -66,10 +66,6 @@
index.min.htm
Checking...
-
-
device.min.htm
-
Checking...
-
config.min.htm
Checking...
@@ -125,11 +121,6 @@ function getUpload() { else $("#index").text("File is missing."); - if( cfg["device"] ) - $("#device").text("Completed."); - else - $("#device").text("File is missing."); - if( cfg["config"] ) $("#config").text("Completed."); else diff --git a/html/upload.min.htm b/html/upload.min.htm index 44c4213..affe5f1 100644 --- a/html/upload.min.htm +++ b/html/upload.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

The listed files below needs to be uploaded to the FileSystem in order for the GUI to work. You can also flash the LittleFS filesystem but in that case you will loose your device settings. An OTA upgrade will automatically download the files if they are found in the same location as the firmware.bin. This page is a fallback option.

Once all the files are confirmed, please reboot the device for normal operation.
index.min.htm
Checking...
device.min.htm
Checking...
config.min.htm
Checking...
calibration.min.htm
Checking...
format.min.htm
Checking...
test.min.htm
Checking...
about.min.htm
Checking...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

The listed files below needs to be uploaded to the FileSystem in order for the GUI to work. You can also flash the LittleFS filesystem but in that case you will loose your device settings. An OTA upgrade will automatically download the files if they are found in the same location as the firmware.bin. This page is a fallback option.

Once all the files are confirmed, please reboot the device for normal operation.
index.min.htm
Checking...
config.min.htm
Checking...
calibration.min.htm
Checking...
format.min.htm
Checking...
test.min.htm
Checking...
about.min.htm
Checking...

(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/script/copy_html.py b/script/copy_html.py index a0e3881..340b000 100644 --- a/script/copy_html.py +++ b/script/copy_html.py @@ -17,9 +17,6 @@ shutil.copyfile( source + file, target + file ) file = "config.min.htm" #print( "Copy file: " + source + file + "->" + target + file) shutil.copyfile( source + file, target + file ) -file = "device.min.htm" -#print( "Copy file: " + source + file + "->" + target + file) -shutil.copyfile( source + file, target + file ) file = "index.min.htm" #print( "Copy file: " + source + file + "->" + target + file) shutil.copyfile( source + file, target + file ) diff --git a/script/create_versionjson.py b/script/create_versionjson.py index 50528c1..507feca 100644 --- a/script/create_versionjson.py +++ b/script/create_versionjson.py @@ -60,7 +60,7 @@ def after_build(source, target, env): print( "Creating version.json" ) f = open( target, "w" ) f.write( "{ \"project\":\"gravmon\", \"version\":" + ver + ", " ) - f.write( " \"html\": [ \"index.min.htm\", \"device.min.htm\", \"config.min.htm\", \"calibration.min.htm\", \"test.min.htm\", \"format.min.htm\", \"about.min.htm\" ] }" ) + f.write( " \"html\": [ \"index.min.htm\", \"config.min.htm\", \"calibration.min.htm\", \"test.min.htm\", \"format.min.htm\", \"about.min.htm\" ] }" ) f.close() diff --git a/src/resources.cpp b/src/resources.cpp index 7e9205d..1eaf3bf 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -31,7 +31,6 @@ SOFTWARE. #if defined(EMBED_HTML) // Using minify to reduce memory usage. Reducing RAM memory usage with about 7% INCBIN(IndexHtm, "data/index.min.htm"); -INCBIN(DeviceHtm, "data/device.min.htm"); INCBIN(ConfigHtm, "data/config.min.htm"); INCBIN(CalibrationHtm, "data/calibration.min.htm"); INCBIN(FormatHtm, "data/format.min.htm"); diff --git a/src/resources.hpp b/src/resources.hpp index 48eb69d..4c284de 100644 --- a/src/resources.hpp +++ b/src/resources.hpp @@ -61,7 +61,6 @@ SOFTWARE. #define PARAM_FILES "files" #define PARAM_FILE_NAME "file-name" #define PARAM_FILE_SIZE "file-size" -#define PARAM_APP_NAME "app-name" #define PARAM_APP_VER "app-ver" #define PARAM_ANGLE "angle" #define PARAM_GRAVITY "gravity" diff --git a/src/webserver.cpp b/src/webserver.cpp index a4ddcc2..1f941dd 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -37,42 +37,6 @@ WebServerHandler myWebServerHandler; // My wrapper class fr webserver functions extern bool sleepModeActive; extern bool sleepModeAlwaysSkip; -// -// Callback from webServer when / has been accessed. -// -void WebServerHandler::webHandleDevice() { - LOG_PERF_START("webserver-api-device"); -#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) - Log.verbose(F("WEB : webServer callback for /api/device(get)." CR)); -#endif - - DynamicJsonDocument doc(100); - doc[PARAM_ID] = myConfig.getID(); - doc[PARAM_APP_NAME] = CFG_APPNAME; - doc[PARAM_APP_VER] = CFG_APPVER; - doc[PARAM_MDNS] = myConfig.getMDNS(); - - FloatHistoryLog runLog(RUNTIME_FILENAME); - doc[PARAM_RUNTIME_AVERAGE] = reduceFloatPrecision( - runLog.getAverage() ? runLog.getAverage() / 1000 : 0, 1); - -#if defined(ESP8266) - doc[PARAM_PLATFORM] = "esp8266"; -#else - doc[PARAM_PLATFORM] = "esp32"; -#endif - -#if LOG_LEVEL == 6 - serializeJson(doc, Serial); - Serial.print(CR); -#endif - String out; - out.reserve(100); - serializeJson(doc, out); - _server->send(200, "application/json", out.c_str()); - LOG_PERF_STOP("webserver-api-device"); -} - // // Callback from webServer when / has been accessed. // @@ -140,8 +104,6 @@ void WebServerHandler::webHandleUpload() { DynamicJsonDocument doc(300); doc["index"] = checkHtmlFile(WebServerHandler::HTML_INDEX); - doc["device"] = checkHtmlFile(WebServerHandler::HTML_DEVICE); - doc["config"] = checkHtmlFile(WebServerHandler::HTML_CONFIG); doc["calibration"] = checkHtmlFile(WebServerHandler::HTML_CALIBRATION); doc["format"] = checkHtmlFile(WebServerHandler::HTML_FORMAT); doc["about"] = checkHtmlFile(WebServerHandler::HTML_ABOUT); @@ -204,9 +166,10 @@ void WebServerHandler::webHandleUploadFile() { bool validFilename = false; if (f.equalsIgnoreCase("index.min.htm") || - f.equalsIgnoreCase("device.min.htm") || f.equalsIgnoreCase("calibration.min.htm") || f.equalsIgnoreCase("config.min.htm") || + f.equalsIgnoreCase("format.min.htm") || + f.equalsIgnoreCase("test.min.htm") || f.equalsIgnoreCase("about.min.htm")) { validFilename = true; } @@ -306,7 +269,7 @@ void WebServerHandler::webHandleStatus() { doc[PARAM_ID] = myConfig.getID(); doc[PARAM_ANGLE] = reduceFloatPrecision(angle); if (myConfig.isGravityTempAdj()) { - gravity = gravityTemperatureCorrectionC(gravity, tempC); // + gravity = gravityTemperatureCorrectionC(gravity, tempC); } if (myConfig.isGravityPlato()) { doc[PARAM_GRAVITY] = reduceFloatPrecision(convertToPlato(gravity), 1); @@ -321,6 +284,19 @@ void WebServerHandler::webHandleStatus() { doc[PARAM_SLEEP_MODE] = sleepModeAlwaysSkip; doc[PARAM_RSSI] = WiFi.RSSI(); + doc[PARAM_APP_VER] = CFG_APPVER; + doc[PARAM_MDNS] = myConfig.getMDNS(); + + FloatHistoryLog runLog(RUNTIME_FILENAME); + doc[PARAM_RUNTIME_AVERAGE] = reduceFloatPrecision( + runLog.getAverage() ? runLog.getAverage() / 1000 : 0, 1); + +#if defined(ESP8266) + doc[PARAM_PLATFORM] = "esp8266"; +#else + doc[PARAM_PLATFORM] = "esp32"; +#endif + #if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING) serializeJson(doc, Serial); Serial.print(CR); @@ -343,6 +319,9 @@ void WebServerHandler::webHandleClearWIFI() { if (!id.compareTo(myConfig.getID())) { _server->send(200, "text/plain", "Clearing WIFI credentials and doing reset..."); + myConfig.setWifiPass(""); + myConfig.setWifiSSID(""); + myConfig.saveFile(); delay(1000); WiFi.disconnect(); // Clear credentials ESP_RESET(); @@ -1003,8 +982,6 @@ const char* WebServerHandler::getHtmlFileName(HtmlFile item) { switch (item) { case HTML_INDEX: return "index.min.htm"; - case HTML_DEVICE: - return "device.min.htm"; case HTML_CONFIG: return "config.min.htm"; case HTML_CALIBRATION: @@ -1060,8 +1037,6 @@ bool WebServerHandler::setupWebServer() { _server->on("/", std::bind(&WebServerHandler::webReturnIndexHtm, this)); _server->on("/index.htm", std::bind(&WebServerHandler::webReturnIndexHtm, this)); - _server->on("/device.htm", - std::bind(&WebServerHandler::webReturnDeviceHtm, this)); _server->on("/config.htm", std::bind(&WebServerHandler::webReturnConfigHtm, this)); _server->on("/calibration.htm", @@ -1087,14 +1062,13 @@ bool WebServerHandler::setupWebServer() { // Check if the html files exist, if so serve them, else show the static // upload page. - if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_DEVICE) && - checkHtmlFile(HTML_CONFIG) && checkHtmlFile(HTML_CALIBRATION) && - checkHtmlFile(HTML_FORMAT) && checkHtmlFile(HTML_ABOUT) && checkHtmlFile(HTML_TEST) ) { + if (checkHtmlFile(HTML_INDEX) && checkHtmlFile(HTML_CONFIG) && + checkHtmlFile(HTML_CALIBRATION) && checkHtmlFile(HTML_FORMAT) && + checkHtmlFile(HTML_ABOUT) && checkHtmlFile(HTML_TEST) ) { Log.notice(F("WEB : All html files exist, starting in normal mode." CR)); _server->serveStatic("/", LittleFS, "/index.min.htm"); _server->serveStatic("/index.htm", LittleFS, "/index.min.htm"); - _server->serveStatic("/device.htm", LittleFS, "/device.min.htm"); _server->serveStatic("/config.htm", LittleFS, "/config.min.htm"); _server->serveStatic("/about.htm", LittleFS, "/about.min.htm"); _server->serveStatic("/test.htm", LittleFS, "/test.min.htm"); @@ -1117,9 +1091,6 @@ bool WebServerHandler::setupWebServer() { _server->on( "/api/config", HTTP_GET, std::bind(&WebServerHandler::webHandleConfig, this)); // Get config.json - _server->on( - "/api/device", HTTP_GET, - std::bind(&WebServerHandler::webHandleDevice, this)); // Get device.json _server->on("/api/formula", HTTP_GET, std::bind(&WebServerHandler::webHandleFormulaRead, this)); // Get formula.json (calibration page) diff --git a/src/webserver.hpp b/src/webserver.hpp index 8c2984c..65a23c6 100644 --- a/src/webserver.hpp +++ b/src/webserver.hpp @@ -37,7 +37,6 @@ SOFTWARE. #if defined(EMBED_HTML) INCBIN_EXTERN(IndexHtm); -INCBIN_EXTERN(DeviceHtm); INCBIN_EXTERN(ConfigHtm); INCBIN_EXTERN(CalibrationHtm); INCBIN_EXTERN(FormatHtm); @@ -70,7 +69,6 @@ class WebServerHandler { void webHandleCalibrate(); void webHandleUploadFile(); void webHandleUpload(); - void webHandleDevice(); void webHandleDeviceParam(); void webHandlePageNotFound(); @@ -86,10 +84,6 @@ class WebServerHandler { _server->send_P(200, "text/html", (const char*)gIndexHtmData, gIndexHtmSize); } - void webReturnDeviceHtm() { - _server->send_P(200, "text/html", (const char*)gDeviceHtmData, - gDeviceHtmSize); - } void webReturnConfigHtm() { _server->send_P(200, "text/html", (const char*)gConfigHtmData, gConfigHtmSize); @@ -120,12 +114,11 @@ class WebServerHandler { public: enum HtmlFile { HTML_INDEX = 0, - HTML_DEVICE = 1, - HTML_CONFIG = 2, - HTML_ABOUT = 3, - HTML_CALIBRATION = 4, - HTML_FORMAT = 5, - HTML_TEST = 6 + HTML_CONFIG = 1, + HTML_ABOUT = 2, + HTML_CALIBRATION = 3, + HTML_FORMAT = 4, + HTML_TEST = 5 }; bool setupWebServer(); diff --git a/src_docs/source/api.rst b/src_docs/source/api.rst index 3534c53..1271a6e 100644 --- a/src_docs/source/api.rst +++ b/src_docs/source/api.rst @@ -78,20 +78,7 @@ Other parameters are the same as in the configuration guide. GET: /api/device ================ -Retrive the current device settings via an HTTP GET command. Payload is in JSON format. - -* ``platform`` can be either ``esp8266`` or ``esp32`` - -.. code-block:: json - - { - "app-name": "GravityMon", - "app-ver": "0.0.0", - "id": "ee1bfc", - "mdns": "gravmon", - "platform": "esp8266", - "runtime-average": 3.12 - } +This API has been removed from 0.9 and merged with /api/status GET: /api/status @@ -100,6 +87,7 @@ GET: /api/status Retrive the current device status via an HTTP GET command. Payload is in JSON format. * ``temp-format`` can be either ``C`` or ``F`` +* ``platform`` can be either ``esp8266`` or ``esp32`` Other parameters are the same as in the configuration guide. @@ -109,13 +97,16 @@ Other parameters are the same as in the configuration guide. "id": "ee1bfc", "angle": 89.86, "gravity": 1.1052, - "gravity-tempcorr": 1.1031, "temp-c": 0, "temp-f": 32, "battery": 0, "temp-format": "C", "sleep-mode": false, - "rssi": -56 + "rssi": -56, + "app-ver": "0.0.0", + "mdns": "gravmon", + "platform": "esp8266", + "runtime-average": 3.12 } @@ -149,7 +140,7 @@ Retrive the data used for formula calculation data via an HTTP GET command. Payl GET: /api/clearwifi =================== -Will reset the wifi settings, leaving the rest unused. +Will reset the wifi settings both in the configuration file and eeprom, leaving the rest of the configuration. For this to work you will need to supply the device id as a parameter in the request: diff --git a/src_docs/source/releases.rst b/src_docs/source/releases.rst index df4f731..dd2b065 100644 --- a/src_docs/source/releases.rst +++ b/src_docs/source/releases.rst @@ -6,6 +6,8 @@ Releases v0.9.0 ------ * Added function to test push targets from configuration page. It will send data and show the return code as a first step. +* Merged index and device pages into one so that all the needed information is available on the index page. +* Removed api for device (/api/device), it's now merged into the /api/status api. * Updated WifiManager and DoubleReset libraries * Experimental release of firmware using an esp32 instead of esp8266 * Updated esp32 target with littlefs support diff --git a/test/device.json b/test/device.json deleted file mode 100644 index f083ca9..0000000 --- a/test/device.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "app-name": "GravityMon ", - "app-ver": "0.0.0", - "id": "7376ef", - "mdns": "gravmon", - "platform": "esp32", - "runtime-average": 3.12 -} \ No newline at end of file diff --git a/test/status.json b/test/status.json index bb89c37..91e9e33 100644 --- a/test/status.json +++ b/test/status.json @@ -2,12 +2,15 @@ "id": "7376ef", "angle": 22.4, "gravity": 1.044, - "gravity-tempcorr": 1.031, "gravity-format": "G", "temp-c": 12, "temp-f": 32, "battery": 3.81, "temp-format": "C", "sleep-mode": false, - "rssi": -56 + "rssi": -56, + "app-ver": "0.0.0", + "mdns": "gravmon", + "platform": "esp32", + "runtime-average": 3.12 } \ No newline at end of file diff --git a/test/upload.json b/test/upload.json index 1776e59..cade73f 100644 --- a/test/upload.json +++ b/test/upload.json @@ -1,6 +1,5 @@ { "index": false, - "device": false, "config": false, "calibration": false, "format": false,