// // Created by lukas on 10.04.20. // #include #include "WifiManager.h" void WifiManager::init() { Serial.print("Setting up Access Point"); // start softap boolean result = WiFi.softAP("PumpenSteuerung-Heiligenbrunner", "1qayxsw2"); if (result == true) { Serial.println("Wifi Ready"); Serial.println( WiFi.softAPIP()); server.on("/", HTTP_GET, [this](){ handleRoot(); }); server.on("/get", [this](){ handleGet(); }); server.onNotFound([this](){ handleNotFound(); }); server.begin(); } else { Serial.println("Wifi Setup failed!"); } } WifiManager::WifiManager() : server(80) {} void WifiManager::handleRoot() { Serial.println("HomePage called"); int value = 0; EEPROM.begin(4096); // init the eeprom EEPROM.get(0, value); EEPROM.end(); // stop the eeprom communication const String index_html = "\n" " Wastinfoboard-ConfigurationPage\n" " \n" " \n" "
Aktuelle Zeit: "+ String(value) +" Minuten
\n" "
\n" " Zeit setzen: \n" " \n" "

\n" " \n" " " " \n" ""; server.send(200, "text/html", index_html); } void WifiManager::handleNotFound() { server.send(404, "text/plain", "404: Not found"); // Send HTTP status 404 (Not Found) when there's no handler for the URI in the request } void WifiManager::handleGet() { Serial.println("get called"); String s = "\n" " Wastinfoboard-ConfigurationPage\n" " \n" " \n" " \n" ""; Serial.println(server.arg("time")); if (server.arg("time") != "") { int time = atoi(server.arg("time").c_str()); //Gets the value of the query parameter //manager.setSSID(message); EEPROM.begin(4096); // init the eeprom EEPROM.put(0, time); EEPROM.commit(); // write the changes to the eeprom EEPROM.end(); // stop the eeprom communication } else if (server.arg("reset") != "") { Serial.println("Reset ..."); ESP.reset(); } // manager.storeVars(); Serial.println("send get back"); server.send(200, "text/html", s); //Send web page } void WifiManager::holdAlive() { server.handleClient(); }