diff --git a/src/Display/OledDisplay.cpp b/src/Display/OledDisplay.cpp index d677d58..111cf36 100644 --- a/src/Display/OledDisplay.cpp +++ b/src/Display/OledDisplay.cpp @@ -42,6 +42,10 @@ void OledDisplay::postSetup() { } } +void OledDisplay::handleUpdate() { + this->ui->update(); +} + void OledDisplay::showBootScreen() { this->oledDisplay->setTextAlignment(TEXT_ALIGN_CENTER); this->oledDisplay->setContrast(255); // default is 255 diff --git a/src/Display/OledDisplay.h b/src/Display/OledDisplay.h index e7c0315..fad4f92 100644 --- a/src/Display/OledDisplay.h +++ b/src/Display/OledDisplay.h @@ -22,6 +22,7 @@ public: OledDisplay(OLEDDisplay *oledDisplay, GlobalDataController *globalDataController, DebugController *debugController); void preSetup(); void postSetup(); + void handleUpdate(); void showBootScreen(); void showApAccessScreen(String apSsid, String apIp); void showWebserverSplashScreen(bool isEnabled); diff --git a/src/Includes.h b/src/Includes.h index e29b764..608ab4a 100644 --- a/src/Includes.h +++ b/src/Includes.h @@ -30,9 +30,7 @@ DebugController debugController; TimeClient timeClient(TIME_UTCOFFSET, &debugController); OpenWeatherMapClient weatherClient(WEATHER_APIKEY, WEATHER_CITYID, 1, WEATHER_METRIC, WEATHER_LANGUAGE, &debugController); GlobalDataController globalDataController(&timeClient, &weatherClient, &debugController); -#if WEBSERVER_ENABLED - WebServer webServer(&globalDataController, &debugController); -#endif +WebServer webServer(&globalDataController, &debugController); // Construct the correct printer client #if (PRINTERCLIENT == REPETIER_CLIENT) diff --git a/src/Network/WebServer.cpp b/src/Network/WebServer.cpp index 78f5fc4..0ddbf5f 100644 --- a/src/Network/WebServer.cpp +++ b/src/Network/WebServer.cpp @@ -319,6 +319,7 @@ void WebServer::handleUpdateConfig() { this->globalDataController->setUseLedFlash(this->server->hasArg("useFlash")); this->globalDataController->writeSettings(); + this->findMDNS(); this->globalDataController->getPrinterClient()->getPrinterJobResults(); this->globalDataController->getPrinterClient()->getPrinterPsuState(); @@ -332,35 +333,37 @@ void WebServer::handleUpdateConfig() { this->globalDataController->getTimeClient()->resetLastEpoch(); this->redirectHome(); } -// findMDNS(); - -// void findMDNS() { -// if (PrinterServer == "" || ENABLE_OTA == false) { -// return; // nothing to do here -// } -// // We now query our network for 'web servers' service -// // over tcp, and get the number of available devices -// int n = MDNS.queryService("http", "tcp"); -// if (n == 0) { -// Serial.println("no services found - make sure Printer server is turned on"); -// return; -// } -// Serial.println("*** Looking for " + PrinterHostName + " over mDNS"); -// for (int i = 0; i < n; ++i) { -// // Going through every available service, -// // we're searching for the one whose hostname -// // matches what we want, and then get its IP -// Serial.println("Found: " + MDNS.hostname(i)); -// if (MDNS.hostname(i) == PrinterHostName) { -// IPAddress serverIp = MDNS.IP(i); -// PrinterServer = serverIp.toString(); -// PrinterPort = MDNS.port(i); // save the port -// Serial.println("*** Found Printer Server " + PrinterHostName + " http://" + PrinterServer + ":" + PrinterPort); -// writeSettings(); // update the settings -// } -// } -// } +void WebServer::findMDNS() { + if (this->globalDataController->getPrinterHostName() == "" || ENABLE_OTA == false) { + return; // nothing to do here + } + // We now query our network for 'web servers' service + // over tcp, and get the number of available devices + int n = MDNS.queryService("http", "tcp"); + if (n == 0) { + this->debugController->printLn("no services found - make sure Printer server is turned on"); + return; + } + this->debugController->printLn("*** Looking for " + this->globalDataController->getPrinterHostName() + " over mDNS"); + for (int i = 0; i < n; ++i) { + // Going through every available service, + // we're searching for the one whose hostname + // matches what we want, and then get its IP + Serial.println("Found: " + MDNS.hostname(i)); + if (MDNS.hostname(i) == this->globalDataController->getPrinterHostName()) { + IPAddress serverIp = MDNS.IP(i); + this->globalDataController->setPrinterServer(serverIp.toString()); + this->globalDataController->setPrinterPort(MDNS.port(i)); + this->debugController->printLn( + "*** Found Printer Server " + this->globalDataController->getPrinterHostName() + + " http://" + this->globalDataController->getPrinterServer() + + ":" + this->globalDataController->getPrinterPort() + ); + this->globalDataController->writeSettings(); // update the settings + } + } +} void WebServer::handleUpdateWeather() { if (!this->authentication()) { @@ -396,32 +399,7 @@ void WebServer::handleConfigure() { html = this->getHeader(); this->server->sendContent(html); - CHANGE_FORM = "