/************************************************************** * WiFiManager is a library for the ESP8266/Arduino platform * (https://github.com/esp8266/Arduino) to enable easy * configuration and reconfiguration of WiFi credentials and * store them in EEPROM. * inspired by http://www.esp8266.com/viewtopic.php?f=29&t=2520 * https://github.com/chriscook8/esp-arduino-apboot * Built by AlexT https://github.com/tzapu * Licensed under MIT license **************************************************************/ #ifndef WiFiManager_h #define WiFiManager_h #include #include #include #include #define DEBUG //until arduino ide can include defines at compile time from main sketch #ifdef DEBUG #define DEBUG_PRINT(x) Serial.println(x) #else #define DEBUG_PRINT(x) #endif class WiFiManager { public: WiFiManager(int eepromStart); void begin(); void begin(char const *apName); boolean autoConnect(); boolean autoConnect(char const *apName); boolean hasConnected(); String beginConfigMode(void); void startWebConfig(); String getSSID(); String getPassword(); void resetSettings(); //for conveniennce String urldecode(const char*); //sets timeout before webserver loop ends and exits even if there has been no setup. //usefully for devices that failed to connect at some point and got stuck in a webserver loop //in seconds void setTimeout(unsigned long seconds); private: const int WM_DONE = 0; const int WM_WAIT = 10; const String HTTP_404 = "HTTP/1.1 404 Not Found\r\n\r\n"; const String HTTP_200 = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; const String HTTP_HEAD = "{v}"; const String HTTP_STYLE = ""; const String HTTP_SCRIPT = ""; const String HTTP_HEAD_END = ""; const String HTTP_ITEM = "
{v}
"; const String HTTP_FORM = "

"; const String HTTP_END = ""; int _eepromStart; const char* _apName = "no-net"; String _ssid = ""; String _pass = ""; unsigned long timeout = 0; unsigned long start = 0; String getEEPROMString(int start, int len); void setEEPROMString(int start, int len, String string); int serverLoop(); }; #endif