Added advanced settings
This commit is contained in:
parent
902d123a68
commit
cf143c0e73
125
html/config.htm
125
html/config.htm
@ -449,6 +449,96 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="headingAdvanced">
|
||||||
|
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAdvanced" aria-expanded="false" aria-controls="collapseAdvanced">
|
||||||
|
<b>Advanced (use with caution)</b>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseAdvanced" class="accordion-collapse collapse" aria-labelledby="headingAdvanced" data-bs-parent="#accordion">
|
||||||
|
<div class="accordion-body">
|
||||||
|
|
||||||
|
<form action="/api/config/advanced" method="post">
|
||||||
|
<input type="text" name="id" id="id6" hidden>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="gyro-read-count" class="col-sm-3 col-form-label">Gyro reads:</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="10" max="100" class="form-control" name="gyro-read-count" id="gyro-read-count">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(10-100) - default 50 - number of reads for angle</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="gyro-moving-threashold" class="col-sm-3 col-form-label">Gyro moving theashold:</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="50" max="1000" class="form-control" name="gyro-moving-threashold" id="gyro-moving-threashold">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(50-1000) - default 500 - size of movement</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="formula-max-deviation" class="col-sm-3 col-form-label">Formula max deviation:</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" step=".1" min="1" max="10" class="form-control" name="formula-max-deviation" id="formula-max-deviation">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(1 - 10) - default 1.6 SG - max deviation value when checking formula</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="int-http1" class="col-sm-3 col-form-label">Skip interval - HTTP 1 (POST):</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="0" max="5" class="form-control" name="int-http1" id="int-http1">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(0 - 5) skips a number of sleep cycles before pushing data</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="int-http2" class="col-sm-3 col-form-label">Skip interval - HTTP 2 (POST):</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="0" max="5" class="form-control" name="int-http2" id="int-http2">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(0 - 5) skips a number of sleep cycles before pushing data</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="int-http3" class="col-sm-3 col-form-label">Skip interval - HTTP 3 (GET):</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="0" max="5" class="form-control" name="int-http3" id="int-http3">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(0 - 5) skips a number of sleep cycles before pushing data</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="int-influx" class="col-sm-3 col-form-label">Skip interval - InfluxDB v2:</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="0" max="5" class="form-control" name="int-influx" id="int-influx">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(0 - 5) skips a number of sleep cycles before pushing data</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="int-mqtt" class="col-sm-3 col-form-label">Skip interval - MQTT:</label>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<input type="number" min="0" max="5" class="form-control" name="int-mqtt" id="int-mqtt">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">(0 - 5) skips a number of sleep cycles before pushing data</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-sm-8 offset-sm-3">
|
||||||
|
<button type="submit" class="btn btn-primary" id="advanced-btn">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -610,6 +700,35 @@
|
|||||||
$("#push-btn2").prop("disabled", b);
|
$("#push-btn2").prop("disabled", b);
|
||||||
$("#format-btn2").prop("disabled", b);
|
$("#format-btn2").prop("disabled", b);
|
||||||
$("#test-btn2").prop("disabled", b);
|
$("#test-btn2").prop("disabled", b);
|
||||||
|
$("#advanced-btn").prop("disabled", b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the advanced values from the API
|
||||||
|
function getAdvancedConfig() {
|
||||||
|
setButtonDisabled( true );
|
||||||
|
|
||||||
|
var url = "/api/config/advanced";
|
||||||
|
//var url = "/test/adv.json";
|
||||||
|
$('#spinner').show();
|
||||||
|
$.getJSON(url, function (cfg) {
|
||||||
|
console.log( cfg );
|
||||||
|
|
||||||
|
$("#gyro-read-count").val(cfg["gyro-read-count"]);
|
||||||
|
$("#gyro-moving-threashold").val(cfg["gyro-moving-threashold"]);
|
||||||
|
$("#formula-max-deviation").val(cfg["formula-max-deviation"]);
|
||||||
|
$("#int-http1").val(cfg["int-http1"]);
|
||||||
|
$("#int-http2").val(cfg["int-http2"]);
|
||||||
|
$("#int-http3").val(cfg["int-http3"]);
|
||||||
|
$("#int-influx").val(cfg["int-influx"]);
|
||||||
|
$("#int-mqtt").val(cfg["int-mqtt"]);
|
||||||
|
})
|
||||||
|
.fail(function () {
|
||||||
|
showError('Unable to get data from the device.');
|
||||||
|
})
|
||||||
|
.always(function() {
|
||||||
|
$('#spinner').hide();
|
||||||
|
setButtonDisabled( false );
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the configuration values from the API
|
// Get the configuration values from the API
|
||||||
@ -632,6 +751,7 @@
|
|||||||
$("#id3").val(cfg["id"]);
|
$("#id3").val(cfg["id"]);
|
||||||
$("#id4").val(cfg["id"]);
|
$("#id4").val(cfg["id"]);
|
||||||
$("#id5").val(cfg["id"]);
|
$("#id5").val(cfg["id"]);
|
||||||
|
$("#id6").val(cfg["id"]);
|
||||||
$("#mdns").val(cfg["mdns"]);
|
$("#mdns").val(cfg["mdns"]);
|
||||||
if( cfg["temp-format"] == "C" ) $("#temp-format-c").click();
|
if( cfg["temp-format"] == "C" ) $("#temp-format-c").click();
|
||||||
else $("#temp-format-f").click();
|
else $("#temp-format-f").click();
|
||||||
@ -671,9 +791,10 @@
|
|||||||
showError('Unable to get data from the device.');
|
showError('Unable to get data from the device.');
|
||||||
})
|
})
|
||||||
.always(function() {
|
.always(function() {
|
||||||
$('#spinner').hide();
|
//$('#spinner').hide();
|
||||||
setButtonDisabled( false );
|
//setButtonDisabled( false );
|
||||||
updateSleepInfo();
|
updateSleepInfo();
|
||||||
|
getAdvancedConfig();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -95,7 +95,7 @@ int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
|||||||
double dev = (g - fd.g[i]) < 0 ? (fd.g[i] - g) : (g - fd.g[i]);
|
double dev = (g - fd.g[i]) < 0 ? (fd.g[i] - g) : (g - fd.g[i]);
|
||||||
|
|
||||||
// If the deviation is more than 2 degress we mark it as failed.
|
// If the deviation is more than 2 degress we mark it as failed.
|
||||||
if (dev * 1000 > myHardwareConfig.getMaxFormulaCreationDeviation()) {
|
if (dev * 1000 > myAdvancedConfig.getMaxFormulaCreationDeviation()) {
|
||||||
char s[20];
|
char s[20];
|
||||||
snprintf(&s[0], sizeof(s), "%.8f", dev);
|
snprintf(&s[0], sizeof(s), "%.8f", dev);
|
||||||
Log.error(F("CALC: Deviation to large: %s" CR), &s[0]);
|
Log.error(F("CALC: Deviation to large: %s" CR), &s[0]);
|
||||||
|
@ -34,7 +34,7 @@ double calculateGravity(double angle, double tempC,
|
|||||||
const char *tempFormula = 0);
|
const char *tempFormula = 0);
|
||||||
double gravityTemperatureCorrectionC(
|
double gravityTemperatureCorrectionC(
|
||||||
double gravity, double tempC,
|
double gravity, double tempC,
|
||||||
double calTempC = myHardwareConfig.getDefaultCalibrationTemp());
|
double calTempC = myAdvancedConfig.getDefaultCalibrationTemp());
|
||||||
int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
int createFormula(RawFormulaData &fd, char *formulaBuffer,
|
||||||
int formulaBufferSize, int order);
|
int formulaBufferSize, int order);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
Config myConfig;
|
Config myConfig;
|
||||||
HardwareConfig myHardwareConfig;
|
AdvancedConfig myAdvancedConfig;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create the config class with default settings.
|
// Create the config class with default settings.
|
||||||
@ -359,7 +359,7 @@ void Config::checkFileSystem() {
|
|||||||
//
|
//
|
||||||
// Save json document to file
|
// Save json document to file
|
||||||
//
|
//
|
||||||
bool HardwareConfig::saveFile() {
|
bool AdvancedConfig::saveFile() {
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
Log.verbose(F("CFG : Saving hardware configuration to file." CR));
|
Log.verbose(F("CFG : Saving hardware configuration to file." CR));
|
||||||
#endif
|
#endif
|
||||||
@ -380,6 +380,11 @@ bool HardwareConfig::saveFile() {
|
|||||||
doc[PARAM_HW_FORMULA_DEVIATION] = this->getMaxFormulaCreationDeviation();
|
doc[PARAM_HW_FORMULA_DEVIATION] = this->getMaxFormulaCreationDeviation();
|
||||||
doc[PARAM_HW_WIFI_PORTALTIMEOUT] = this->getWifiPortalTimeout();
|
doc[PARAM_HW_WIFI_PORTALTIMEOUT] = this->getWifiPortalTimeout();
|
||||||
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] = this->getDefaultCalibrationTemp();
|
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] = this->getDefaultCalibrationTemp();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP1] = this->getPushIntervalHttp1();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP2] = this->getPushIntervalHttp2();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = this->getPushIntervalHttp3();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_INFLUX] = this->getPushIntervalInflux();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_MQTT] = this->getPushIntervalMqtt();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, Serial);
|
||||||
@ -397,7 +402,7 @@ bool HardwareConfig::saveFile() {
|
|||||||
//
|
//
|
||||||
// Load config file from disk
|
// Load config file from disk
|
||||||
//
|
//
|
||||||
bool HardwareConfig::loadFile() {
|
bool AdvancedConfig::loadFile() {
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
Log.verbose(F("CFG : Loading hardware configuration from file." CR));
|
Log.verbose(F("CFG : Loading hardware configuration from file." CR));
|
||||||
#endif
|
#endif
|
||||||
@ -454,6 +459,16 @@ bool HardwareConfig::loadFile() {
|
|||||||
this->setWifiPortalTimeout(doc[PARAM_HW_WIFI_PORTALTIMEOUT].as<int>());
|
this->setWifiPortalTimeout(doc[PARAM_HW_WIFI_PORTALTIMEOUT].as<int>());
|
||||||
if (!doc[PARAM_HW_PUSH_TIMEOUT].isNull())
|
if (!doc[PARAM_HW_PUSH_TIMEOUT].isNull())
|
||||||
this->setPushTimeout(doc[PARAM_HW_PUSH_TIMEOUT].as<int>());
|
this->setPushTimeout(doc[PARAM_HW_PUSH_TIMEOUT].as<int>());
|
||||||
|
if (!doc[PARAM_HW_PUSH_INTERVAL_HTTP1].isNull())
|
||||||
|
this->setPushIntervalHttp1(doc[PARAM_HW_PUSH_INTERVAL_HTTP1].as<int>());
|
||||||
|
if (!doc[PARAM_HW_PUSH_INTERVAL_HTTP2].isNull())
|
||||||
|
this->setPushIntervalHttp2(doc[PARAM_HW_PUSH_INTERVAL_HTTP2].as<int>());
|
||||||
|
if (!doc[PARAM_HW_PUSH_INTERVAL_HTTP3].isNull())
|
||||||
|
this->setPushIntervalHttp3(doc[PARAM_HW_PUSH_INTERVAL_HTTP3].as<int>());
|
||||||
|
if (!doc[PARAM_HW_PUSH_INTERVAL_INFLUX].isNull())
|
||||||
|
this->setPushIntervalInflux(doc[PARAM_HW_PUSH_INTERVAL_INFLUX].as<int>());
|
||||||
|
if (!doc[PARAM_HW_PUSH_INTERVAL_MQTT].isNull())
|
||||||
|
this->setPushIntervalMqtt(doc[PARAM_HW_PUSH_INTERVAL_MQTT].as<int>());
|
||||||
|
|
||||||
Log.notice(F("CFG : Configuration file " CFG_HW_FILENAME " loaded." CR));
|
Log.notice(F("CFG : Configuration file " CFG_HW_FILENAME " loaded." CR));
|
||||||
return true;
|
return true;
|
||||||
|
@ -54,7 +54,7 @@ struct RawFormulaData {
|
|||||||
double g[FORMULA_DATA_SIZE];
|
double g[FORMULA_DATA_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
class HardwareConfig {
|
class AdvancedConfig {
|
||||||
private:
|
private:
|
||||||
int _wifiPortalTimeout = 120;
|
int _wifiPortalTimeout = 120;
|
||||||
float _maxFormulaCreationDeviation = 1.6;
|
float _maxFormulaCreationDeviation = 1.6;
|
||||||
@ -63,27 +63,55 @@ class HardwareConfig {
|
|||||||
int _gyroReadCount = 50;
|
int _gyroReadCount = 50;
|
||||||
int _gyroReadDelay = 3150; // us, empirical, to hold sampling to 200 Hz
|
int _gyroReadDelay = 3150; // us, empirical, to hold sampling to 200 Hz
|
||||||
int _pushTimeout = 10; // seconds
|
int _pushTimeout = 10; // seconds
|
||||||
|
int _pushIntervalHttp1 = 0;
|
||||||
|
int _pushIntervalHttp2 = 0;
|
||||||
|
int _pushIntervalHttp3 = 0;
|
||||||
|
int _pushIntervalInflux = 0;
|
||||||
|
int _pushIntervalMqtt = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int getWifiPortalTimeout() { return _wifiPortalTimeout; }
|
int getWifiPortalTimeout() { return _wifiPortalTimeout; }
|
||||||
void setWifiPortalTimeout(int t) { _wifiPortalTimeout = t; }
|
void setWifiPortalTimeout(int t) { _wifiPortalTimeout = t; }
|
||||||
|
|
||||||
float getMaxFormulaCreationDeviation() {
|
float getMaxFormulaCreationDeviation() {
|
||||||
return _maxFormulaCreationDeviation;
|
return _maxFormulaCreationDeviation;
|
||||||
}
|
}
|
||||||
void setMaxFormulaCreationDeviation(float f) {
|
void setMaxFormulaCreationDeviation(float f) {
|
||||||
_maxFormulaCreationDeviation = f;
|
_maxFormulaCreationDeviation = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDefaultCalibrationTemp() { return _defaultCalibrationTemp; }
|
float getDefaultCalibrationTemp() { return _defaultCalibrationTemp; }
|
||||||
void SetDefaultCalibrationTemp(float t) { _defaultCalibrationTemp = t; }
|
void SetDefaultCalibrationTemp(float t) { _defaultCalibrationTemp = t; }
|
||||||
|
|
||||||
int getGyroSensorMovingThreashold() { return _gyroSensorMovingThreashold; }
|
int getGyroSensorMovingThreashold() { return _gyroSensorMovingThreashold; }
|
||||||
void setGyroSensorMovingThreashold(int t) { _gyroSensorMovingThreashold = t; }
|
void setGyroSensorMovingThreashold(int t) { _gyroSensorMovingThreashold = t; }
|
||||||
|
|
||||||
int getGyroReadCount() { return _gyroReadCount; }
|
int getGyroReadCount() { return _gyroReadCount; }
|
||||||
void setGyroReadCount(int c) { _gyroReadCount = c; }
|
void setGyroReadCount(int c) { _gyroReadCount = c; }
|
||||||
|
|
||||||
int getGyroReadDelay() { return _gyroReadDelay; }
|
int getGyroReadDelay() { return _gyroReadDelay; }
|
||||||
void setGyroReadDelay(int d) { _gyroReadDelay = d; }
|
void setGyroReadDelay(int d) { _gyroReadDelay = d; }
|
||||||
|
|
||||||
int getPushTimeout() { return _pushTimeout; }
|
int getPushTimeout() { return _pushTimeout; }
|
||||||
void setPushTimeout(int t) { _pushTimeout = t; }
|
void setPushTimeout(int t) { _pushTimeout = t; }
|
||||||
|
|
||||||
|
int getPushIntervalHttp1() { return _pushIntervalHttp1; }
|
||||||
|
void setPushIntervalHttp1(int t) { _pushIntervalHttp1 = t; }
|
||||||
|
|
||||||
|
int getPushIntervalHttp2() { return _pushIntervalHttp2; }
|
||||||
|
void setPushIntervalHttp2(int t) { _pushIntervalHttp2 = t; }
|
||||||
|
|
||||||
|
int getPushIntervalHttp3() { return _pushIntervalHttp3; }
|
||||||
|
void setPushIntervalHttp3(int t) { _pushIntervalHttp3 = t; }
|
||||||
|
|
||||||
|
int getPushIntervalInflux() { return _pushIntervalInflux; }
|
||||||
|
void setPushIntervalInflux(int t) { _pushIntervalInflux = t; }
|
||||||
|
|
||||||
|
int getPushIntervalMqtt() { return _pushIntervalMqtt; }
|
||||||
|
void setPushIntervalMqtt(int t) { _pushIntervalMqtt = t; }
|
||||||
|
|
||||||
|
bool isPushIntervalActive() { return (_pushIntervalHttp1+_pushIntervalHttp2+_pushIntervalHttp3+_pushIntervalInflux+_pushIntervalMqtt) == 0 ? false : true; }
|
||||||
|
|
||||||
bool saveFile();
|
bool saveFile();
|
||||||
bool loadFile();
|
bool loadFile();
|
||||||
};
|
};
|
||||||
@ -379,7 +407,7 @@ class Config {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern Config myConfig;
|
extern Config myConfig;
|
||||||
extern HardwareConfig myHardwareConfig;
|
extern AdvancedConfig myAdvancedConfig;
|
||||||
|
|
||||||
#endif // SRC_CONFIG_HPP_
|
#endif // SRC_CONFIG_HPP_
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ bool GyroSensor::isSensorMoving(RawGyroData &raw) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int x = abs(raw.gx), y = abs(raw.gy), z = abs(raw.gz);
|
int x = abs(raw.gx), y = abs(raw.gy), z = abs(raw.gz);
|
||||||
int threashold = myHardwareConfig.getGyroSensorMovingThreashold();
|
int threashold = myAdvancedConfig.getGyroSensorMovingThreashold();
|
||||||
|
|
||||||
if (x > threashold || y > threashold || z > threashold) {
|
if (x > threashold || y > threashold || z > threashold) {
|
||||||
Log.notice(F("GYRO: Movement detected (%d)\t%d\t%d\t%d." CR), threashold, x,
|
Log.notice(F("GYRO: Movement detected (%d)\t%d\t%d\t%d." CR), threashold, x,
|
||||||
@ -239,8 +239,8 @@ bool GyroSensor::read() {
|
|||||||
if (!_sensorConnected) return false;
|
if (!_sensorConnected) return false;
|
||||||
|
|
||||||
readSensor(
|
readSensor(
|
||||||
_lastGyroData, myHardwareConfig.getGyroReadCount(),
|
_lastGyroData, myAdvancedConfig.getGyroReadCount(),
|
||||||
myHardwareConfig.getGyroReadDelay()); // Last param is unused if
|
myAdvancedConfig.getGyroReadDelay()); // Last param is unused if
|
||||||
// GYRO_USE_INTERRUPT is defined.
|
// GYRO_USE_INTERRUPT is defined.
|
||||||
|
|
||||||
// If the sensor is unstable we return false to signal we dont have valid
|
// If the sensor is unstable we return false to signal we dont have valid
|
||||||
|
@ -138,7 +138,7 @@ void setup() {
|
|||||||
myConfig.checkFileSystem();
|
myConfig.checkFileSystem();
|
||||||
myConfig.loadFile();
|
myConfig.loadFile();
|
||||||
myWifi.init();
|
myWifi.init();
|
||||||
myHardwareConfig.loadFile();
|
myAdvancedConfig.loadFile();
|
||||||
LOG_PERF_STOP("main-config-load");
|
LOG_PERF_STOP("main-config-load");
|
||||||
|
|
||||||
// Setup watchdog
|
// Setup watchdog
|
||||||
|
@ -32,6 +32,74 @@ SOFTWARE.
|
|||||||
#include <pushtarget.hpp>
|
#include <pushtarget.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
|
#define PUSHINT_FILENAME "/push.dat"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decrease counters
|
||||||
|
//
|
||||||
|
void PushIntervalTracker::update(const int index, const int defaultValue) {
|
||||||
|
if (_counters[index] <= 0)
|
||||||
|
_counters[index] = defaultValue;
|
||||||
|
else
|
||||||
|
_counters[index]--;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Load data from file
|
||||||
|
//
|
||||||
|
void PushIntervalTracker::load() {
|
||||||
|
File intFile = LittleFS.open(PUSHINT_FILENAME, "r");
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (intFile) {
|
||||||
|
String line = intFile.readStringUntil('\n');
|
||||||
|
Log.notice(F("PUSH: Read interval tracker %s." CR), line.c_str());
|
||||||
|
|
||||||
|
char temp[80];
|
||||||
|
char *s, *p = &temp[0];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
snprintf(&temp[0], sizeof(temp), "%s", line.c_str());
|
||||||
|
while ((s = strtok_r(p, ":", &p)) != NULL) {
|
||||||
|
_counters[i++] = atoi(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
intFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(PUSH_DISABLE_LOGGING)
|
||||||
|
Log.verbose(F("PUSH: Parsed trackers: %d:%d:%d:%d:%d." CR), _counters[0], _counters[1], _counters[2], _counters[3], _counters[4] );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update and save counters
|
||||||
|
//
|
||||||
|
void PushIntervalTracker::save() {
|
||||||
|
update(0, myAdvancedConfig.getPushIntervalHttp1());
|
||||||
|
update(1, myAdvancedConfig.getPushIntervalHttp2());
|
||||||
|
update(2, myAdvancedConfig.getPushIntervalHttp3());
|
||||||
|
update(3, myAdvancedConfig.getPushIntervalInflux());
|
||||||
|
update(4, myAdvancedConfig.getPushIntervalMqtt());
|
||||||
|
|
||||||
|
// If this feature is disabled we skip saving the file
|
||||||
|
if (!myAdvancedConfig.isPushIntervalActive()) {
|
||||||
|
#if !defined(PUSH_DISABLE_LOGGING)
|
||||||
|
Log.notice(F("PUSH: Variabled push interval disabled." CR));
|
||||||
|
#endif
|
||||||
|
LittleFS.remove(PUSHINT_FILENAME);
|
||||||
|
} else {
|
||||||
|
Log.notice(F("PUSH: Variabled push interval enabled, updating counters." CR));
|
||||||
|
File intFile = LittleFS.open(PUSHINT_FILENAME, "w");
|
||||||
|
|
||||||
|
if (intFile) {
|
||||||
|
// Format=http1:http2:http3:influx:mqtt
|
||||||
|
intFile.printf("%d:%d:%d:%d:%d\n", _counters[0], _counters[1], _counters[2], _counters[3], _counters[4] );
|
||||||
|
intFile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Send the data to targets
|
// Send the data to targets
|
||||||
//
|
//
|
||||||
@ -44,35 +112,40 @@ void PushTarget::sendAll(float angle, float gravitySG, float corrGravitySG,
|
|||||||
TemplatingEngine engine;
|
TemplatingEngine engine;
|
||||||
engine.initialize(angle, gravitySG, corrGravitySG, tempC, runTime);
|
engine.initialize(angle, gravitySG, corrGravitySG, tempC, runTime);
|
||||||
|
|
||||||
if (myConfig.isHttpActive()) {
|
PushIntervalTracker intDelay;
|
||||||
|
intDelay.load();
|
||||||
|
|
||||||
|
if (myConfig.isHttpActive() && intDelay.useHttp1()) {
|
||||||
LOG_PERF_START("push-http");
|
LOG_PERF_START("push-http");
|
||||||
sendHttpPost(engine, myConfig.isHttpSSL(), 0);
|
sendHttpPost(engine, myConfig.isHttpSSL(), 0);
|
||||||
LOG_PERF_STOP("push-http");
|
LOG_PERF_STOP("push-http");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myConfig.isHttp2Active()) {
|
if (myConfig.isHttp2Active() && intDelay.useHttp2()) {
|
||||||
LOG_PERF_START("push-http2");
|
LOG_PERF_START("push-http2");
|
||||||
sendHttpPost(engine, myConfig.isHttp2SSL(), 1);
|
sendHttpPost(engine, myConfig.isHttp2SSL(), 1);
|
||||||
LOG_PERF_STOP("push-http2");
|
LOG_PERF_STOP("push-http2");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myConfig.isHttp3Active()) {
|
if (myConfig.isHttp3Active() && intDelay.useHttp3()) {
|
||||||
LOG_PERF_START("push-http3");
|
LOG_PERF_START("push-http3");
|
||||||
sendHttpGet(engine, myConfig.isHttp3SSL());
|
sendHttpGet(engine, myConfig.isHttp3SSL());
|
||||||
LOG_PERF_STOP("push-http3");
|
LOG_PERF_STOP("push-http3");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myConfig.isInfluxDb2Active()) {
|
if (myConfig.isInfluxDb2Active() && intDelay.useInflux()) {
|
||||||
LOG_PERF_START("push-influxdb2");
|
LOG_PERF_START("push-influxdb2");
|
||||||
sendInfluxDb2(engine, myConfig.isInfluxSSL());
|
sendInfluxDb2(engine, myConfig.isInfluxSSL());
|
||||||
LOG_PERF_STOP("push-influxdb2");
|
LOG_PERF_STOP("push-influxdb2");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myConfig.isMqttActive()) {
|
if (myConfig.isMqttActive() && intDelay.useMqtt()) {
|
||||||
LOG_PERF_START("push-mqtt");
|
LOG_PERF_START("push-mqtt");
|
||||||
sendMqtt(engine, myConfig.isMqttSSL());
|
sendMqtt(engine, myConfig.isMqttSSL());
|
||||||
LOG_PERF_STOP("push-mqtt");
|
LOG_PERF_STOP("push-mqtt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
intDelay.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -109,11 +182,11 @@ void PushTarget::sendInfluxDb2(TemplatingEngine& engine, bool isSecure) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_httpSecure.begin(_wifiSecure, serverPath);
|
_httpSecure.begin(_wifiSecure, serverPath);
|
||||||
_httpSecure.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_httpSecure.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
_lastCode = _httpSecure.POST(doc);
|
_lastCode = _httpSecure.POST(doc);
|
||||||
} else {
|
} else {
|
||||||
_http.begin(_wifi, serverPath);
|
_http.begin(_wifi, serverPath);
|
||||||
_http.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_http.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
_lastCode = _http.POST(doc);
|
_lastCode = _http.POST(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +282,7 @@ void PushTarget::sendHttpPost(TemplatingEngine& engine, bool isSecure,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_httpSecure.begin(_wifiSecure, serverPath);
|
_httpSecure.begin(_wifiSecure, serverPath);
|
||||||
_httpSecure.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_httpSecure.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
addHttpHeader(_httpSecure, myConfig.getHttpHeader(0));
|
addHttpHeader(_httpSecure, myConfig.getHttpHeader(0));
|
||||||
@ -222,7 +295,7 @@ void PushTarget::sendHttpPost(TemplatingEngine& engine, bool isSecure,
|
|||||||
_lastCode = _httpSecure.POST(doc);
|
_lastCode = _httpSecure.POST(doc);
|
||||||
} else {
|
} else {
|
||||||
_http.begin(_wifi, serverPath);
|
_http.begin(_wifi, serverPath);
|
||||||
_http.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_http.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
addHttpHeader(_http, myConfig.getHttpHeader(0));
|
addHttpHeader(_http, myConfig.getHttpHeader(0));
|
||||||
@ -291,11 +364,11 @@ void PushTarget::sendHttpGet(TemplatingEngine& engine, bool isSecure) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_httpSecure.begin(_wifiSecure, serverPath);
|
_httpSecure.begin(_wifiSecure, serverPath);
|
||||||
_httpSecure.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_httpSecure.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
_lastCode = _httpSecure.GET();
|
_lastCode = _httpSecure.GET();
|
||||||
} else {
|
} else {
|
||||||
_http.begin(_wifi, serverPath);
|
_http.begin(_wifi, serverPath);
|
||||||
_http.setTimeout(myHardwareConfig.getPushTimeout() * 1000);
|
_http.setTimeout(myAdvancedConfig.getPushTimeout() * 1000);
|
||||||
_lastCode = _http.GET();
|
_lastCode = _http.GET();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +430,7 @@ void PushTarget::sendMqtt(TemplatingEngine& engine, bool isSecure) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Send MQQT message(s)
|
// Send MQQT message(s)
|
||||||
mqtt.setTimeout(myHardwareConfig.getPushTimeout()); // 10 seconds timeout
|
mqtt.setTimeout(myAdvancedConfig.getPushTimeout()); // 10 seconds timeout
|
||||||
|
|
||||||
int lines = 1;
|
int lines = 1;
|
||||||
// Find out how many lines are in the document. Each line is one
|
// Find out how many lines are in the document. Each line is one
|
||||||
|
@ -65,6 +65,21 @@ class PushTarget {
|
|||||||
bool getLastSuccess() { return _lastSuccess; }
|
bool getLastSuccess() { return _lastSuccess; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PushIntervalTracker {
|
||||||
|
private:
|
||||||
|
int _counters[5] = { 0, 0, 0, 0, 0 };
|
||||||
|
void update(const int index, const int defaultValue);
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool useHttp1() { return _counters[0] == 0 ? true : false; }
|
||||||
|
bool useHttp2() { return _counters[1] == 0 ? true : false; }
|
||||||
|
bool useHttp3() { return _counters[2] == 0 ? true : false; }
|
||||||
|
bool useInflux() { return _counters[3] == 0 ? true : false; }
|
||||||
|
bool useMqtt() { return _counters[4] == 0 ? true : false; }
|
||||||
|
void load();
|
||||||
|
void save();
|
||||||
|
};
|
||||||
|
|
||||||
#endif // SRC_PUSHTARGET_HPP_
|
#endif // SRC_PUSHTARGET_HPP_
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -81,6 +81,11 @@ SOFTWARE.
|
|||||||
#define PARAM_HW_FORMULA_CALIBRATION_TEMP "formula-calibration-temp"
|
#define PARAM_HW_FORMULA_CALIBRATION_TEMP "formula-calibration-temp"
|
||||||
#define PARAM_HW_WIFI_PORTALTIMEOUT "wifi-portaltimeout"
|
#define PARAM_HW_WIFI_PORTALTIMEOUT "wifi-portaltimeout"
|
||||||
#define PARAM_HW_PUSH_TIMEOUT "push-timeout"
|
#define PARAM_HW_PUSH_TIMEOUT "push-timeout"
|
||||||
|
#define PARAM_HW_PUSH_INTERVAL_HTTP1 "int-http1"
|
||||||
|
#define PARAM_HW_PUSH_INTERVAL_HTTP2 "int-http2"
|
||||||
|
#define PARAM_HW_PUSH_INTERVAL_HTTP3 "int-http3"
|
||||||
|
#define PARAM_HW_PUSH_INTERVAL_INFLUX "int-influx"
|
||||||
|
#define PARAM_HW_PUSH_INTERVAL_MQTT "int-mqtt"
|
||||||
#define PARAM_FORMAT_HTTP1 "http-1"
|
#define PARAM_FORMAT_HTTP1 "http-1"
|
||||||
#define PARAM_FORMAT_HTTP2 "http-2"
|
#define PARAM_FORMAT_HTTP2 "http-2"
|
||||||
#define PARAM_FORMAT_HTTP3 "http-3"
|
#define PARAM_FORMAT_HTTP3 "http-3"
|
||||||
|
@ -622,18 +622,18 @@ void WebServerHandler::webHandleConfigHardware() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update device parameters.
|
// Update advanced settings.
|
||||||
//
|
//
|
||||||
void WebServerHandler::webHandleDeviceParam() {
|
void WebServerHandler::webHandleConfigAdvancedWrite() {
|
||||||
LOG_PERF_START("webserver-api-device-param");
|
LOG_PERF_START("webserver-api-config-advanced");
|
||||||
String id = _server->arg(PARAM_ID);
|
String id = _server->arg(PARAM_ID);
|
||||||
Log.notice(F("WEB : webServer callback for /api/device/param(post)." CR));
|
Log.notice(F("WEB : webServer callback for /api/config/advaced(post)." CR));
|
||||||
|
|
||||||
if (!id.equalsIgnoreCase(myConfig.getID())) {
|
if (!id.equalsIgnoreCase(myConfig.getID())) {
|
||||||
Log.error(F("WEB : Wrong ID received %s, expected %s" CR), id.c_str(),
|
Log.error(F("WEB : Wrong ID received %s, expected %s" CR), id.c_str(),
|
||||||
myConfig.getID());
|
myConfig.getID());
|
||||||
_server->send(400, "text/plain", "Invalid ID.");
|
_server->send(400, "text/plain", "Invalid ID.");
|
||||||
LOG_PERF_STOP("webserver-api-device-param");
|
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,41 +641,61 @@ void WebServerHandler::webHandleDeviceParam() {
|
|||||||
Log.verbose(F("WEB : %s." CR), getRequestArguments().c_str());
|
Log.verbose(F("WEB : %s." CR), getRequestArguments().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < _server->args(); i++) {
|
if (_server->hasArg(PARAM_HW_GYRO_READ_COUNT))
|
||||||
String s = _server->arg(i);
|
myAdvancedConfig.setGyroReadCount(_server->arg(PARAM_HW_GYRO_READ_COUNT).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_GYRO_READ_DELAY))
|
||||||
|
myAdvancedConfig.setGyroReadDelay(_server->arg(PARAM_HW_GYRO_READ_DELAY).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_GYRO_MOVING_THREASHOLD))
|
||||||
|
myAdvancedConfig.setGyroSensorMovingThreashold(_server->arg(PARAM_HW_GYRO_MOVING_THREASHOLD).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_FORMULA_DEVIATION))
|
||||||
|
myAdvancedConfig.setMaxFormulaCreationDeviation(_server->arg(PARAM_HW_FORMULA_DEVIATION).toFloat());
|
||||||
|
if (_server->hasArg(PARAM_HW_FORMULA_CALIBRATION_TEMP))
|
||||||
|
myAdvancedConfig.SetDefaultCalibrationTemp(_server->arg(PARAM_HW_FORMULA_CALIBRATION_TEMP).toFloat());
|
||||||
|
if (_server->hasArg(PARAM_HW_WIFI_PORTALTIMEOUT))
|
||||||
|
myAdvancedConfig.setWifiPortalTimeout(_server->arg(PARAM_HW_WIFI_PORTALTIMEOUT).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_TIMEOUT))
|
||||||
|
myAdvancedConfig.setPushTimeout(_server->arg(PARAM_HW_PUSH_TIMEOUT).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_HTTP1))
|
||||||
|
myAdvancedConfig.setPushIntervalHttp1(_server->arg(PARAM_HW_PUSH_INTERVAL_HTTP1).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_HTTP2))
|
||||||
|
myAdvancedConfig.setPushIntervalHttp2(_server->arg(PARAM_HW_PUSH_INTERVAL_HTTP2).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_HTTP3))
|
||||||
|
myAdvancedConfig.setPushIntervalHttp3(_server->arg(PARAM_HW_PUSH_INTERVAL_HTTP3).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_INFLUX))
|
||||||
|
myAdvancedConfig.setPushIntervalInflux(_server->arg(PARAM_HW_PUSH_INTERVAL_INFLUX).toInt());
|
||||||
|
if (_server->hasArg(PARAM_HW_PUSH_INTERVAL_MQTT))
|
||||||
|
myAdvancedConfig.setPushIntervalMqtt(_server->arg(PARAM_HW_PUSH_INTERVAL_MQTT).toInt());
|
||||||
|
|
||||||
if (_server->argName(i).equalsIgnoreCase(PARAM_HW_GYRO_READ_COUNT))
|
myAdvancedConfig.saveFile();
|
||||||
myHardwareConfig.setGyroReadCount(s.toInt());
|
_server->sendHeader("Location", "/config.htm#collapseAdvanced", true);
|
||||||
else if (_server->argName(i).equalsIgnoreCase(PARAM_HW_GYRO_READ_DELAY))
|
_server->send(302, "text/plain", "Advanced config updated");
|
||||||
myHardwareConfig.setGyroReadDelay(s.toInt());
|
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||||
else if (_server->argName(i).equalsIgnoreCase(
|
|
||||||
PARAM_HW_GYRO_MOVING_THREASHOLD))
|
|
||||||
myHardwareConfig.setGyroSensorMovingThreashold(s.toInt());
|
|
||||||
else if (_server->argName(i).equalsIgnoreCase(PARAM_HW_FORMULA_DEVIATION))
|
|
||||||
myHardwareConfig.setMaxFormulaCreationDeviation(s.toFloat());
|
|
||||||
else if (_server->argName(i).equalsIgnoreCase(
|
|
||||||
PARAM_HW_FORMULA_CALIBRATION_TEMP))
|
|
||||||
myHardwareConfig.SetDefaultCalibrationTemp(s.toFloat());
|
|
||||||
else if (_server->argName(i).equalsIgnoreCase(PARAM_HW_WIFI_PORTALTIMEOUT))
|
|
||||||
myHardwareConfig.setWifiPortalTimeout(s.toInt());
|
|
||||||
else if (_server->argName(i).equalsIgnoreCase(PARAM_HW_PUSH_TIMEOUT))
|
|
||||||
myHardwareConfig.setPushTimeout(s.toInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myHardwareConfig.saveFile();
|
|
||||||
|
|
||||||
// Return the current configuration.
|
//
|
||||||
|
// Read advanced settings
|
||||||
|
//
|
||||||
|
void WebServerHandler::webHandleConfigAdvancedRead() {
|
||||||
|
LOG_PERF_START("webserver-api-config-advanced");
|
||||||
|
Log.notice(F("WEB : webServer callback for /api/config/advanced(get)." CR));
|
||||||
|
|
||||||
DynamicJsonDocument doc(512);
|
DynamicJsonDocument doc(512);
|
||||||
|
|
||||||
doc[PARAM_HW_GYRO_READ_COUNT] = myHardwareConfig.getGyroReadCount();
|
doc[PARAM_HW_GYRO_READ_COUNT] = myAdvancedConfig.getGyroReadCount();
|
||||||
doc[PARAM_HW_GYRO_READ_DELAY] = myHardwareConfig.getGyroReadDelay();
|
doc[PARAM_HW_GYRO_READ_DELAY] = myAdvancedConfig.getGyroReadDelay();
|
||||||
doc[PARAM_HW_GYRO_MOVING_THREASHOLD] =
|
doc[PARAM_HW_GYRO_MOVING_THREASHOLD] =
|
||||||
myHardwareConfig.getGyroSensorMovingThreashold();
|
myAdvancedConfig.getGyroSensorMovingThreashold();
|
||||||
doc[PARAM_HW_FORMULA_DEVIATION] =
|
doc[PARAM_HW_FORMULA_DEVIATION] =
|
||||||
myHardwareConfig.getMaxFormulaCreationDeviation();
|
myAdvancedConfig.getMaxFormulaCreationDeviation();
|
||||||
doc[PARAM_HW_WIFI_PORTALTIMEOUT] = myHardwareConfig.getWifiPortalTimeout();
|
doc[PARAM_HW_WIFI_PORTALTIMEOUT] = myAdvancedConfig.getWifiPortalTimeout();
|
||||||
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] =
|
doc[PARAM_HW_FORMULA_CALIBRATION_TEMP] =
|
||||||
myHardwareConfig.getDefaultCalibrationTemp();
|
myAdvancedConfig.getDefaultCalibrationTemp();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP1] = myAdvancedConfig.getPushIntervalHttp1();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP2] = myAdvancedConfig.getPushIntervalHttp2();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_HTTP3] = myAdvancedConfig.getPushIntervalHttp3();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_INFLUX] = myAdvancedConfig.getPushIntervalInflux();
|
||||||
|
doc[PARAM_HW_PUSH_INTERVAL_MQTT] = myAdvancedConfig.getPushIntervalMqtt();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, Serial);
|
||||||
@ -686,7 +706,7 @@ void WebServerHandler::webHandleDeviceParam() {
|
|||||||
out.reserve(512);
|
out.reserve(512);
|
||||||
serializeJson(doc, out);
|
serializeJson(doc, out);
|
||||||
_server->send(200, "application/json", out.c_str());
|
_server->send(200, "application/json", out.c_str());
|
||||||
LOG_PERF_STOP("webserver-api-device-param");
|
LOG_PERF_STOP("webserver-api-config-advanced");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1245,9 +1265,12 @@ bool WebServerHandler::setupWebServer() {
|
|||||||
_server->on("/api/config/format", HTTP_POST,
|
_server->on("/api/config/format", HTTP_POST,
|
||||||
std::bind(&WebServerHandler::webHandleConfigFormatWrite,
|
std::bind(&WebServerHandler::webHandleConfigFormatWrite,
|
||||||
this)); // Change template formats
|
this)); // Change template formats
|
||||||
_server->on("/api/device/param", HTTP_GET,
|
_server->on("/api/config/advanced", HTTP_GET,
|
||||||
std::bind(&WebServerHandler::webHandleDeviceParam,
|
std::bind(&WebServerHandler::webHandleConfigAdvancedRead,
|
||||||
this)); // Change device params
|
this)); // Read advanced settings
|
||||||
|
_server->on("/api/config/advanced", HTTP_POST,
|
||||||
|
std::bind(&WebServerHandler::webHandleConfigAdvancedWrite,
|
||||||
|
this)); // Change advanced params
|
||||||
_server->on("/api/test/push", HTTP_GET,
|
_server->on("/api/test/push", HTTP_GET,
|
||||||
std::bind(&WebServerHandler::webHandleTestPush,
|
std::bind(&WebServerHandler::webHandleTestPush,
|
||||||
this)); //
|
this)); //
|
||||||
|
@ -60,6 +60,8 @@ class WebServerHandler {
|
|||||||
void webHandleConfig();
|
void webHandleConfig();
|
||||||
void webHandleFormulaWrite();
|
void webHandleFormulaWrite();
|
||||||
void webHandleFormulaRead();
|
void webHandleFormulaRead();
|
||||||
|
void webHandleConfigAdvancedRead();
|
||||||
|
void webHandleConfigAdvancedWrite();
|
||||||
void webHandleConfigHardware();
|
void webHandleConfigHardware();
|
||||||
void webHandleConfigGravity();
|
void webHandleConfigGravity();
|
||||||
void webHandleConfigPush();
|
void webHandleConfigPush();
|
||||||
@ -74,7 +76,6 @@ class WebServerHandler {
|
|||||||
void webHandleCalibrate();
|
void webHandleCalibrate();
|
||||||
void webHandleUploadFile();
|
void webHandleUploadFile();
|
||||||
void webHandleUpload();
|
void webHandleUpload();
|
||||||
void webHandleDeviceParam();
|
|
||||||
void webHandlePageNotFound();
|
void webHandlePageNotFound();
|
||||||
|
|
||||||
String readFile(String fname);
|
String readFile(String fname);
|
||||||
|
@ -137,7 +137,7 @@ void WifiConnection::startPortal() {
|
|||||||
myWifiManager->setMinimumSignalQuality(-1);
|
myWifiManager->setMinimumSignalQuality(-1);
|
||||||
myWifiManager->setConfigPortalChannel(0);
|
myWifiManager->setConfigPortalChannel(0);
|
||||||
myWifiManager->setConfigPortalTimeout(
|
myWifiManager->setConfigPortalTimeout(
|
||||||
myHardwareConfig.getWifiPortalTimeout());
|
myAdvancedConfig.getWifiPortalTimeout());
|
||||||
|
|
||||||
String mdns("<p>Default mDNS name is: http://");
|
String mdns("<p>Default mDNS name is: http://");
|
||||||
mdns += myConfig.getMDNS();
|
mdns += myConfig.getMDNS();
|
||||||
|
@ -156,6 +156,35 @@ Retrive the data used for formula calculation data via an HTTP GET command. Payl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GET: /api/config/advanced
|
||||||
|
=========================
|
||||||
|
|
||||||
|
Used for adjusting some internal constants and other advanced settings. Should be used with caution.
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
|
{
|
||||||
|
"gyro-read-count": 50,
|
||||||
|
"gyro-read-delay": 3150,
|
||||||
|
"gyro-moving-threashold": 500,
|
||||||
|
"formula-max-deviation": 1.6,
|
||||||
|
"wifi-portaltimeout": 120,
|
||||||
|
"formula-calibration-temp": 20,
|
||||||
|
"int-http1": 0,
|
||||||
|
"int-http2": 0,
|
||||||
|
"int-http3": 0,
|
||||||
|
"int-influx": 0,
|
||||||
|
"int-mqtt": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
POST: /api/config/advanced
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Same parameters as above.
|
||||||
|
|
||||||
|
Payload should be in standard format used for posting a form
|
||||||
|
|
||||||
|
|
||||||
GET: /api/clearwifi
|
GET: /api/clearwifi
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
@ -275,3 +275,14 @@ This option gives you the possibility to install an new version of the firmware
|
|||||||
:alt: Update firmware
|
:alt: Update firmware
|
||||||
|
|
||||||
|
|
||||||
|
Advanded Settings
|
||||||
|
+++++++++++++++++
|
||||||
|
|
||||||
|
.. image:: images/config5.png
|
||||||
|
:width: 800
|
||||||
|
:alt: Advanced Settings
|
||||||
|
|
||||||
|
* **Header:**
|
||||||
|
|
||||||
|
To be described
|
||||||
|
|
||||||
|
@ -9,10 +9,15 @@ v1.0.0
|
|||||||
* Removed brewfather option (can use standard HTTP options), the old apporach can still be used via changing format template.
|
* Removed brewfather option (can use standard HTTP options), the old apporach can still be used via changing format template.
|
||||||
* Added 5 more points for formula creation, so a total of 10 angles/gravity values can be stored.
|
* Added 5 more points for formula creation, so a total of 10 angles/gravity values can be stored.
|
||||||
* Added function on format page so that it's easy to copy a format template from the docs (simplify service integration).
|
* Added function on format page so that it's easy to copy a format template from the docs (simplify service integration).
|
||||||
* Added https support for Influxdb
|
* Added https support for Influxdb (EXPERIMENTAL NOT YET TESTED)
|
||||||
|
* Added possibility to have variable push intervals for different endpoints.
|
||||||
|
* Added advanced settings to configuration for adjusting some internal values (gyro reads, accepted formula deviation, moving detection).
|
||||||
* Added additional http error codes to troubleshooting documentation
|
* Added additional http error codes to troubleshooting documentation
|
||||||
* BUG: Fixed issue in formula calculation in case there were a gap in the data series
|
* BUG: Fixed issue in formula calculation in case there were a gap in the data series
|
||||||
|
|
||||||
|
* TODO: Fix documentation for advanced settings.
|
||||||
|
* TODO: Update brewfather documentation
|
||||||
|
|
||||||
v0.9.0
|
v0.9.0
|
||||||
------
|
------
|
||||||
* Added one http push target that uses HTTP GET. This can be used with ubidots or blynk api's.
|
* Added one http push target that uses HTTP GET. This can be used with ubidots or blynk api's.
|
||||||
|
13
test/adv.json
Normal file
13
test/adv.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"gyro-read-count": 51,
|
||||||
|
"gyro-read-delay": 3151,
|
||||||
|
"gyro-moving-threashold": 501,
|
||||||
|
"formula-max-deviation": 1.7,
|
||||||
|
"wifi-portaltimeout": 121,
|
||||||
|
"formula-calibration-temp": 21,
|
||||||
|
"int-http1": 1,
|
||||||
|
"int-http2": 2,
|
||||||
|
"int-http3": 3,
|
||||||
|
"int-influx": 4,
|
||||||
|
"int-mqtt": 5
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user