From 700cc71ffb0d0ba9ff59ff0041276dd14b8ab187 Mon Sep 17 00:00:00 2001 From: luc lebosse Date: Tue, 21 Apr 2015 22:10:24 +0800 Subject: [PATCH] Memory optimization and Client Status Info Diisplay all System information and Client Information AP information to be done --- esp8266/config.h | 13 ++-- esp8266/webinterface.cpp | 145 ++++++++++++++++++++++++++------------- esp8266/wifi.cpp | 8 +-- 3 files changed, 111 insertions(+), 55 deletions(-) diff --git a/esp8266/config.h b/esp8266/config.h index e88ddeac..3e974578 100644 --- a/esp8266/config.h +++ b/esp8266/config.h @@ -50,13 +50,16 @@ //default values #define DEFAULT_WIFI_MODE AP_MODE -#define DEFAULT_SSID "ESP8266" -#define DEFAULT_PASSWORD "12345678" +const char DEFAULT_SSID [] PROGMEM = "ESP8266"; +const char DEFAULT_PASSWORD [] PROGMEM = "12345678"; #define DEFAULT_IP_MODE STATIC_IP_MODE -#define DEFAULT_IP_VALUE "192.168.0.1" -#define DEFAULT_MASK_VALUE "255.255.255.0" +const char DEFAULT_IP_VALUE[] PROGMEM = "192.168.0.1"; +const char DEFAULT_MASK_VALUE[] PROGMEM = "255.255.255.0"; #define DEFAULT_GATEWAY_VALUE DEFAULT_IP_VALUE -#define DEFAULT_BAUD_RATE "9600" +const char DEFAULT_BAUD_RATE[] PROGMEM = "9600"; +#if MDNS_FEATURE +const char LOCAL_NAME[] PROGMEM = "esp8266"; +#endif #define EEPROM_SIZE 256 //max is 512 #define MAX_SSID_LENGH 32 diff --git a/esp8266/webinterface.cpp b/esp8266/webinterface.cpp index 99b5bcfc..dc1ff3b7 100644 --- a/esp8266/webinterface.cpp +++ b/esp8266/webinterface.cpp @@ -29,36 +29,48 @@ extern "C" { #include "user_interface.h" } -#define PAGE_HEAD "\n\n\n\n" \ +const char PAGE_HEAD[] PROGMEM = "\n\n\n\n" \ "\nWifi Configuration" \ "\n\n"\ - "
" -#define NAV_START ""; -#define PAGE_BOTTOM "\n" - +const char PAGE_BOTTOM[] PROGMEM = "\n" ; +const char PANEL_TOP[] PROGMEM = "
\n
\n

"; +const char PANEL_START[] PROGMEM ="

\n
\n
"; +const char PANEL_END[] PROGMEM = "
\n
"; +const char LABEL_START[] PROGMEM = ""; +const char BR[] PROGMEM = "
\n"; +#define LABEL(buffer, title, value) buffer+= LABEL_START; buffer+=title;buffer+=LABEL_COLOR;buffer+=value;buffer+=LABEL_END;buffer+=BR; +#define LABEL_UNITS(buffer, title, value,units) buffer+= LABEL_START; buffer+=title;buffer+=LABEL_COLOR;buffer+=value;buffer+=units;buffer+=LABEL_END;buffer+=BR; //cannot put it in class then cast it as std::function so put outside void handle_web_interface_root() { String sbuf=PAGE_HEAD ; String IP; + String sstatus; + int istatus; + uint8_t mac [WL_MAC_ADDR_LENGTH]; if (wifi_get_opmode()==WIFI_STA ) IP=wifi_config.ip2str(WiFi.localIP()); else IP=wifi_config.ip2str(WiFi.softAPIP()); + //top bar sbuf+=NAV_START ; sbuf+=NAV_LEFT_PART1 ; sbuf+=NAV_ELEMENT_ACTIVE ; @@ -70,36 +82,77 @@ void handle_web_interface_root() 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="