Updated documentation and made build
This commit is contained in:
parent
e8d02de96b
commit
231b1fccd5
23
README.md
23
README.md
@ -6,7 +6,6 @@ I started this project out of curiosity for how a motion sensor is working and s
|
|||||||
|
|
||||||
* Add support for Plato in device (today it assumes that formula is in SG).
|
* Add support for Plato in device (today it assumes that formula is in SG).
|
||||||
* Add support for converting between SG/Plato in device.
|
* Add support for converting between SG/Plato in device.
|
||||||
* Add support for InfluxDB as endpoint
|
|
||||||
* Add support for Blynk as endpoint
|
* Add support for Blynk as endpoint
|
||||||
* Add support for https connections (push)
|
* Add support for https connections (push)
|
||||||
* Add support for https web server (will require certificates to be created as part of build process)
|
* Add support for https web server (will require certificates to be created as part of build process)
|
||||||
@ -54,11 +53,15 @@ The device page shows the device settings and software versions.
|
|||||||
|
|
||||||
http://gravmon.local/config.htm
|
http://gravmon.local/config.htm
|
||||||
|
|
||||||
This page is divided into several categories of settings. The first one contains device settings, mDNS name, temperature format, and gyro calibration data. Calibration needs to be done or the device will not work correctly. Place the device flat on a surface with gyro up and press the calibrate button when it's stable.
|
This page is divided into several categories of settings. The first one contains device settings, mDNS name, temperature format, and gyro calibration data. The interval setting is the amount of time the device will be in sleep mode between readings (interval is in seconds).
|
||||||
|
|
||||||
|
Calibration needs to be done or the device will not work correctly. Place the device flat on a surface with gyro up and press the calibrate button when it's stable.
|
||||||
|
|
||||||
|
__TODO: Update image for config settings.__
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The second section contains the push settings, two URL's for http sending and one for Brewfather. The interval setting is the amount of time the device will be in sleep mode between readings (interval is in seconds).
|
The second section contains the push settings, two URL's for http posts, Brewfather and settings for InfluxDB v2.
|
||||||
|
|
||||||
### This is the format used for standard http posts.
|
### This is the format used for standard http posts.
|
||||||
```
|
```
|
||||||
@ -73,7 +76,7 @@ The second section contains the push settings, two URL's for http sending and on
|
|||||||
"angle": 45.34,
|
"angle": 45.34,
|
||||||
"battery": 3.67,
|
"battery": 3.67,
|
||||||
"rssi": -12,
|
"rssi": -12,
|
||||||
"run-time": 2.30, // Runtime for this reading, this is an extension
|
"run-time": 230, // ms, Runtime for this reading, this is an additional field not part of the standard format
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -90,6 +93,18 @@ The second section contains the push settings, two URL's for http sending and on
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### This is the format for InfluxDB v2
|
||||||
|
|
||||||
|
```
|
||||||
|
gravity,host=<mdns>,device=<id>,format=SG value=1.0004
|
||||||
|
angle,host=<mdns>,device=<id> value=45.45
|
||||||
|
temp,host=<mdns>,device=<id>,format=<C|F> value=20.1
|
||||||
|
battery,host=<mdns>,device=<id> value=3.96
|
||||||
|
rssi,host=<mdns>,device=<id> value=-18
|
||||||
|
```
|
||||||
|
|
||||||
|
__TODO: Update image for push settings.__
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The third section contains the gravity options, formlua and option for temperature correcting gravity.
|
The third section contains the gravity options, formlua and option for temperature correcting gravity.
|
||||||
|
@ -1,17 +1 @@
|
|||||||
<!doctype html><html lang="en"><!--
|
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" crossorigin="anonymous"></script></head><body class="py-4"><!-- START MENU --><nav class="navbar navbar-expand-sm navbar-dark bg-primary"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><ul class="navbar-nav mr-auto"><li class="nav-item"><a class="nav-link" href="/index.htm">Home <span class="sr-only">(current)</span></a></li><li class="nav-item active"><a class="nav-link" href="/device.htm">Device</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/about.htm">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></nav><!-- START MAIN INDEX --><div class="container"><hr class="my-4"><div class="alert alert-success alert-dismissible fade hide show d-none" role="alert" id="alert"><div id="alert-msg">...</div><button type="button" id="alert-btn" class="close" aria-label="Close"><span aria-hidden="true">×</span></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("d-none").removeClass("show")})</script><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Current version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3" id="h-app-ver-new" hidden><div class="col-md-8 themed-grid-col bg-light">New version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver-new">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Host name:</div><div class="col-md-4 themed-grid-col bg-light" id="mdns">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Device ID:</div><div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div></div><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.5)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
||||||
TODO:
|
|
||||||
* Add OTA check for new firmware.
|
|
||||||
* Add button to do upgrade to new firmware.
|
|
||||||
--><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" crossorigin="anonymous"></script></head><body class="py-4"><!-- START MENU --><nav class="navbar navbar-expand-sm navbar-dark bg-primary"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><ul class="navbar-nav mr-auto"><li class="nav-item"><a class="nav-link" href="/index.htm">Home <span class="sr-only">(current)</span></a></li><li class="nav-item active"><a class="nav-link" href="/device.htm">Device</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/about.htm">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></nav><!-- START MAIN INDEX --><div class="container"><hr class="my-4"><div class="alert alert-success alert-dismissible fade hide show d-none" role="alert" id="alert"><div id="alert-msg">...</div><button type="button" id="alert-btn" class="close" aria-label="Close"><span aria-hidden="true">×</span></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("d-none").removeClass("show")})</script><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Current version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3" id="h-app-ver-new" hidden><div class="col-md-8 themed-grid-col bg-light">New version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver-new">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Host name:</div><div class="col-md-4 themed-grid-col bg-light" id="mdns">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Device ID:</div><div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div></div><!--
|
|
||||||
<div class="form-group row">
|
|
||||||
<div class="col-md-4 ">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Reset Device</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Clear WIFI Settings</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.2)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
|
Binary file not shown.
BIN
bin/firmware.bin
BIN
bin/firmware.bin
Binary file not shown.
@ -1 +1 @@
|
|||||||
{ "project":"gravmon", "version":"0.3.2", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] }
|
{ "project":"gravmon", "version":"0.3.5", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] }
|
@ -1,12 +1,6 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<!--
|
|
||||||
TODO:
|
|
||||||
* Add OTA check for new firmware.
|
|
||||||
* Add button to do upgrade to new firmware.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
@ -91,21 +85,6 @@
|
|||||||
<div class="col-md-8 themed-grid-col bg-light">Device ID:</div>
|
<div class="col-md-8 themed-grid-col bg-light">Device ID:</div>
|
||||||
<div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div>
|
<div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
|
||||||
<div class="form-group row">
|
|
||||||
<div class="col-md-4 ">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Reset Device</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Clear WIFI Settings</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<hr class="my-4">
|
<hr class="my-4">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,17 +1 @@
|
|||||||
<!doctype html><html lang="en"><!--
|
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" crossorigin="anonymous"></script></head><body class="py-4"><!-- START MENU --><nav class="navbar navbar-expand-sm navbar-dark bg-primary"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><ul class="navbar-nav mr-auto"><li class="nav-item"><a class="nav-link" href="/index.htm">Home <span class="sr-only">(current)</span></a></li><li class="nav-item active"><a class="nav-link" href="/device.htm">Device</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/about.htm">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></nav><!-- START MAIN INDEX --><div class="container"><hr class="my-4"><div class="alert alert-success alert-dismissible fade hide show d-none" role="alert" id="alert"><div id="alert-msg">...</div><button type="button" id="alert-btn" class="close" aria-label="Close"><span aria-hidden="true">×</span></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("d-none").removeClass("show")})</script><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Current version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3" id="h-app-ver-new" hidden><div class="col-md-8 themed-grid-col bg-light">New version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver-new">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Host name:</div><div class="col-md-4 themed-grid-col bg-light" id="mdns">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Device ID:</div><div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div></div><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.5)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
||||||
TODO:
|
|
||||||
* Add OTA check for new firmware.
|
|
||||||
* Add button to do upgrade to new firmware.
|
|
||||||
--><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Beer Gravity Monitor</title><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"><script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" crossorigin="anonymous"></script></head><body class="py-4"><!-- START MENU --><nav class="navbar navbar-expand-sm navbar-dark bg-primary"><a class="navbar-brand" href="/index.htm">Beer Gravity Monitor</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbar"><ul class="navbar-nav mr-auto"><li class="nav-item"><a class="nav-link" href="/index.htm">Home <span class="sr-only">(current)</span></a></li><li class="nav-item active"><a class="nav-link" href="/device.htm">Device</a></li><li class="nav-item"><a class="nav-link" href="/config.htm">Configuration</a></li><li class="nav-item"><a class="nav-link" href="/about.htm">About</a></li></ul></div><div class="spinner-border text-light" id="spinner" role="status"></div></nav><!-- START MAIN INDEX --><div class="container"><hr class="my-4"><div class="alert alert-success alert-dismissible fade hide show d-none" role="alert" id="alert"><div id="alert-msg">...</div><button type="button" id="alert-btn" class="close" aria-label="Close"><span aria-hidden="true">×</span></button></div><script type="text/javascript">function showError(s){$(".alert").removeClass("alert-success").addClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}function showSuccess(s){$(".alert").addClass("alert-success").removeClass("alert-danger").removeClass("d-none").addClass("show"),$("#alert-msg").text(s)}$("#alert-btn").click(function(s){$(".alert").addClass("d-none").removeClass("show")})</script><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Current version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver">Loading...</div></div><div class="row mb-3" id="h-app-ver-new" hidden><div class="col-md-8 themed-grid-col bg-light">New version:</div><div class="col-md-4 themed-grid-col bg-light" id="app-ver-new">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Host name:</div><div class="col-md-4 themed-grid-col bg-light" id="mdns">Loading...</div></div><div class="row mb-3"><div class="col-md-8 themed-grid-col bg-light">Device ID:</div><div class="col-md-4 themed-grid-col bg-light" id="id">Loading...</div></div><!--
|
|
||||||
<div class="form-group row">
|
|
||||||
<div class="col-md-4 ">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Reset Device</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Clear WIFI Settings</button>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.5)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
|
|
@ -50,7 +50,7 @@ extra_scripts =
|
|||||||
build_unflags = ${common_env_data.build_unflags}
|
build_unflags = ${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
-D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial or influxdb
|
-D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb
|
||||||
-D LOG_LEVEL=6 # Maximum log level for the debug build.
|
-D LOG_LEVEL=6 # Maximum log level for the debug build.
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
@ -69,6 +69,7 @@ extra_scripts =
|
|||||||
build_unflags = ${common_env_data.build_unflags}
|
build_unflags = ${common_env_data.build_unflags}
|
||||||
build_flags =
|
build_flags =
|
||||||
${common_env_data.build_flags}
|
${common_env_data.build_flags}
|
||||||
|
-D COLLECT_PERFDATA # This option will collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb
|
||||||
-D LOG_LEVEL=5
|
-D LOG_LEVEL=5
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps}
|
${common_env_data.lib_deps}
|
||||||
|
@ -137,7 +137,7 @@ bool Config::loadFile() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.notice(F("CFG : Size of configuration %d bytes." CR), configFile.size() );
|
Log.notice(F("CFG : Size of configuration file=%d bytes." CR), configFile.size() );
|
||||||
|
|
||||||
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
DynamicJsonDocument doc(CFG_JSON_BUFSIZE);
|
||||||
DeserializationError err = deserializeJson(doc, configFile);
|
DeserializationError err = deserializeJson(doc, configFile);
|
||||||
|
@ -194,9 +194,9 @@ void PerfLogging::pushInflux() {
|
|||||||
int httpResponseCode = http.POST(body);
|
int httpResponseCode = http.POST(body);
|
||||||
|
|
||||||
if (httpResponseCode==204) {
|
if (httpResponseCode==204) {
|
||||||
Log.notice(F("PUSH: InfluxDB2 HTTP Response code %d" CR), httpResponseCode);
|
Log.notice(F("PERF: InfluxDB2 push performance data successful, response=%d" CR), httpResponseCode);
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("PUSH: InfluxDB2 HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("PERF: InfluxDB2 push performance data failed, response=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
http.end();
|
http.end();
|
||||||
|
@ -125,13 +125,14 @@ extern PerfLogging myPerfLogging;
|
|||||||
// Use these to collect performance data from various parts of the code
|
// Use these to collect performance data from various parts of the code
|
||||||
#define LOG_PERF_START(s) myPerfLogging.start(s)
|
#define LOG_PERF_START(s) myPerfLogging.start(s)
|
||||||
#define LOG_PERF_STOP(s) myPerfLogging.stop(s)
|
#define LOG_PERF_STOP(s) myPerfLogging.stop(s)
|
||||||
#define LOG_PERF_PRINT() myPerfLogging.print()
|
//#define LOG_PERF_PRINT() myPerfLogging.print()
|
||||||
|
#define LOG_PERF_PRINT()
|
||||||
#define LOG_PERF_CLEAR() myPerfLogging.clear()
|
#define LOG_PERF_CLEAR() myPerfLogging.clear()
|
||||||
#define LOG_PERF_PUSH() myPerfLogging.pushInflux()
|
#define LOG_PERF_PUSH() myPerfLogging.pushInflux()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// These will disable the performance collection
|
// These will disable the performance collection function
|
||||||
#define LOG_PERF_START(s)
|
#define LOG_PERF_START(s)
|
||||||
#define LOG_PERF_STOP(s)
|
#define LOG_PERF_STOP(s)
|
||||||
#define LOG_PERF_PRINT()
|
#define LOG_PERF_PRINT()
|
||||||
|
@ -97,7 +97,6 @@ void setup() {
|
|||||||
|
|
||||||
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
|
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
|
||||||
bool dt = drd->detectDoubleReset();
|
bool dt = drd->detectDoubleReset();
|
||||||
|
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("Main: Reset reason %s." CR), ESP.getResetInfo().c_str() );
|
Log.verbose(F("Main: Reset reason %s." CR), ESP.getResetInfo().c_str() );
|
||||||
#endif
|
#endif
|
||||||
@ -105,7 +104,6 @@ void setup() {
|
|||||||
Log.notice(F("Main: Started setup for %s." CR), String( ESP.getChipId(), HEX).c_str() );
|
Log.notice(F("Main: Started setup for %s." CR), String( ESP.getChipId(), HEX).c_str() );
|
||||||
printBuildOptions();
|
printBuildOptions();
|
||||||
|
|
||||||
Log.notice(F("Main: Loading configuration." CR));
|
|
||||||
LOG_PERF_START("main-config-load");
|
LOG_PERF_START("main-config-load");
|
||||||
myConfig.checkFileSystem();
|
myConfig.checkFileSystem();
|
||||||
myConfig.loadFile();
|
myConfig.loadFile();
|
||||||
@ -128,7 +126,6 @@ void setup() {
|
|||||||
if( dt )
|
if( dt )
|
||||||
Log.notice(F("Main: Detected doubletap on reset." CR));
|
Log.notice(F("Main: Detected doubletap on reset." CR));
|
||||||
|
|
||||||
Log.notice(F("Main: Connecting to wifi." CR));
|
|
||||||
LOG_PERF_START("main-wifi-connect");
|
LOG_PERF_START("main-wifi-connect");
|
||||||
myWifi.connect( dt );
|
myWifi.connect( dt );
|
||||||
LOG_PERF_STOP("main-wifi-connect");
|
LOG_PERF_STOP("main-wifi-connect");
|
||||||
@ -143,8 +140,6 @@ void setup() {
|
|||||||
checkSleepMode( myGyro.getAngle(), myBatteryVoltage.getVoltage() );
|
checkSleepMode( myGyro.getAngle(), myBatteryVoltage.getVoltage() );
|
||||||
|
|
||||||
if( myWifi.isConnected() ) {
|
if( myWifi.isConnected() ) {
|
||||||
Log.notice(F("Main: Connected to wifi ip=%s." CR), myWifi.getIPAddress().c_str() );
|
|
||||||
|
|
||||||
#if defined( ACTIVATE_OTA )
|
#if defined( ACTIVATE_OTA )
|
||||||
LOG_PERF_START("main-wifi-ota");
|
LOG_PERF_START("main-wifi-ota");
|
||||||
if( !sleepModeActive && myWifi.checkFirmwareVersion() ) {
|
if( !sleepModeActive && myWifi.checkFirmwareVersion() ) {
|
||||||
@ -154,8 +149,7 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
if( !sleepModeActive ) {
|
if( !sleepModeActive ) {
|
||||||
LOG_PERF_START("main-webserver-setup");
|
LOG_PERF_START("main-webserver-setup");
|
||||||
if( myWebServer.setupWebServer() )
|
myWebServer.setupWebServer();
|
||||||
Log.notice(F("Main: Webserver is running." CR) );
|
|
||||||
LOG_PERF_STOP("main-webserver-setup");
|
LOG_PERF_STOP("main-webserver-setup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,6 +157,7 @@ void setup() {
|
|||||||
LOG_PERF_STOP("main-setup");
|
LOG_PERF_STOP("main-setup");
|
||||||
LOG_PERF_PRINT(); // Dump data to serial
|
LOG_PERF_PRINT(); // Dump data to serial
|
||||||
LOG_PERF_PUSH(); // Dump data to influx
|
LOG_PERF_PUSH(); // Dump data to influx
|
||||||
|
Log.notice(F("Main: Setup completed." CR));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -87,11 +87,13 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run
|
|||||||
// Create body for influxdb2
|
// Create body for influxdb2
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
sprintf( &buf[0], "gravity,host=%s,device=%s,format=%s value=%.4f\n"
|
sprintf( &buf[0], "gravity,host=%s,device=%s,format=%s value=%.4f\n"
|
||||||
|
"angle,host=%s,device=%s value=%.2f\n"
|
||||||
"temp,host=%s,device=%s,format=%c value=%.1f\n"
|
"temp,host=%s,device=%s,format=%c value=%.1f\n"
|
||||||
"battery,host=%s,device=%s value=%.2f\n"
|
"battery,host=%s,device=%s value=%.2f\n"
|
||||||
"rssi,host=%s,device=%s value=%d\n",
|
"rssi,host=%s,device=%s value=%d\n",
|
||||||
// TODO: Add support for plato format
|
// TODO: Add support for plato format
|
||||||
myConfig.getMDNS(), myConfig.getID(), "SG", gravity,
|
myConfig.getMDNS(), myConfig.getID(), "SG", gravity,
|
||||||
|
myConfig.getMDNS(), myConfig.getID(), angle,
|
||||||
myConfig.getMDNS(), myConfig.getID(), myConfig.getTempFormat(), temp,
|
myConfig.getMDNS(), myConfig.getID(), myConfig.getTempFormat(), temp,
|
||||||
myConfig.getMDNS(), myConfig.getID(), myBatteryVoltage.getVoltage(),
|
myConfig.getMDNS(), myConfig.getID(), myBatteryVoltage.getVoltage(),
|
||||||
myConfig.getMDNS(), myConfig.getID(), WiFi.RSSI() );
|
myConfig.getMDNS(), myConfig.getID(), WiFi.RSSI() );
|
||||||
@ -107,9 +109,9 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run
|
|||||||
int httpResponseCode = http.POST(&buf[0]);
|
int httpResponseCode = http.POST(&buf[0]);
|
||||||
|
|
||||||
if (httpResponseCode==204) {
|
if (httpResponseCode==204) {
|
||||||
Log.notice(F("PUSH: InfluxDB2 HTTP Response code %d" CR), httpResponseCode);
|
Log.notice(F("PUSH: InfluxDB2 push successful, response=%d" CR), httpResponseCode);
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("PUSH: InfluxDB2 HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("PUSH: InfluxDB2 push failed, response=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
http.end();
|
http.end();
|
||||||
@ -167,9 +169,9 @@ void PushTarget::sendBrewfather(float angle, float gravity, float temp ) {
|
|||||||
int httpResponseCode = http.POST(json);
|
int httpResponseCode = http.POST(json);
|
||||||
|
|
||||||
if (httpResponseCode==200) {
|
if (httpResponseCode==200) {
|
||||||
Log.notice(F("PUSH: Brewfather HTTP Response code %d" CR), httpResponseCode);
|
Log.notice(F("PUSH: Brewfather push successful, response=%d" CR), httpResponseCode);
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("PUSH: Brewfather HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("PUSH: Brewfather push failed, response=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
http.end();
|
http.end();
|
||||||
@ -217,9 +219,9 @@ void PushTarget::sendHttp( String serverPath, float angle, float gravity, float
|
|||||||
int httpResponseCode = http.POST(json);
|
int httpResponseCode = http.POST(json);
|
||||||
|
|
||||||
if (httpResponseCode==200) {
|
if (httpResponseCode==200) {
|
||||||
Log.notice(F("PUSH: HTTP Response code %d" CR), httpResponseCode);
|
Log.notice(F("PUSH: HTTP push successful, response=%d" CR), httpResponseCode);
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("PUSH: HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("PUSH: HTTP push failed, response=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
http.end();
|
http.end();
|
||||||
|
@ -444,7 +444,7 @@ bool WebServer::checkHtmlFile( HtmlFile item ) {
|
|||||||
// Setup the Web Server callbacks and start it
|
// Setup the Web Server callbacks and start it
|
||||||
//
|
//
|
||||||
bool WebServer::setupWebServer() {
|
bool WebServer::setupWebServer() {
|
||||||
Log.notice(F("WEB : Web server setup started." CR));
|
Log.notice(F("WEB : Configuring web server." CR));
|
||||||
|
|
||||||
MDNS.begin( myConfig.getMDNS() );
|
MDNS.begin( myConfig.getMDNS() );
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
|
38
src/wifi.cpp
38
src/wifi.cpp
@ -57,8 +57,6 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
Log.verbose(F("WIFI: Connecting to WIFI via connection manager (portal=%s)." CR), showPortal?"true":"false");
|
Log.verbose(F("WIFI: Connecting to WIFI via connection manager (portal=%s)." CR), showPortal?"true":"false");
|
||||||
myWifiManager.setDebugOutput(true);
|
myWifiManager.setDebugOutput(true);
|
||||||
#endif
|
#endif
|
||||||
unsigned long startMillis = millis();
|
|
||||||
|
|
||||||
if( strlen(userSSID)==0 && showPortal ) {
|
if( strlen(userSSID)==0 && showPortal ) {
|
||||||
Log.notice(F("WIFI: Starting wifi portal." CR));
|
Log.notice(F("WIFI: Starting wifi portal." CR));
|
||||||
|
|
||||||
@ -82,8 +80,9 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
// Connect to wifi
|
// Connect to wifi
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
Log.notice(F("WIFI: Connecting to WIFI." CR));
|
||||||
if( strlen(userSSID) ) {
|
if( strlen(userSSID) ) {
|
||||||
Log.notice(F("WIFI: connecting to wifi using predefined settings %s." CR), userSSID);
|
Log.notice(F("WIFI: Connecting to wifi using predefined settings %s." CR), userSSID);
|
||||||
WiFi.begin( userSSID, userPWD );
|
WiFi.begin( userSSID, userPWD );
|
||||||
} else {
|
} else {
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
@ -100,13 +99,7 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
}
|
}
|
||||||
Serial.print( CR );
|
Serial.print( CR );
|
||||||
connectedFlag = true;
|
connectedFlag = true;
|
||||||
|
Log.notice(F("WIFI: Connected to wifi ip=%s." CR), getIPAddress().c_str() );
|
||||||
Log.notice( F("WIFI: IP=%s, Connect time %d s" CR), WiFi.localIP().toString().c_str(), abs(millis() - startMillis)/1000);
|
|
||||||
|
|
||||||
#if LOG_LEVEL==6
|
|
||||||
Log.verbose(F("WIFI: Connect returned %s." CR), connectedFlag?"True":"False" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return connectedFlag;
|
return connectedFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +109,7 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
bool Wifi::disconnect() {
|
bool Wifi::disconnect() {
|
||||||
Log.notice(F("WIFI: Erasing stored WIFI credentials." CR));
|
Log.notice(F("WIFI: Erasing stored WIFI credentials." CR));
|
||||||
// Erase WIFI credentials
|
// Erase WIFI credentials
|
||||||
return WiFi.disconnect();
|
return WiFi.disconnect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined( ACTIVATE_OTA )
|
#if defined( ACTIVATE_OTA )
|
||||||
@ -141,12 +134,13 @@ bool Wifi::updateFirmware() {
|
|||||||
|
|
||||||
switch(ret) {
|
switch(ret) {
|
||||||
case HTTP_UPDATE_FAILED:
|
case HTTP_UPDATE_FAILED:
|
||||||
Log.error(F("WIFI: Updating failed %d, %s." CR), ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
Log.error(F("WIFI: OTA update failed %d, %s." CR), ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||||
break;
|
break;
|
||||||
case HTTP_UPDATE_NO_UPDATES:
|
case HTTP_UPDATE_NO_UPDATES:
|
||||||
break;
|
break;
|
||||||
case HTTP_UPDATE_OK:
|
case HTTP_UPDATE_OK:
|
||||||
Log.notice("WIFI: Updated succesfull, rebooting." );
|
Log.notice("WIFI: OTA Update sucesfull, rebooting." );
|
||||||
|
delay(100);
|
||||||
ESP.reset();
|
ESP.reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -175,7 +169,7 @@ void Wifi::downloadFile(const char *fname) {
|
|||||||
f.close();
|
f.close();
|
||||||
Log.notice(F("WIFI: Downloaded file %s." CR), fname);
|
Log.notice(F("WIFI: Downloaded file %s." CR), fname);
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("WIFI: HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("WIFI: Failed to download file, respone=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
}
|
}
|
||||||
@ -199,7 +193,7 @@ bool Wifi::checkFirmwareVersion() {
|
|||||||
int httpResponseCode = http.GET();
|
int httpResponseCode = http.GET();
|
||||||
|
|
||||||
if (httpResponseCode==200) {
|
if (httpResponseCode==200) {
|
||||||
Log.notice(F("WIFI: HTTP Response code %d" CR), httpResponseCode);
|
Log.notice(F("WIFI: Found version.json, response=%d" CR), httpResponseCode);
|
||||||
|
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
@ -208,7 +202,7 @@ bool Wifi::checkFirmwareVersion() {
|
|||||||
DynamicJsonDocument ver(300);
|
DynamicJsonDocument ver(300);
|
||||||
DeserializationError err = deserializeJson(ver, payload);
|
DeserializationError err = deserializeJson(ver, payload);
|
||||||
if( err ) {
|
if( err ) {
|
||||||
Log.error(F("WIFI: Failed to parse json, %s" CR), err);
|
Log.error(F("WIFI: Failed to parse version.json, %s" CR), err);
|
||||||
} else {
|
} else {
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("WIFI: Project %s version %s." CR), (const char*) ver["project"], (const char*) ver["version"]);
|
Log.verbose(F("WIFI: Project %s version %s." CR), (const char*) ver["project"], (const char*) ver["version"]);
|
||||||
@ -219,7 +213,7 @@ bool Wifi::checkFirmwareVersion() {
|
|||||||
if( parseFirmwareVersionString( newVer, (const char*) ver["version"] ) ) {
|
if( parseFirmwareVersionString( newVer, (const char*) ver["version"] ) ) {
|
||||||
if( parseFirmwareVersionString( curVer, CFG_APPVER) ) {
|
if( parseFirmwareVersionString( curVer, CFG_APPVER) ) {
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("OTA : Checking New=%d.%d.%d Cur=%d.%d.%d" CR), newVer[0], newVer[1], newVer[2], curVer[0], curVer[1], curVer[2] );
|
Log.verbose(F("WIFI: OTA checking new=%d.%d.%d cur=%d.%d.%d" CR), newVer[0], newVer[1], newVer[2], curVer[0], curVer[1], curVer[2] );
|
||||||
#endif
|
#endif
|
||||||
// Compare major version
|
// Compare major version
|
||||||
if( newVer[0] > curVer[0] )
|
if( newVer[0] > curVer[0] )
|
||||||
@ -235,23 +229,23 @@ bool Wifi::checkFirmwareVersion() {
|
|||||||
|
|
||||||
// Download new html files to filesystem if they are present.
|
// Download new html files to filesystem if they are present.
|
||||||
if( !ver["html"].isNull() && newFirmware ) {
|
if( !ver["html"].isNull() && newFirmware ) {
|
||||||
Log.notice(F("OTA : Downloading new html files." CR));
|
Log.notice(F("WIFI: OTA downloading new html files." CR));
|
||||||
JsonArray htmlFiles = ver["html"].as<JsonArray>();
|
JsonArray htmlFiles = ver["html"].as<JsonArray>();
|
||||||
for(JsonVariant v : htmlFiles) {
|
for(JsonVariant v : htmlFiles) {
|
||||||
String s = v;
|
String s = v;
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("OTA : Html file found %s" CR), s.c_str() );
|
Log.verbose(F("WIFI: OTA listed html file %s" CR), s.c_str() );
|
||||||
#endif
|
#endif
|
||||||
downloadFile( s.c_str() );
|
downloadFile( s.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("WIFI: HTTP Response code %d" CR), httpResponseCode);
|
Log.error(F("WIFI: OTA error checking version.json, response=%d" CR), httpResponseCode);
|
||||||
}
|
}
|
||||||
http.end();
|
http.end();
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("WIFI: Found new version %s." CR), newFirmware?"true":"false");
|
Log.verbose(F("WIFI: OTA found new version %s." CR), newFirmware?"true":"false");
|
||||||
#endif
|
#endif
|
||||||
return newFirmware;
|
return newFirmware;
|
||||||
}
|
}
|
||||||
@ -261,7 +255,7 @@ bool Wifi::checkFirmwareVersion() {
|
|||||||
//
|
//
|
||||||
bool Wifi::parseFirmwareVersionString( int (&num)[3], const char *version ) {
|
bool Wifi::parseFirmwareVersionString( int (&num)[3], const char *version ) {
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("WIFI: Parsing version number %s." CR), version);
|
Log.verbose(F("WIFI: Parsing version number string %s." CR), version);
|
||||||
#endif
|
#endif
|
||||||
char temp[80];
|
char temp[80];
|
||||||
char *s;
|
char *s;
|
||||||
|
Loading…
Reference in New Issue
Block a user