Refactored includes
This commit is contained in:
parent
37a1ca6058
commit
35f66e0458
@ -25,9 +25,7 @@ SOFTWARE.
|
|||||||
#include <tinyexpr.h>
|
#include <tinyexpr.h>
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <main.hpp>
|
||||||
#include <helper.hpp>
|
|
||||||
#include <tempsensor.hpp>
|
|
||||||
|
|
||||||
#define FORMULA_MAX_DEVIATION 1.6
|
#define FORMULA_MAX_DEVIATION 1.6
|
||||||
|
|
||||||
|
@ -24,14 +24,12 @@ SOFTWARE.
|
|||||||
#ifndef SRC_CALC_HPP_
|
#ifndef SRC_CALC_HPP_
|
||||||
#define SRC_CALC_HPP_
|
#define SRC_CALC_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
|
|
||||||
#define ERR_FORMULA_NOTENOUGHVALUES -1
|
#define ERR_FORMULA_NOTENOUGHVALUES -1
|
||||||
#define ERR_FORMULA_INTERNAL -2
|
#define ERR_FORMULA_INTERNAL -2
|
||||||
#define ERR_FORMULA_UNABLETOFFIND -3
|
#define ERR_FORMULA_UNABLETOFFIND -3
|
||||||
|
|
||||||
// Functions
|
|
||||||
double calculateGravity(double angle, double tempC,
|
double calculateGravity(double angle, double tempC,
|
||||||
const char *tempFormula = 0);
|
const char *tempFormula = 0);
|
||||||
double gravityTemperatureCorrectionC(double gravity, double tempC,
|
double gravityTemperatureCorrectionC(double gravity, double tempC,
|
||||||
|
@ -21,10 +21,8 @@ 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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
Config myConfig;
|
Config myConfig;
|
||||||
|
|
||||||
|
@ -24,14 +24,8 @@ SOFTWARE.
|
|||||||
#ifndef SRC_CONFIG_HPP_
|
#ifndef SRC_CONFIG_HPP_
|
||||||
#define SRC_CONFIG_HPP_
|
#define SRC_CONFIG_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
|
||||||
// defintions
|
|
||||||
#define CFG_JSON_BUFSIZE 3192
|
#define CFG_JSON_BUFSIZE 3192
|
||||||
|
|
||||||
#define CFG_APPNAME "GravityMon " // Name of firmware
|
#define CFG_APPNAME "GravityMon " // Name of firmware
|
||||||
@ -43,7 +37,6 @@ SOFTWARE.
|
|||||||
#define WIFI_PORTAL_TIMEOUT \
|
#define WIFI_PORTAL_TIMEOUT \
|
||||||
120 // Number of seconds until the config portal is closed
|
120 // Number of seconds until the config portal is closed
|
||||||
|
|
||||||
// These are used in API + Savefile
|
|
||||||
#define CFG_PARAM_ID "id"
|
#define CFG_PARAM_ID "id"
|
||||||
#define CFG_PARAM_MDNS "mdns" // Device name
|
#define CFG_PARAM_MDNS "mdns" // Device name
|
||||||
#define CFG_PARAM_OTA "ota-url"
|
#define CFG_PARAM_OTA "ota-url"
|
||||||
@ -79,7 +72,6 @@ SOFTWARE.
|
|||||||
#define CFG_PARAM_FORMULA_DATA \
|
#define CFG_PARAM_FORMULA_DATA \
|
||||||
"formula-calculation-data" // Raw data for the formula calculation
|
"formula-calculation-data" // Raw data for the formula calculation
|
||||||
|
|
||||||
// These are used in API's
|
|
||||||
#define CFG_PARAM_APP_NAME "app-name"
|
#define CFG_PARAM_APP_NAME "app-name"
|
||||||
#define CFG_PARAM_APP_VER "app-ver"
|
#define CFG_PARAM_APP_VER "app-ver"
|
||||||
#define CFG_PARAM_ANGLE "angle"
|
#define CFG_PARAM_ANGLE "angle"
|
||||||
@ -110,7 +102,6 @@ struct RawFormulaData {
|
|||||||
double g[5];
|
double g[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Main configuration class
|
|
||||||
class Config {
|
class Config {
|
||||||
private:
|
private:
|
||||||
bool _saveNeeded;
|
bool _saveNeeded;
|
||||||
@ -348,7 +339,6 @@ class Config {
|
|||||||
void setSaveNeeded() { _saveNeeded = true; }
|
void setSaveNeeded() { _saveNeeded = true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern Config myConfig;
|
extern Config myConfig;
|
||||||
|
|
||||||
#endif // SRC_CONFIG_HPP_
|
#endif // SRC_CONFIG_HPP_
|
||||||
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
GyroSensor myGyro;
|
GyroSensor myGyro;
|
||||||
MPU6050 accelgyro;
|
MPU6050 accelgyro;
|
||||||
@ -46,7 +46,7 @@ bool GyroSensor::setup() {
|
|||||||
Wire.begin(D3, D4);
|
Wire.begin(D3, D4);
|
||||||
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having
|
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having
|
||||||
// compilation difficulties
|
// compilation difficulties
|
||||||
|
|
||||||
if (!accelgyro.testConnection()) {
|
if (!accelgyro.testConnection()) {
|
||||||
Log.error(F("GYRO: Failed to connect to MPU6050 (gyro)." CR));
|
Log.error(F("GYRO: Failed to connect to MPU6050 (gyro)." CR));
|
||||||
_sensorConnected = false;
|
_sensorConnected = false;
|
||||||
@ -260,7 +260,8 @@ bool GyroSensor::read() {
|
|||||||
|
|
||||||
// The first read value is close to the DS18 value according to my tests, if
|
// The first read value is close to the DS18 value according to my tests, if
|
||||||
// more reads are done then the gyro temp will increase to much
|
// more reads are done then the gyro temp will increase to much
|
||||||
if (_initialSensorTemp == INVALID_TEMPERATURE) _initialSensorTemp = _sensorTemp;
|
if (_initialSensorTemp == INVALID_TEMPERATURE)
|
||||||
|
_initialSensorTemp = _sensorTemp;
|
||||||
|
|
||||||
return _validValue;
|
return _validValue;
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,10 @@ SOFTWARE.
|
|||||||
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
#define I2CDEV_IMPLEMENTATION I2CDEV_ARDUINO_WIRE
|
||||||
// #define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_SBWIRE
|
// #define I2CDEV_IMPLEMENTATION I2CDEV_BUILTIN_SBWIRE
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <MPU6050.h>
|
#include <MPU6050.h>
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
|
|
||||||
// Classes
|
|
||||||
struct RawGyroDataL { // Used for average multiple readings
|
struct RawGyroDataL { // Used for average multiple readings
|
||||||
int32_t ax; // Raw Acceleration
|
int32_t ax; // Raw Acceleration
|
||||||
int32_t ay;
|
int32_t ay;
|
||||||
@ -80,7 +77,6 @@ class GyroSensor {
|
|||||||
void enterSleep();
|
void enterSleep();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern GyroSensor myGyro;
|
extern GyroSensor myGyro;
|
||||||
|
|
||||||
#endif // SRC_GYRO_HPP_
|
#endif // SRC_GYRO_HPP_
|
||||||
|
@ -24,8 +24,10 @@ SOFTWARE.
|
|||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
#define SRC_HELPER_HPP_
|
#define SRC_HELPER_HPP_
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
#include <ArduinoLog.h>
|
#include <main.hpp>
|
||||||
|
|
||||||
// Sleep mode
|
// Sleep mode
|
||||||
void deepSleep(int t);
|
void deepSleep(int t);
|
||||||
|
@ -21,12 +21,11 @@ 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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <pushtarget.hpp>
|
#include <pushtarget.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <webserver.hpp>
|
#include <webserver.hpp>
|
||||||
|
33
src/main.hpp
Normal file
33
src/main.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021-22 Magnus
|
||||||
|
|
||||||
|
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 above 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.
|
||||||
|
*/
|
||||||
|
#ifndef SRC_MAIN_HPP_
|
||||||
|
#define SRC_MAIN_HPP_
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <ArduinoLog.h>
|
||||||
|
#include <LittleFS.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#endif // SRC_MAIN_HPP_
|
@ -25,7 +25,8 @@ SOFTWARE.
|
|||||||
#include <MQTT.h>
|
#include <MQTT.h>
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <pushtarget.hpp>
|
#include <pushtarget.hpp>
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
|
@ -24,13 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_PUSHTARGET_HPP_
|
#ifndef SRC_PUSHTARGET_HPP_
|
||||||
#define SRC_PUSHTARGET_HPP_
|
#define SRC_PUSHTARGET_HPP_
|
||||||
|
|
||||||
// Includes
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ArduinoJson.h>
|
|
||||||
|
|
||||||
#include <helper.hpp>
|
|
||||||
|
|
||||||
// Classes
|
|
||||||
class PushTarget {
|
class PushTarget {
|
||||||
private:
|
private:
|
||||||
uint32_t _ms; // Used to check that we do not post to often
|
uint32_t _ms; // Used to check that we do not post to often
|
||||||
|
@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
|
|
||||||
OneWire myOneWire(D6);
|
OneWire myOneWire(D6);
|
||||||
|
@ -24,9 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_TEMPSENSOR_HPP_
|
#ifndef SRC_TEMPSENSOR_HPP_
|
||||||
#define SRC_TEMPSENSOR_HPP_
|
#define SRC_TEMPSENSOR_HPP_
|
||||||
|
|
||||||
// definitions
|
|
||||||
|
|
||||||
// classes
|
|
||||||
class TempSensor {
|
class TempSensor {
|
||||||
private:
|
private:
|
||||||
bool _hasSensor = false;
|
bool _hasSensor = false;
|
||||||
@ -41,7 +38,6 @@ class TempSensor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Global instance created
|
|
||||||
extern TempSensor myTempSensor;
|
extern TempSensor myTempSensor;
|
||||||
|
|
||||||
#endif // SRC_TEMPSENSOR_HPP_
|
#endif // SRC_TEMPSENSOR_HPP_
|
||||||
|
@ -21,15 +21,14 @@ 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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <ArduinoJson.h>
|
|
||||||
#include <LittleFS.h>
|
|
||||||
|
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
#include <helper.hpp>
|
#include <helper.hpp>
|
||||||
|
#include <main.hpp>
|
||||||
#include <tempsensor.hpp>
|
#include <tempsensor.hpp>
|
||||||
#include <webserver.hpp>
|
#include <webserver.hpp>
|
||||||
|
#include <wifi.hpp>
|
||||||
|
|
||||||
WebServer myWebServer; // My wrapper class fr webserver functions
|
WebServer myWebServer; // My wrapper class fr webserver functions
|
||||||
extern bool sleepModeActive;
|
extern bool sleepModeActive;
|
||||||
@ -263,7 +262,7 @@ void WebServer::webHandleClearWIFI() {
|
|||||||
|
|
||||||
if (!id.compareTo(myConfig.getID())) {
|
if (!id.compareTo(myConfig.getID())) {
|
||||||
_server->send(200, "text/plain",
|
_server->send(200, "text/plain",
|
||||||
"Clearing WIFI credentials and doing reset...");
|
"Clearing WIFI credentials and doing reset...");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
WiFi.disconnect(); // Clear credentials
|
WiFi.disconnect(); // Clear credentials
|
||||||
ESP.reset();
|
ESP.reset();
|
||||||
@ -350,7 +349,8 @@ void WebServer::webHandleConfigPush() {
|
|||||||
|
|
||||||
myConfig.setHttpPushUrl(_server->arg(CFG_PARAM_PUSH_HTTP).c_str());
|
myConfig.setHttpPushUrl(_server->arg(CFG_PARAM_PUSH_HTTP).c_str());
|
||||||
myConfig.setHttpPushUrl2(_server->arg(CFG_PARAM_PUSH_HTTP2).c_str());
|
myConfig.setHttpPushUrl2(_server->arg(CFG_PARAM_PUSH_HTTP2).c_str());
|
||||||
myConfig.setBrewfatherPushUrl(_server->arg(CFG_PARAM_PUSH_BREWFATHER).c_str());
|
myConfig.setBrewfatherPushUrl(
|
||||||
|
_server->arg(CFG_PARAM_PUSH_BREWFATHER).c_str());
|
||||||
myConfig.setInfluxDb2PushUrl(_server->arg(CFG_PARAM_PUSH_INFLUXDB2).c_str());
|
myConfig.setInfluxDb2PushUrl(_server->arg(CFG_PARAM_PUSH_INFLUXDB2).c_str());
|
||||||
myConfig.setInfluxDb2PushOrg(
|
myConfig.setInfluxDb2PushOrg(
|
||||||
_server->arg(CFG_PARAM_PUSH_INFLUXDB2_ORG).c_str());
|
_server->arg(CFG_PARAM_PUSH_INFLUXDB2_ORG).c_str());
|
||||||
@ -411,7 +411,7 @@ void WebServer::webHandleConfigGravity() {
|
|||||||
myConfig.setGravityFormula(_server->arg(CFG_PARAM_GRAVITY_FORMULA).c_str());
|
myConfig.setGravityFormula(_server->arg(CFG_PARAM_GRAVITY_FORMULA).c_str());
|
||||||
myConfig.setGravityTempAdj(
|
myConfig.setGravityTempAdj(
|
||||||
_server->arg(CFG_PARAM_GRAVITY_TEMP_ADJ).equalsIgnoreCase("on") ? true
|
_server->arg(CFG_PARAM_GRAVITY_TEMP_ADJ).equalsIgnoreCase("on") ? true
|
||||||
: false);
|
: false);
|
||||||
myConfig.saveFile();
|
myConfig.saveFile();
|
||||||
_server->sendHeader("Location", "/config.htm#collapseThree", true);
|
_server->sendHeader("Location", "/config.htm#collapseThree", true);
|
||||||
_server->send(302, "text/plain", "Gravity config updated");
|
_server->send(302, "text/plain", "Gravity config updated");
|
||||||
@ -663,7 +663,7 @@ bool WebServer::setupWebServer() {
|
|||||||
_server->on("/device.htm", std::bind(&WebServer::webReturnDeviceHtm, this));
|
_server->on("/device.htm", std::bind(&WebServer::webReturnDeviceHtm, this));
|
||||||
_server->on("/config.htm", std::bind(&WebServer::webReturnConfigHtm, this));
|
_server->on("/config.htm", std::bind(&WebServer::webReturnConfigHtm, this));
|
||||||
_server->on("/calibration.htm",
|
_server->on("/calibration.htm",
|
||||||
std::bind(&WebServer::webReturnCalibrationHtm, this));
|
std::bind(&WebServer::webReturnCalibrationHtm, this));
|
||||||
_server->on("/about.htm", std::bind(&WebServer::webReturnAboutHtm, this));
|
_server->on("/about.htm", std::bind(&WebServer::webReturnAboutHtm, this));
|
||||||
#else
|
#else
|
||||||
// Show files in the filessytem at startup
|
// Show files in the filessytem at startup
|
||||||
@ -703,18 +703,18 @@ bool WebServer::setupWebServer() {
|
|||||||
|
|
||||||
// Dynamic content
|
// Dynamic content
|
||||||
_server->on("/api/config", HTTP_GET,
|
_server->on("/api/config", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleConfig, this)); // Get config.json
|
std::bind(&WebServer::webHandleConfig, this)); // Get config.json
|
||||||
_server->on("/api/device", HTTP_GET,
|
_server->on("/api/device", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleDevice, this)); // Get device.json
|
std::bind(&WebServer::webHandleDevice, this)); // Get device.json
|
||||||
_server->on("/api/formula", HTTP_GET,
|
_server->on("/api/formula", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleFormulaRead,
|
std::bind(&WebServer::webHandleFormulaRead,
|
||||||
this)); // Get formula.json (calibration page)
|
this)); // Get formula.json (calibration page)
|
||||||
_server->on("/api/formula", HTTP_POST,
|
_server->on("/api/formula", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleFormulaWrite,
|
std::bind(&WebServer::webHandleFormulaWrite,
|
||||||
this)); // Get formula.json (calibration page)
|
this)); // Get formula.json (calibration page)
|
||||||
_server->on("/api/calibrate", HTTP_POST,
|
_server->on("/api/calibrate", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleCalibrate,
|
std::bind(&WebServer::webHandleCalibrate,
|
||||||
this)); // Run calibration routine (param id)
|
this)); // Run calibration routine (param id)
|
||||||
_server->on(
|
_server->on(
|
||||||
"/api/factory", HTTP_GET,
|
"/api/factory", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleFactoryReset, this)); // Reset the device
|
std::bind(&WebServer::webHandleFactoryReset, this)); // Reset the device
|
||||||
@ -725,26 +725,26 @@ bool WebServer::setupWebServer() {
|
|||||||
"/api/clearwifi", HTTP_GET,
|
"/api/clearwifi", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleClearWIFI, this)); // Clear wifi settings
|
std::bind(&WebServer::webHandleClearWIFI, this)); // Clear wifi settings
|
||||||
_server->on("/api/upload", HTTP_GET,
|
_server->on("/api/upload", HTTP_GET,
|
||||||
std::bind(&WebServer::webHandleUpload, this)); // Get upload.json
|
std::bind(&WebServer::webHandleUpload, this)); // Get upload.json
|
||||||
|
|
||||||
_server->on(
|
_server->on(
|
||||||
"/api/upload", HTTP_POST, std::bind(&WebServer::webReturnOK, this),
|
"/api/upload", HTTP_POST, std::bind(&WebServer::webReturnOK, this),
|
||||||
std::bind(&WebServer::webHandleUploadFile, this)); // File upload data
|
std::bind(&WebServer::webHandleUploadFile, this)); // File upload data
|
||||||
_server->on("/api/status/sleepmode", HTTP_POST,
|
_server->on("/api/status/sleepmode", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleStatusSleepmode,
|
std::bind(&WebServer::webHandleStatusSleepmode,
|
||||||
this)); // Change sleep mode
|
this)); // Change sleep mode
|
||||||
_server->on("/api/config/device", HTTP_POST,
|
_server->on("/api/config/device", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleConfigDevice,
|
std::bind(&WebServer::webHandleConfigDevice,
|
||||||
this)); // Change device settings
|
this)); // Change device settings
|
||||||
_server->on("/api/config/push", HTTP_POST,
|
_server->on("/api/config/push", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleConfigPush,
|
std::bind(&WebServer::webHandleConfigPush,
|
||||||
this)); // Change push settings
|
this)); // Change push settings
|
||||||
_server->on("/api/config/gravity", HTTP_POST,
|
_server->on("/api/config/gravity", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleConfigGravity,
|
std::bind(&WebServer::webHandleConfigGravity,
|
||||||
this)); // Change gravity settings
|
this)); // Change gravity settings
|
||||||
_server->on("/api/config/hardware", HTTP_POST,
|
_server->on("/api/config/hardware", HTTP_POST,
|
||||||
std::bind(&WebServer::webHandleConfigHardware,
|
std::bind(&WebServer::webHandleConfigHardware,
|
||||||
this)); // Change hardware settings
|
this)); // Change hardware settings
|
||||||
|
|
||||||
_server->onNotFound(std::bind(&WebServer::webHandlePageNotFound, this));
|
_server->onNotFound(std::bind(&WebServer::webHandlePageNotFound, this));
|
||||||
_server->begin();
|
_server->begin();
|
||||||
|
@ -24,13 +24,11 @@ SOFTWARE.
|
|||||||
#ifndef SRC_WEBSERVER_HPP_
|
#ifndef SRC_WEBSERVER_HPP_
|
||||||
#define SRC_WEBSERVER_HPP_
|
#define SRC_WEBSERVER_HPP_
|
||||||
|
|
||||||
// Include
|
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|
||||||
// Binary resouces
|
|
||||||
#if defined(EMBED_HTML)
|
#if defined(EMBED_HTML)
|
||||||
INCBIN_EXTERN(IndexHtm);
|
INCBIN_EXTERN(IndexHtm);
|
||||||
INCBIN_EXTERN(DeviceHtm);
|
INCBIN_EXTERN(DeviceHtm);
|
||||||
@ -41,7 +39,6 @@ INCBIN_EXTERN(AboutHtm);
|
|||||||
INCBIN_EXTERN(UploadHtm);
|
INCBIN_EXTERN(UploadHtm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// classes
|
|
||||||
class WebServer {
|
class WebServer {
|
||||||
private:
|
private:
|
||||||
ESP8266WebServer* _server = 0;
|
ESP8266WebServer* _server = 0;
|
||||||
@ -71,27 +68,29 @@ class WebServer {
|
|||||||
void webReturnOK() { _server->send(200); }
|
void webReturnOK() { _server->send(200); }
|
||||||
#if defined(EMBED_HTML)
|
#if defined(EMBED_HTML)
|
||||||
void webReturnIndexHtm() {
|
void webReturnIndexHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gIndexHtmData, gIndexHtmSize);
|
_server->send_P(200, "text/html", (const char*)gIndexHtmData,
|
||||||
|
gIndexHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnDeviceHtm() {
|
void webReturnDeviceHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gDeviceHtmData,
|
_server->send_P(200, "text/html", (const char*)gDeviceHtmData,
|
||||||
gDeviceHtmSize);
|
gDeviceHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnConfigHtm() {
|
void webReturnConfigHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gConfigHtmData,
|
_server->send_P(200, "text/html", (const char*)gConfigHtmData,
|
||||||
gConfigHtmSize);
|
gConfigHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnCalibrationHtm() {
|
void webReturnCalibrationHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gCalibrationHtmData,
|
_server->send_P(200, "text/html", (const char*)gCalibrationHtmData,
|
||||||
gCalibrationHtmSize);
|
gCalibrationHtmSize);
|
||||||
}
|
}
|
||||||
void webReturnAboutHtm() {
|
void webReturnAboutHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gAboutHtmData, gAboutHtmSize);
|
_server->send_P(200, "text/html", (const char*)gAboutHtmData,
|
||||||
|
gAboutHtmSize);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void webReturnUploadHtm() {
|
void webReturnUploadHtm() {
|
||||||
_server->send_P(200, "text/html", (const char*)gUploadHtmData,
|
_server->send_P(200, "text/html", (const char*)gUploadHtmData,
|
||||||
gUploadHtmSize);
|
gUploadHtmSize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -26,12 +26,8 @@ SOFTWARE.
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <incbin.h>
|
#include <incbin.h>
|
||||||
|
|
||||||
#include <ArduinoJson.hpp>
|
|
||||||
#include <calc.hpp>
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <main.hpp>
|
||||||
#include <helper.hpp>
|
|
||||||
#include <tempsensor.hpp>
|
|
||||||
#include <wifi.hpp>
|
#include <wifi.hpp>
|
||||||
|
|
||||||
// Settings for DRD
|
// Settings for DRD
|
||||||
|
@ -24,8 +24,6 @@ SOFTWARE.
|
|||||||
#ifndef SRC_WIFI_HPP_
|
#ifndef SRC_WIFI_HPP_
|
||||||
#define SRC_WIFI_HPP_
|
#define SRC_WIFI_HPP_
|
||||||
|
|
||||||
// Include
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
|
||||||
// tcp cleanup, to avoid memory crash.
|
// tcp cleanup, to avoid memory crash.
|
||||||
@ -33,7 +31,6 @@ struct tcp_pcb;
|
|||||||
extern struct tcp_pcb* tcp_tw_pcbs;
|
extern struct tcp_pcb* tcp_tw_pcbs;
|
||||||
extern "C" void tcp_abort(struct tcp_pcb* pcb);
|
extern "C" void tcp_abort(struct tcp_pcb* pcb);
|
||||||
|
|
||||||
// classes
|
|
||||||
class WifiConnection {
|
class WifiConnection {
|
||||||
private:
|
private:
|
||||||
// WIFI
|
// WIFI
|
||||||
|
Loading…
Reference in New Issue
Block a user