Example:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> //Local WebServer used to serve the configuration portal
const char *ssid = "myssid";
const char *pass = "mypassword";
boolean proceed = false;
// Start WiFi Server
std::unique_ptr<ESP8266WebServer> server;
void setup() {
// Setup console
Serial1.begin(115200);
delay(10);
Serial1.println();
Serial1.println();
WiFi.begin(ssid, pass);
server.reset(new ESP8266WebServer(WiFi.localIP(), 80));
server->on("/", []() {
server->send(200, "text/plain", "this works as well");
});
server->on("/inline", []() {
server->send(200, "text/plain", "this works as well");
});
server->on("/start", []() {
server->send(200, "text/plain", "Program has started");
proceed = false;
unsigned long previousMillis = millis();
unsigned long currentMillis = millis();
while (proceed == false) {
//repeating task will go here
currentMillis = millis();
//break out of the loop after 600 seconds
if (currentMillis - previousMillis >= 600000) {
proceed = true;
}
delay(1);
}
});
server->on("/stop", []() {
proceed = true;
server->send(200, "text/plain", "Program has stopped");
});
server->onNotFound( []() {
server->send(404, "text/plain", "Not Found");
});
server->begin();
}
void loop() {
server->handleClient();
}