From 6f0cce3de51e6283aa0d26a422d97ffd49e1080b Mon Sep 17 00:00:00 2001 From: Ivan Susanin Date: Sun, 27 Sep 2015 21:30:24 +0300 Subject: [PATCH 1/5] Add hostname display. Shown on left, between logo and menu --- html/style.css | 10 ++++++++++ html/ui.js | 4 ++++ user/cgi.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/html/style.css b/html/style.css index 29d15a3..e67d064 100644 --- a/html/style.css +++ b/html/style.css @@ -206,6 +206,16 @@ pre.console a { color: #fff; } +#menu .hostname { + width: 100%; + font-size: 12px; + height: 20px; + padding-left: 10px; + text-align: center; + color: #fff; + background: #9d1414; +} + #menu .pure-menu-heading { font-size: 110%; color: #fff; diff --git a/html/ui.js b/html/ui.js index 5de2f4c..5d703c8 100644 --- a/html/ui.js +++ b/html/ui.js @@ -226,6 +226,7 @@ onLoad(function() {
\ \  esp-link\ +
\ \
\ \ @@ -258,6 +259,9 @@ onLoad(function() { v = $("#version"); if (v != null) { v.innerHTML = data.version; } + + $("#hostname").innerHTML = data.hostname; + }, function() { setTimeout(getMenu, 1000); }); }; getMenu(); diff --git a/user/cgi.c b/user/cgi.c index 8f87d38..afef507 100644 --- a/user/cgi.c +++ b/user/cgi.c @@ -66,7 +66,7 @@ int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { os_sprintf(buff, "{\"menu\": [\"Home\", \"/home.html\", \"Wifi\", \"/wifi/wifi.html\"," "\"\xC2\xB5" "C Console\", \"/console.html\", \"Debug log\", \"/log.html\" ],\n" - " \"version\": \"%s\" }", esp_link_version); + " \"version\": \"%s\", \"hostname\": \"%s\"}", esp_link_version, wifi_station_get_hostname()); httpdSend(connData, buff, -1); return HTTPD_CGI_DONE; } From 1e769245abff656eaeb22ed9171fdd90b37fb18c Mon Sep 17 00:00:00 2001 From: Ivan Susanin Date: Sun, 27 Sep 2015 22:10:48 +0300 Subject: [PATCH 2/5] Make hostname left aligned - looks much better --- html/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/style.css b/html/style.css index e67d064..9d27ee3 100644 --- a/html/style.css +++ b/html/style.css @@ -211,7 +211,7 @@ pre.console a { font-size: 12px; height: 20px; padding-left: 10px; - text-align: center; + text-align: left; color: #fff; background: #9d1414; } From 926409f676bee4ce88448a5e9e1fdb98c14012dc Mon Sep 17 00:00:00 2001 From: Ivan Susanin Date: Sun, 27 Sep 2015 22:11:56 +0300 Subject: [PATCH 3/5] Allow update over WiFi when password is set. Use as 'AUTH=user:pass ./wiflash ' --- wiflash | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wiflash b/wiflash index d8c12ea..5c33a32 100755 --- a/wiflash +++ b/wiflash @@ -25,6 +25,8 @@ Example: ${0##*/} -v esp8266 firmware/user1.bin firmware/user2.bin EOT } +[ -z "$DEBUG" ] || set -x + if ! which curl >/dev/null; then echo "ERROR: Cannot find curl: it is required for this script." >&2 exit 1 @@ -56,6 +58,8 @@ fi hostname=$1 user1=$2 user2=$3 +test -n "$AUTH" && PASSADD="-u $AUTH" + re='[-A-Za-z0-9.]+' if [[ ! "$hostname" =~ $re ]]; then @@ -79,7 +83,7 @@ fw= while true; do [[ -n "$verbose" ]] && echo "Fetching http://$hostname/flash/next" >&2 v=; [[ -n "$verbose" ]] && v=-v - next=`curl -m 10 $v -s "http://$hostname/flash/next"` + next=`curl -m 10 $v $PASSADD -s "http://$hostname/flash/next"` if [[ $? != 0 ]]; then echo "Error retrieving http://$hostname/flash/next" >&2 exit 1 @@ -102,7 +106,7 @@ done #silent=-s [[ -n "$verbose" ]] && silent= -res=`curl $silent -XPOST --data-binary "@$fw" "http://$hostname/flash/upload"` +res=`curl $silent $PASSADD -XPOST --data-binary "@$fw" "http://$hostname/flash/upload"` if [[ $? != 0 ]]; then echo "Error flashing $fw" >&2 exit 1 @@ -110,13 +114,13 @@ fi sleep 2 echo "Rebooting into new firmware" >&2 -curl -m 10 -s "http://$hostname/flash/reboot" +curl -m 10 $PASSADD -s "http://$hostname/flash/reboot" sleep 2 echo "Waiting for ESP8266 to come back" while true; do [[ -n "$verbose" ]] && echo "Fetching http://$hostname/flash/next" >&2 - next2=`curl -m 10 $v -s "http://$hostname/flash/next"` + next2=`curl -m 10 $v $PASSADD -s "http://$hostname/flash/next"` [[ -n "$verbose" ]] && echo "got: $next2" re='user[12]\.bin' if [[ "$next2" =~ $re ]]; then From d7f519fff027b78200314b830f1361ede2b615ae Mon Sep 17 00:00:00 2001 From: Ivan Susanin Date: Mon, 28 Sep 2015 11:06:38 +0300 Subject: [PATCH 4/5] Even better hostname display --- html/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/style.css b/html/style.css index 9d27ee3..2e111a1 100644 --- a/html/style.css +++ b/html/style.css @@ -207,8 +207,8 @@ pre.console a { } #menu .hostname { - width: 100%; - font-size: 12px; + width: 140px; + border-top: 1px solid #333; height: 20px; padding-left: 10px; text-align: left; From 04082a1661e8519787416c867bba3a159a8d84fd Mon Sep 17 00:00:00 2001 From: Ivan Susanin Date: Thu, 1 Oct 2015 21:09:42 +0300 Subject: [PATCH 5/5] Backport buildtime wifi config ability to v1.0 --- Makefile | 12 ++++++++++++ include/espmissingincludes.h | 6 ++++++ user/user_main.c | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/Makefile b/Makefile index 709a0a1..e7f34fa 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,10 @@ ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) ESPPORT ?= /dev/ttyUSB0 ESPBAUD ?= 460800 +# Build time Wifi Cfg +# STA_SSID ?= +# STA_PASS ?= + # --------------- chipset configuration --------------- # Pick your flash size: "512KB", "1MB", or "4MB" @@ -212,6 +216,14 @@ Q := @ vecho := @echo endif +ifneq ($(strip $(STA_SSID)),) +CFLAGS+= -DSTA_SSID="$(STA_SSID)" +endif + +ifneq ($(strip $(STA_PASS)),) +CFLAGS+= -DSTA_PASS="$(STA_PASS)" +endif + ifeq ("$(GZIP_COMPRESSION)","yes") CFLAGS += -DGZIP_COMPRESSION endif diff --git a/include/espmissingincludes.h b/include/espmissingincludes.h index c69b9fc..86128ff 100644 --- a/include/espmissingincludes.h +++ b/include/espmissingincludes.h @@ -37,6 +37,12 @@ void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *fn, void *parg); void ets_update_cpu_frequency(int freqmhz); +#ifdef SDK_DBG +#define DEBUG_SDK true +#else +#define DEBUG_SDK false +#endif + int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2))); int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4))); int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); diff --git a/user/user_main.c b/user/user_main.c index f454c17..a52c971 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -105,6 +105,14 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) { #endif void user_rf_pre_init(void) { + system_set_os_print(DEBUG_SDK); +#if defined(STA_SSID) && defined(STA_PASS) + struct station_config stconf; + os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32); + os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64); + stconf.bssid_set = 0; + wifi_station_set_config_current(&stconf); +#endif } // address of espfs binary blob