#include #include #include #include #include #include #include "WebServer.h" #include "ClockServer.h" #ifdef ESP8266 extern "C" { #include "user_interface.h" } #endif static const char * const PROGMEM appConfig[] = { "enable_battery:boolean:false", "enable_webupdate:boolean:false", "enable_fastclock_server:boolean:true", }; static Debug debug(115200); static Config config(debug); static SimpleFS simpleFS(debug); static Battery battery; static WiFiConnection wifiConnection(debug, config); static ClockServer clockServer(debug, config); static WebServer webServer(debug, config, clockServer); static WebUpdate webUpdate(debug, config, simpleFS, "clockserver"); // ***** Configuration Switches ***** static boolean enableBattery = false; static boolean enableFastclockServer = false; static boolean enableWebupdate = false; void setup() { debug.setOutputUptoLevel(DEBUG_MAX_INFO); debug.outln(F("### Setup")); // ********** Initialize file system ********** simpleFS.begin(); delay(100); debug.outln(F("Getting app config")); config.begin("app.cfg", appConfig, sizeof(appConfig)/sizeof(appConfig[0])); enableFastclockServer = config.getBoolean("enable_fastclock_server"); enableBattery = config.getBoolean("enable_battery"); enableWebupdate = true; //config.getBoolean("enable_webupdate"); // ********** Setting up networking ********** wifiConnection.setup(); wifiConnection.begin(); // *********** Starting web server ********** webServer.begin(); delay(1000); // *********** Check for Updates ********** if (enableWebupdate) { webUpdate.begin(); } // *********** Start Clock Server ********** if (enableFastclockServer) { clockServer.begin(); } } int lastBatteryReadOn = 0; void loop() { webServer.loop(); if (enableBattery && (millis() - lastBatteryReadOn > 30000)) { lastBatteryReadOn = millis(); debug.out("Battery="); debug.out(battery.getPercentage()); debug.outln(" %"); logHeap(); } if (enableFastclockServer) clockServer.loop(); if (enableWebupdate) webUpdate.loop(); simpleFS.loop(); }