/*
 * configurationMode.cpp
 *
 *  Created on: Aug 20, 2017
 *      Author: wn
 */

#include "defines.h"

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <PubSubClient.h>
#include <EEPROM.h>


#include "configurationMode.h"
#include "configuration.h"




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();
}



