esp8266boilerplate/configurationMode.cpp

56 lines
887 B
C++
Raw Permalink Normal View History

2019-04-25 16:47:05 +02:00
/*
2019-04-25 16:20:01 +02:00
* configurationMode.cpp
*
* Created on: Aug 20, 2017
* Author: wn
*/
2019-04-30 11:22:16 +00:00
#include <defines.h>
2019-04-25 16:20:01 +02:00
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
#include "configurationMode.h"
2019-04-30 11:22:16 +00:00
#include <configuration.h>
2019-04-25 16:20:01 +02:00
ESP8266WebServer webServer(80);
void configServeNotFound() {
webServer.send(404, "text/plain", "page not found");
#ifdef DEBUG
Serial.println("page not found served");
#endif
}
void setupConfigurationNetwork() {
WiFi.mode(WIFI_AP);
WiFi.softAP(CONFIG_SSID);
#ifdef DEBUG
Serial.println("AP started");
#endif
}
void setupConfigurationServer() {
webServer.on("/", configServeIndex);
webServer.on("/config", configServeGetConfiguration);
webServer.onNotFound(configServeNotFound);
webServer.begin();
#ifdef DEBUG
Serial.println("Webserver started");
#endif
}
void loopConfiguration() {
webServer.handleClient();
}