diff --git a/Makefile b/Makefile index 3d4c186..3e83e64 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ # `ESP_HOSTNAME=my.esp.example.com make wiflash` is an easy way to override a variable # # Makefile heavily adapted to esp-link and wireless flashing by Thorsten von Eicken +# Lots of work, in particular to support windows, by brunnels # Original from esphttpd and others... #VERBOSE=1 @@ -29,7 +30,9 @@ ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) ESPPORT ?= /dev/ttyUSB0 ESPBAUD ?= 460800 -# Build time Wifi Cfg +# The Wifi station configuration can be hard-coded here, which makes esp-link come up in STA+AP +# mode trying to connect to the specified AP. It will only switch to STA-only a few seconds after +# actually connecting the AP. # STA_SSID ?= # STA_PASS ?= @@ -59,6 +62,9 @@ LED_SERIAL_PIN ?= 14 CHANGE_TO_STA ?= yes +# Optional Modules +MODULES ?= mqtt rest + # --------------- esphttpd config options --------------- # If GZIP_COMPRESSION is set to "yes" then the static css, js, and html files will be compressed @@ -83,11 +89,8 @@ GZIP_COMPRESSION ?= yes # http://yui.github.io/yuicompressor/ # enabled by default. COMPRESS_W_HTMLCOMPRESSOR ?= yes -HTML-COMPRESSOR ?= htmlcompressor-1.5.3.jar -YUI-COMPRESSOR ?= yuicompressor-2.4.8.jar - -# Optional Modules -MODULES ?= mqtt rest +HTML_COMPRESSOR ?= htmlcompressor-1.5.3.jar +YUI_COMPRESSOR ?= yuicompressor-2.4.8.jar # -------------- End of config options ------------- @@ -337,18 +340,18 @@ flash: all 0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x01000 $(FW_BASE)/user1.bin \ $(ET_BLANK) $(SDK_BASE)/bin/blank.bin -tools/$(HTML-COMPRESSOR): +tools/$(HTML_COMPRESSOR): $(Q) mkdir -p tools ifeq ($(OS),Windows_NT) - cd tools; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI-COMPRESSOR) -O $(YUI-COMPRESSOR) - cd tools; wget --no-check-certificate https://htmlcompressor.googlecode.com/files/$(HTML-COMPRESSOR) -O $(HTML-COMPRESSOR) + cd tools; wget --no-check-certificate https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR) -O $(YUI_COMPRESSOR) + cd tools; wget --no-check-certificate https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR) -O $(HTML_COMPRESSOR) else - cd tools; wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI-COMPRESSOR) - cd tools; wget https://htmlcompressor.googlecode.com/files/$(HTML-COMPRESSOR) + cd tools; wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI_COMPRESSOR) + cd tools; wget https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR) endif ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") -$(BUILD_BASE)/espfs_img.o: tools/$(HTML-COMPRESSOR) +$(BUILD_BASE)/espfs_img.o: tools/$(HTML_COMPRESSOR) endif $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage @@ -360,21 +363,21 @@ $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage $(Q) cp -r html/wifi/*.js html_compressed/wifi; ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") $(Q) echo "Compression assets with htmlcompressor. This may take a while..." - $(Q) java -jar tools/$(HTML-COMPRESSOR) \ + $(Q) java -jar tools/$(HTML_COMPRESSOR) \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -o $(abspath ./html_compressed)/ \ $(HTML_PATH)head- \ $(HTML_PATH)*.html - $(Q) java -jar tools/$(HTML-COMPRESSOR) \ + $(Q) java -jar tools/$(HTML_COMPRESSOR) \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -o $(abspath ./html_compressed)/wifi/ \ $(WIFI_PATH)*.html $(Q) echo "Compression assets with yui-compressor. This may take a while..." $(Q) for file in `find html_compressed -type f -name "*.js"`; do \ - java -jar tools/$(YUI-COMPRESSOR) $$file -o $$file; \ + java -jar tools/$(YUI_COMPRESSOR) $$file -o $$file; \ done $(Q) for file in `find html_compressed -type f -name "*.css"`; do \ - java -jar tools/$(YUI-COMPRESSOR) $$file -o $$file; \ + java -jar tools/$(YUI_COMPRESSOR) $$file -o $$file; \ done endif ifeq (,$(findstring mqtt,$(MODULES))) diff --git a/esp-link/main.c b/esp-link/main.c index e44d0a1..7c20d04 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -119,23 +119,18 @@ void user_init(void) { os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); #if defined(STA_SSID) && defined(STA_PASS) - int x = wifi_get_opmode() & 0x3; + struct station_config stconf; + wifi_station_get_config(&stconf); - if (x == 2) { - struct station_config stconf; - wifi_station_get_config(&stconf); - - if (os_strlen((char*)stconf.ssid) == 0 && os_strlen((char*)stconf.password) == 0) { - os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32); - os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64); + os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32); + os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64); #ifdef CGIWIFI_DBG - os_printf("Wifi pre-config trying to connect to AP %s pw %s\n", (char*)stconf.ssid, (char*)stconf.password); + os_printf("Wifi pre-config trying to connect to AP %s pw %s\n", + (char*)stconf.ssid, (char*)stconf.password); #endif - wifi_set_opmode(3); - stconf.bssid_set = 0; - wifi_station_set_config(&stconf); - } - } + wifi_set_opmode(3); // sta+ap, will switch to sta-only 15 secs after connecting + stconf.bssid_set = 0; + wifi_station_set_config(&stconf); #endif // Status LEDs