diff --git a/esp8266/config.h b/esp8266/config.h index 0ae55820..e88ddeac 100644 --- a/esp8266/config.h +++ b/esp8266/config.h @@ -26,6 +26,8 @@ #define FW_VERSION "V0.1" #define REPOSITORY "https://github.com/luc-github/ESP8266" +#define MDNS_FEATURE 1 + //pin used to reset setting #define RESET_CONFIG_PIN 2 diff --git a/esp8266/datainterface.cpp b/esp8266/datainterface.cpp index 17309cbb..39dd9b54 100644 --- a/esp8266/datainterface.cpp +++ b/esp8266/datainterface.cpp @@ -27,7 +27,7 @@ //cannot put it in class then cast it as std::function so put outside void handle_data_interface_root() { - data_interface.WebServer.send(200, "text/plain", "hello from esp8266 from port 8888 "); + data_interface.WebServer.send(200, "text/html", "hello from esp8266 from port 8888 "); } DATAINTERFACE_CLASS::DATAINTERFACE_CLASS (int port):WebServer(port) diff --git a/esp8266/webinterface.cpp b/esp8266/webinterface.cpp index 06c815c6..99b5bcfc 100644 --- a/esp8266/webinterface.cpp +++ b/esp8266/webinterface.cpp @@ -20,20 +20,149 @@ #include "config.h" #include "webinterface.h" +#include "wifi.h" #include #include +#include #include +extern "C" { +#include "user_interface.h" +} + +#define PAGE_HEAD "\n\n\n\n" \ + "\nWifi Configuration" \ + "\n\n"\ + "
" +#define NAV_START "" + +#define PAGE_BOTTOM "\n" + + //cannot put it in class then cast it as std::function so put outside void handle_web_interface_root() { - web_interface.WebServer.send(200, "text/plain", "hello from esp8266 from port 80!"); + String sbuf=PAGE_HEAD ; + String IP; + if (wifi_get_opmode()==WIFI_STA ) IP=wifi_config.ip2str(WiFi.localIP()); + else IP=wifi_config.ip2str(WiFi.softAPIP()); + sbuf+=NAV_START ; + sbuf+=NAV_LEFT_PART1 ; + sbuf+=NAV_ELEMENT_ACTIVE ; + sbuf+=NAV_LEFT_PART2a ; + sbuf+=IP; + sbuf+=NAV_LEFT_PART2b ; + sbuf+=NAV_LEFT_PART3a ; + sbuf+=IP; + sbuf+=NAV_LEFT_PART3b ; + sbuf+=NAV_RIGHT_PART ; + sbuf+=NAV_END ; + /* if (web_interface.WebServer.arg("myinput").length()> 0) + { + char buf[250]; + char buf1[250]; + web_interface.WebServer.arg("myinput").toCharArray(buf1, 249); + web_interface.urldecode(buf,buf1); + sbuf="