#include <WebServer.h>
Public Member Functions | |
MyWebServer (MyOptions &options, MyData &data) | |
bool | begin () |
void | handleClient () |
Static Public Member Functions | |
static void | handleRoot () |
static void | loadMain () |
static void | handleLoadMainInfo () |
static void | loadUpdate () |
static void | loadSettings () |
static void | handleLoadSettingsInfo () |
static void | handleSaveSettings () |
static void | handleLoadInfoInfo () |
static void | loadConsole () |
static void | handleLoadConsoleInfo () |
static void | loadRestart () |
static void | handleLoadRestartInfo () |
static void | handleNotFound () |
static void | handleWebRequests () |
Data Fields | |
bool | isWebServerActive |
Is the webserver currently active. | |
Static Public Attributes | |
static MyESPWebServer | server |
Webserver helper class. | |
static IPAddress | ip |
Soft AP ip Address. | |
static DNSServer | dnsServer |
Dns server. | |
static MyOptions * | myOptions = NULL |
Reference to the options. | |
static MyData * | myData = NULL |
Reference to the data. | |
Static Protected Member Functions | |
static bool | loadFromSpiffs (String path) |
static void | AddTableBegin (String &info) |
static void | AddTableTr (String &info) |
static void | AddTableTr (String &info, String name, String value) |
static void | AddTableEnd (String &info) |
static bool | GetOption (String id, String &option) |
static bool | GetOption (String id, long &option) |
static bool | GetOption (String id, double &option) |
static bool | GetOption (String id, bool &option) |
static void | AddBr (String &info) |
static void | AddOption (String &info, String id, String name, bool value, bool addBr=true) |
static void | AddOption (String &info, String id, String name, String value, bool addBr=true, bool isPassword=false) |
static void | AddIntervalInfo (String &info) |
My Webserver interface. Works together with .html, .css and .js files from the SPIFFS. Works mostly with static functions because of the server callback functions.
Definition at line 47 of file WebServer.h.
Constructor/Destructor
Definition at line 108 of file WebServer.h.
References myData, and myOptions.
|
staticprotected |
Add a HTML br element.
Definition at line 276 of file WebServer.h.
Referenced by handleLoadSettingsInfo().
|
staticprotected |
Add the format information of the intervall in 'dd hh:mm:ss'
Definition at line 317 of file WebServer.h.
References TextToXml().
Referenced by handleLoadSettingsInfo().
|
staticprotected |
Add one bool input option field to the HTML source.
Definition at line 300 of file WebServer.h.
References TextToXml().
Referenced by handleLoadSettingsInfo().
|
staticprotected |
Add one string input option field to the HTML source.
Definition at line 282 of file WebServer.h.
References TextToXml().
|
staticprotected |
Helper function to start a HTML table.
Definition at line 193 of file WebServer.h.
Referenced by handleLoadInfoInfo(), and handleLoadMainInfo().
|
staticprotected |
Helper function to add one HTML table end element.
Definition at line 216 of file WebServer.h.
Referenced by handleLoadInfoInfo(), and handleLoadMainInfo().
|
staticprotected |
Helper function to write one HTML row with no data.
Definition at line 199 of file WebServer.h.
Referenced by handleLoadInfoInfo(), and handleLoadMainInfo().
|
staticprotected |
Helper function to add one HTML table row line with data.
Definition at line 205 of file WebServer.h.
References TextToXml().
bool MyWebServer::begin | ( | ) |
Starts the Webserver in station and/or ap mode and sets all the callback functions for the specific urls. If you use rtc yourself you have to switch off the automatic Wifi configuration with WiFi.persistent(false) (because it uses also the RTC memory) otherwise the WIFI won't start after a Deep Sleep.
Definition at line 124 of file WebServer.h.
References MyOptions::connectWifiAP, dnsServer, handleLoadConsoleInfo(), handleLoadInfoInfo(), handleLoadMainInfo(), handleLoadRestartInfo(), handleLoadSettingsInfo(), handleRoot(), handleSaveSettings(), handleWebRequests(), ip, isWebServerActive, loadConsole(), loadMain(), loadRestart(), loadSettings(), loadUpdate(), myData, MyDbg(), MyDelay(), myOptions, server, SOFT_AP_NAME, SOFT_AP_PW, MyData::softAPIP, MyData::softAPmacAddress, MyData::stationIP, MyOptions::wifiAP, WifiGetRssiAsQuality(), and MyOptions::wifiPassword.
Referenced by setup().
|
staticprotected |
Reads one string option from the url args.
Definition at line 222 of file WebServer.h.
References server.
Referenced by handleSaveSettings().
|
staticprotected |
Reads one long option from the URL args.
Definition at line 232 of file WebServer.h.
References scanInterval(), and server.
|
staticprotected |
Reads one double option from the URL args.
Definition at line 249 of file WebServer.h.
References server.
|
staticprotected |
Reads one bool option from the URL args.
Definition at line 261 of file WebServer.h.
References server.
void MyWebServer::handleClient | ( | ) |
Handle the http requests.
Definition at line 184 of file WebServer.h.
References dnsServer, isWebServerActive, and server.
Referenced by loop(), myDebugInfo(), and myDelayLoop().
|
static |
Handle the Console ajax calls to get AT commands and show the result of the calls or debug informations.
Definition at line 719 of file WebServer.h.
References StringList::addTail(), MyData::consoleCmds, StringList::count(), StringList::getAt(), MyData::logInfos, myData, MyDbg(), myOptions, StringList::rolledOut(), server, and TextToUrl().
Referenced by begin().
|
static |
Load the detail info part via ajax call.
Definition at line 633 of file WebServer.h.
References AddTableBegin(), AddTableEnd(), AddTableTr(), MyGps::altitudeString(), MyData::batteryLevel, MyData::batteryVolt, MyData::cop, MyGps::courseString(), MyGps::date, MyDate::dateString(), MyData::RtcData::deepSleepTimeSec, MyGps::fixStatus, formatInterval(), MyData::getActiveTimeSec(), MyData::getLowPowerPowerConsumption(), MyData::getPowerConsumption(), MyData::getPowerOnTimeSec(), MyData::imei, MyData::isMoving, MyData::isOtaActive, MyGps::kmphString(), MyData::RtcData::lastGps, MyGps::latitudeString(), MyGps::longitudeString(), MyData::modemInfo, MyData::modemIP, MyData::movingDistance, myData, myOptions, MyData::rtcData, MyGps::satellitesString(), server, MyData::signalQuality, MyData::softAPIP, MyData::softAPmacAddress, MyData::stationIP, MyData::status, MyGps::time, MyTime::timeString(), MyOptions::wifiAP, and WifiGetRssiAsQuality().
Referenced by begin().
|
static |
Handle the ajax call of the Main.html detail information.
Definition at line 374 of file WebServer.h.
References AddTableBegin(), AddTableEnd(), AddTableTr(), MyGps::altitudeString(), MyData::RtcData::deepSleepTimeSec, MyGps::fixStatus, formatInterval(), MyData::getActiveTimeSec(), MyData::getLowPowerPowerConsumption(), MyData::getPowerConsumption(), MyData::getPowerOnTimeSec(), MyData::humidity, MyOptions::isMqttEnabled, MyGps::kmphString(), MyData::RtcData::lastGps, MyGps::latitudeString(), MyGps::longitudeString(), MyData::modemInfo, MyData::RtcData::mqttLastSentTime, MyData::RtcData::mqttSendCount, myData, myOptions, MyOptions::powerOn, MyData::pressure, MyData::rtcData, MyGps::satellitesString(), MyOptions::save(), MyData::secondsToDeepSleep, server, SOFT_AP_NAME, MyData::status, MyData::temperature, MyTime::timeString(), MyData::voltage, MyOptions::wifiAP, and WifiGetRssiAsQuality().
Referenced by begin().
|
static |
Handle the restart ajax call of the restart reason.
Definition at line 768 of file WebServer.h.
References myData, myOptions, MyData::restartInfo, and server.
Referenced by begin().
|
static |
Sends the ajax settings detail information to the client.
Definition at line 478 of file WebServer.h.
References MyOptions::activeTimeSec, AddBr(), AddIntervalInfo(), AddOption(), MyOptions::bme280CheckIntervalSec, MyOptions::connectWifiAP, MyOptions::deepSleepTimeSec, formatInterval(), MyOptions::gprsAP, MyOptions::gprsPassword, MyOptions::gprsUser, MyOptions::gpsCheckIntervalSec, MyOptions::gpsTimeoutSec, MyOptions::isDebugActive, MyOptions::isDeepSleepEnabled, MyOptions::isGpsEnabled, MyOptions::isMqttEnabled, MyOptions::isSmsEnabled, MyOptions::minMovingDistance, MyOptions::mqttId, MyOptions::mqttName, MyOptions::mqttPassword, MyOptions::mqttPort, MyOptions::mqttSendOnMoveEverySec, MyOptions::mqttSendOnNonMoveEverySec, MyOptions::mqttServer, MyOptions::mqttUser, myData, MyDbg(), myOptions, MyOptions::phoneNumber, MyOptions::powerCheckIntervalSec, MyOptions::powerSaveModeVoltage, server, MyOptions::smsCheckIntervalSec, MyOptions::wifiAP, and MyOptions::wifiPassword.
Referenced by begin().
|
static |
Handle if the url could not be found.
Definition at line 779 of file WebServer.h.
References myData, MyDbg(), myOptions, and server.
Referenced by handleWebRequests(), loadConsole(), loadMain(), loadRestart(), loadSettings(), and loadUpdate().
|
static |
Redirect a root call to the Main.html site.
Definition at line 358 of file WebServer.h.
References server.
Referenced by begin().
|
static |
Reads all the options from the url and save them to the SPIFFS.
Definition at line 583 of file WebServer.h.
References MyOptions::activeTimeSec, MyData::awakeTimeOffsetSec, MyOptions::bme280CheckIntervalSec, MyOptions::connectWifiAP, MyOptions::deepSleepTimeSec, GetOption(), MyOptions::gprsAP, MyOptions::gprsPassword, MyOptions::gprsUser, MyOptions::gpsCheckIntervalSec, MyOptions::gpsTimeoutSec, MyOptions::isDebugActive, MyOptions::isDeepSleepEnabled, MyOptions::isGpsEnabled, MyOptions::isMqttEnabled, MyOptions::isSmsEnabled, loadMain(), loadRestart(), MyOptions::minMovingDistance, MyOptions::mqttId, MyOptions::mqttName, MyOptions::mqttPassword, MyOptions::mqttPort, MyOptions::mqttSendOnMoveEverySec, MyOptions::mqttSendOnNonMoveEverySec, MyOptions::mqttServer, MyOptions::mqttUser, myData, MyDbg(), myOptions, MyOptions::phoneNumber, MyOptions::powerCheckIntervalSec, MyOptions::powerSaveModeVoltage, MyData::restartInfo, MyOptions::save(), MyOptions::smsCheckIntervalSec, MyOptions::wifiAP, and MyOptions::wifiPassword.
Referenced by begin().
|
static |
Default for an unknown web request on not found.
Definition at line 803 of file WebServer.h.
References handleNotFound(), loadFromSpiffs(), and server.
Referenced by begin().
|
static |
Load the console page
Definition at line 707 of file WebServer.h.
References handleNotFound(), loadFromSpiffs(), MyData::logInfos, myData, StringList::removeAll(), and server.
Referenced by begin().
|
staticprotected |
Helper function to load a file from the SPIFFS.
Definition at line 324 of file WebServer.h.
References server.
Referenced by handleWebRequests(), loadConsole(), loadMain(), loadRestart(), loadSettings(), and loadUpdate().
|
static |
Sends the Main.html to the client.
Definition at line 365 of file WebServer.h.
References handleNotFound(), and loadFromSpiffs().
Referenced by begin(), and handleSaveSettings().
|
static |
Load the restart page.
Definition at line 755 of file WebServer.h.
References handleNotFound(), loadFromSpiffs(), MyDbg(), and MyDelay().
Referenced by begin(), and handleSaveSettings().
|
static |
Load the Settings page.
Definition at line 469 of file WebServer.h.
References handleNotFound(), and loadFromSpiffs().
Referenced by begin().
|
static |
Load the firmware update page after starting OTA.
Definition at line 451 of file WebServer.h.
References handleNotFound(), MyData::isOtaActive, loadFromSpiffs(), myData, myOptions, and SetupOTA().
Referenced by begin().