From 0bf70cc79c7aa0f26198296af7442489f1051cb6 Mon Sep 17 00:00:00 2001 From: luc Date: Thu, 14 May 2015 22:13:26 +0800 Subject: [PATCH] Add 404 basic management Draft page if not URL is not found Change first Configuration link to be system, later will add Configuration AP and Configuration Station --- esp8266/webinterface.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/esp8266/webinterface.cpp b/esp8266/webinterface.cpp index 8326aaa9..09b222ed 100644 --- a/esp8266/webinterface.cpp +++ b/esp8266/webinterface.cpp @@ -42,7 +42,7 @@ const char NAV_ELEMENT_ACTIVE [] PROGMEM = "class=\"active\""; const char NAV_LEFT_PART2a[] PROGMEM = ">Home\n
  • Configuration
  • \n\n"; +const char NAV_LEFT_PART3b[] PROGMEM = "/CONFIGSYS\">Configuration System\n\n"; const char NAV_RIGHT_PART[] PROGMEM = "

        

    \n\n"\ @@ -108,7 +108,6 @@ void handle_web_interface_root() web_interface.add4send(PANEL_TOP); web_interface.add4send(F("System")); web_interface.add4send(PANEL_START); - LABEL(F("Chip ID: "),String(system_get_chip_id()).c_str()) LABEL_UNITS(F("CPU Frequency: "),String(system_get_cpu_freq()).c_str(),F("Hz")) LABEL_UNITS(F("Free Memory: "),String(system_get_free_heap_size()).c_str(),F(" octets")) @@ -130,6 +129,9 @@ void handle_web_interface_root() LABEL(F("Sleep mode: "),sstatus.c_str()) //LABEL(sbuf,F("Boot mode: "),String(system_get_boot_mode())) //no meaning so far LABEL(F("Boot version: "),String(system_get_boot_version()).c_str()) + istatus=0; + if (!CONFIG::read_buffer(EP_BAUD_RATE, (byte *)&istatus , BAUD_LENGH))istatus=0;; + LABEL(F("Baud rate: "),String(istatus).c_str()) web_interface.add4send(PANEL_END); //access point web_interface.add4send(PANEL_TOP); @@ -240,7 +242,7 @@ void handle_web_interface_root() web_interface.flushbuffer(); } -void handle_web_interface_config() +void handle_web_interface_configSys() { String IP; if (wifi_get_opmode()==WIFI_STA ) IP=wifi_config.ip2str(WiFi.localIP()); @@ -262,6 +264,17 @@ void handle_web_interface_config() web_interface.flushbuffer(); } +void handle_not_found() +{ + String IP; + if (wifi_get_opmode()==WIFI_STA ) IP=wifi_config.ip2str(WiFi.localIP()); + else IP=wifi_config.ip2str(WiFi.softAPIP()); + web_interface.add4send(F("

    Page not found!


    Please try here")); + web_interface.flushbuffer(); +} + //URI Decoding function //no check if dst buffer is big enough to receive string so //use same size as src is a recommendation @@ -345,7 +358,8 @@ WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port) { //init what will handle "/" WebServer.on(F("/"),HTTP_ANY, handle_web_interface_root); - WebServer.on(F("/CONFIG"),HTTP_ANY, handle_web_interface_config); + WebServer.on(F("/CONFIGSYS"),HTTP_ANY, handle_web_interface_configSys); + WebServer.onNotFound( handle_not_found); buffer2send=""; }