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/html/style.css b/html/style.css index 29d15a3..2e111a1 100644 --- a/html/style.css +++ b/html/style.css @@ -206,6 +206,16 @@ pre.console a { color: #fff; } +#menu .hostname { + width: 140px; + border-top: 1px solid #333; + height: 20px; + padding-left: 10px; + text-align: left; + 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/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/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; } 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 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