pull/65/head
Thorsten von Eicken 9 years ago
parent b912c4babe
commit de7207ac1d
  1. 35
      Makefile
  2. 23
      esp-link/main.c

@ -9,6 +9,7 @@
# `ESP_HOSTNAME=my.esp.example.com make wiflash` is an easy way to override a variable # `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 # 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... # Original from esphttpd and others...
#VERBOSE=1 #VERBOSE=1
@ -29,7 +30,9 @@ ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py)
ESPPORT ?= /dev/ttyUSB0 ESPPORT ?= /dev/ttyUSB0
ESPBAUD ?= 460800 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_SSID ?=
# STA_PASS ?= # STA_PASS ?=
@ -59,6 +62,9 @@ LED_SERIAL_PIN ?= 14
CHANGE_TO_STA ?= yes CHANGE_TO_STA ?= yes
# Optional Modules
MODULES ?= mqtt rest
# --------------- esphttpd config options --------------- # --------------- esphttpd config options ---------------
# If GZIP_COMPRESSION is set to "yes" then the static css, js, and html files will be compressed # 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/ # http://yui.github.io/yuicompressor/
# enabled by default. # enabled by default.
COMPRESS_W_HTMLCOMPRESSOR ?= yes COMPRESS_W_HTMLCOMPRESSOR ?= yes
HTML-COMPRESSOR ?= htmlcompressor-1.5.3.jar HTML_COMPRESSOR ?= htmlcompressor-1.5.3.jar
YUI-COMPRESSOR ?= yuicompressor-2.4.8.jar YUI_COMPRESSOR ?= yuicompressor-2.4.8.jar
# Optional Modules
MODULES ?= mqtt rest
# -------------- End of config options ------------- # -------------- End of config options -------------
@ -337,18 +340,18 @@ flash: all
0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x01000 $(FW_BASE)/user1.bin \ 0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x01000 $(FW_BASE)/user1.bin \
$(ET_BLANK) $(SDK_BASE)/bin/blank.bin $(ET_BLANK) $(SDK_BASE)/bin/blank.bin
tools/$(HTML-COMPRESSOR): tools/$(HTML_COMPRESSOR):
$(Q) mkdir -p tools $(Q) mkdir -p tools
ifeq ($(OS),Windows_NT) 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://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://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR) -O $(HTML_COMPRESSOR)
else else
cd tools; wget https://github.com/yui/yuicompressor/releases/download/v2.4.8/$(YUI-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) cd tools; wget https://htmlcompressor.googlecode.com/files/$(HTML_COMPRESSOR)
endif endif
ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes")
$(BUILD_BASE)/espfs_img.o: tools/$(HTML-COMPRESSOR) $(BUILD_BASE)/espfs_img.o: tools/$(HTML_COMPRESSOR)
endif endif
$(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage $(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; $(Q) cp -r html/wifi/*.js html_compressed/wifi;
ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes")
$(Q) echo "Compression assets with htmlcompressor. This may take a while..." $(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 \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \
-o $(abspath ./html_compressed)/ \ -o $(abspath ./html_compressed)/ \
$(HTML_PATH)head- \ $(HTML_PATH)head- \
$(HTML_PATH)*.html $(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 \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \
-o $(abspath ./html_compressed)/wifi/ \ -o $(abspath ./html_compressed)/wifi/ \
$(WIFI_PATH)*.html $(WIFI_PATH)*.html
$(Q) echo "Compression assets with yui-compressor. This may take a while..." $(Q) echo "Compression assets with yui-compressor. This may take a while..."
$(Q) for file in `find html_compressed -type f -name "*.js"`; do \ $(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 done
$(Q) for file in `find html_compressed -type f -name "*.css"`; do \ $(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 done
endif endif
ifeq (,$(findstring mqtt,$(MODULES))) ifeq (,$(findstring mqtt,$(MODULES)))

@ -119,23 +119,18 @@ void user_init(void) {
os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*"); os_printf("Flash config restore %s\n", restoreOk ? "ok" : "*FAILED*");
#if defined(STA_SSID) && defined(STA_PASS) #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) { os_strncpy((char*)stconf.ssid, VERS_STR(STA_SSID), 32);
struct station_config stconf; os_strncpy((char*)stconf.password, VERS_STR(STA_PASS), 64);
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);
#ifdef CGIWIFI_DBG #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 #endif
wifi_set_opmode(3); wifi_set_opmode(3); // sta+ap, will switch to sta-only 15 secs after connecting
stconf.bssid_set = 0; stconf.bssid_set = 0;
wifi_station_set_config(&stconf); wifi_station_set_config(&stconf);
}
}
#endif #endif
// Status LEDs // Status LEDs

Loading…
Cancel
Save