From ccc179f533205f7a61ddebd14c749649bf6a8459 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Tue, 9 Jun 2015 17:47:48 +0800 Subject: [PATCH] Big-arse structure change: readying esphttpd for a split into a library and an usage example --- .gitmodules | 2 +- Makefile | 92 +++--------- esphttpdconfig.mk | 28 ++++ libesphttpd/.gitignore | 9 ++ libesphttpd/Makefile | 140 ++++++++++++++++++ {httpd => libesphttpd/core}/auth.c | 0 {httpd => libesphttpd/core}/base64.c | 0 {httpd => libesphttpd/core}/base64.h | 0 {httpd => libesphttpd/core}/httpd.c | 0 {httpd => libesphttpd/core}/httpdespfs.c | 0 {espfs => libesphttpd/espfs}/espfs.c | 0 {espfs => libesphttpd/espfs}/espfsformat.h | 0 .../espfs}/espfstest/Makefile | 0 {espfs => libesphttpd/espfs}/espfstest/main.c | 0 .../espfs}/heatshrink_config_custom.h | 0 .../espfs}/heatshrink_decoder.c | 0 .../espfs}/mkespfsimage/Makefile | 2 +- .../espfs}/mkespfsimage/heatshrink_encoder.c | 0 .../espfs}/mkespfsimage/main.c | 0 {httpd => libesphttpd/include}/auth.h | 0 {user => libesphttpd/include}/captdns.h | 0 {user => libesphttpd/include}/cgiflash.h | 0 {user => libesphttpd/include}/cgiwifi.h | 0 {include => libesphttpd/include}/esp8266.h | 2 +- {espfs => libesphttpd/include}/espfs.h | 0 .../include}/espmissingincludes.h | 0 {httpd => libesphttpd/include}/httpd.h | 0 {httpd => libesphttpd/include}/httpdespfs.h | 0 libesphttpd/include/user_config.h | 1 + {lib => libesphttpd/lib}/heatshrink | 0 {user => libesphttpd/util}/captdns.c | 0 {user => libesphttpd/util}/cgiflash.c | 6 + {user => libesphttpd/util}/cgiwifi.c | 0 user/stdout.c | 2 +- 34 files changed, 207 insertions(+), 77 deletions(-) create mode 100644 esphttpdconfig.mk create mode 100644 libesphttpd/.gitignore create mode 100644 libesphttpd/Makefile rename {httpd => libesphttpd/core}/auth.c (100%) rename {httpd => libesphttpd/core}/base64.c (100%) rename {httpd => libesphttpd/core}/base64.h (100%) rename {httpd => libesphttpd/core}/httpd.c (100%) rename {httpd => libesphttpd/core}/httpdespfs.c (100%) rename {espfs => libesphttpd/espfs}/espfs.c (100%) rename {espfs => libesphttpd/espfs}/espfsformat.h (100%) rename {espfs => libesphttpd/espfs}/espfstest/Makefile (100%) rename {espfs => libesphttpd/espfs}/espfstest/main.c (100%) rename {espfs => libesphttpd/espfs}/heatshrink_config_custom.h (100%) rename {espfs => libesphttpd/espfs}/heatshrink_decoder.c (100%) rename {espfs => libesphttpd/espfs}/mkespfsimage/Makefile (80%) rename {espfs => libesphttpd/espfs}/mkespfsimage/heatshrink_encoder.c (100%) rename {espfs => libesphttpd/espfs}/mkespfsimage/main.c (100%) rename {httpd => libesphttpd/include}/auth.h (100%) rename {user => libesphttpd/include}/captdns.h (100%) rename {user => libesphttpd/include}/cgiflash.h (100%) rename {user => libesphttpd/include}/cgiwifi.h (100%) rename {include => libesphttpd/include}/esp8266.h (93%) rename {espfs => libesphttpd/include}/espfs.h (100%) rename {include => libesphttpd/include}/espmissingincludes.h (100%) rename {httpd => libesphttpd/include}/httpd.h (100%) rename {httpd => libesphttpd/include}/httpdespfs.h (100%) create mode 100644 libesphttpd/include/user_config.h rename {lib => libesphttpd/lib}/heatshrink (100%) rename {user => libesphttpd/util}/captdns.c (100%) rename {user => libesphttpd/util}/cgiflash.c (94%) rename {user => libesphttpd/util}/cgiwifi.c (100%) diff --git a/.gitmodules b/.gitmodules index 772d424..e0195a4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lib/heatshrink"] - path = lib/heatshrink + path = libesphttpd/lib/heatshrink url = https://github.com/atomicobject/heatshrink.git diff --git a/Makefile b/Makefile index 7b591ff..0c8e919 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,4 @@ -# --------------- esphttpd config options --------------- - -# If GZIP_COMPRESSION is set to "yes" then the static css, js, and html files will be compressed with gzip before added to the espfs image -# and will be served with gzip Content-Encoding header. -# This could speed up the downloading of these files, but might break compatibility with older web browsers not supporting gzip encoding -# because Accept-Encoding is simply ignored. Enable this option if you have large static files to serve (for e.g. JQuery, Twitter bootstrap) -# By default only js, css and html files are compressed. -# If you have text based static files with different extensions what you want to serve compressed then you will need to add the extension to the following places: -# - Add the extension to this Makefile at the webpages.espfs target to the find command -# - Add the extension to the gzippedFileTypes array in the user/httpd.c file -# -# Adding JPG or PNG files (and any other compressed formats) is not recommended, because GZIP compression does not works effectively on compressed files. - -#Static gzipping is disabled by default. -GZIP_COMPRESSION ?= no - -# If COMPRESS_W_YUI is set to "yes" then the static css and js files will be compressed with yui-compressor -# This option works only when GZIP_COMPRESSION is set to "yes" -# http://yui.github.io/yuicompressor/ -#Disabled by default. -COMPRESS_W_YUI ?= no -YUI-COMPRESSOR ?= /usr/bin/yui-compressor - -#If USE_HEATSHRINK is set to "yes" then the espfs files will be compressed with Heatshrink and decompressed -#on the fly while reading the file. Because the decompression is done in the esp8266, it does not require -#any support in the browser. -USE_HEATSHRINK ?= yes - -#Position and maximum length of espfs in flash memory -ESPFS_POS = 0x12000 -ESPFS_SIZE = 0x2E000 - -# -------------- End of esphttpd config options ------------- - # Output directors to store intermediate compiled files # relative to the project directory @@ -53,23 +19,23 @@ ESPPORT ?= /dev/ttyUSB0 ESPDELAY ?= 3 ESPBAUD ?= 460800 -# name for the target project -TARGET = httpd +#Position and maximum length of espfs in flash memory +ESPFS_POS = 0x12000 +ESPFS_SIZE = 0x2E000 +# name for the target project +TARGET = httpd + # which modules (subdirectories) of the project to include in compiling #MODULES = driver user lwip/api lwip/app lwip/core lwip/core/ipv4 lwip/netif -MODULES = espfs httpd user -EXTRA_INCDIR = include \ - . \ - lib/heatshrink/ +MODULES = user +EXTRA_INCDIR = include libesphttpd/include # libraries used in this project, mainly provided by the SDK -LIBS = c gcc hal phy pp net80211 wpa main lwip - - +LIBS = c gcc hal phy pp net80211 wpa main lwip esphttpd # compiler flags using during compilation of source files CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ @@ -139,13 +105,16 @@ $1/%.o: %.c $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ endef -.PHONY: all checkdirs clean webpages.espfs +.PHONY: all checkdirs clean libesphttpd all: checkdirs $(TARGET_OUT) $(FW_BASE) -$(TARGET_OUT): $(APP_AR) +libesphttpd: + make -C libesphttpd + +$(TARGET_OUT): $(APP_AR) libesphttpd $(vecho) "LD $@" - $(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@ + $(Q) $(LD) -Llibesphttpd -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@ $(FW_BASE): $(TARGET_OUT) $(vecho) "FW $@" @@ -165,41 +134,18 @@ $(BUILD_DIR): flash: $(TARGET_OUT) $(FW_BASE) $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin -webpages.espfs: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage -ifeq ("$(COMPRESS_W_YUI)","yes") - $(Q) rm -rf html_compressed; - $(Q) cp -r html html_compressed; - $(Q) echo "Compression assets with yui-compressor. This may take a while..." - $(Q) for file in `find html_compressed -type f -name "*.js"`; do $(YUI-COMPRESSOR) --type js $$file -o $$file; done - $(Q) for file in `find html_compressed -type f -name "*.css"`; do $(YUI-COMPRESSOR) --type css $$file -o $$file; done - $(Q) awk "BEGIN {printf \"YUI compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s html/ | sed 's/\([0-9]*\).*/\1/'`)*100}" - -# mkespfsimage will compress html, css and js files with gzip by default if enabled -# override with -g cmdline parameter - $(Q) cd html_compressed; find | ../espfs/mkespfsimage/mkespfsimage > ../webpages.espfs; cd ..; -else - $(Q) cd html; find | ../espfs/mkespfsimage/mkespfsimage > ../webpages.espfs; cd .. -endif - blankflash: $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin -espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/ - $(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)" - -htmlflash: webpages.espfs - $(Q) if [ $$(stat -c '%s' webpages.espfs) -gt $$(( $(ESPFS_SIZE) )) ]; then echo "webpages.espfs too big!"; false; fi - $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash $(ESPFS_POS) webpages.espfs +htmlflash: libesphttpd + $(Q) if [ $$(stat -c '%s' libesphttpd/webpages.espfs) -gt $$(( $(ESPFS_SIZE) )) ]; then echo "webpages.espfs too big!"; false; fi + $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash $(ESPFS_POS) libesphttpd/webpages.espfs clean: + $(Q) make -C libesphttpd clean $(Q) rm -f $(APP_AR) $(Q) rm -f $(TARGET_OUT) $(Q) find $(BUILD_BASE) -type f | xargs rm -f - $(Q) make -C espfs/mkespfsimage/ clean $(Q) rm -rf $(FW_BASE) - $(Q) rm -f webpages.espfs -ifeq ("$(COMPRESS_W_YUI)","yes") - $(Q) rm -rf html_compressed -endif $(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) diff --git a/esphttpdconfig.mk b/esphttpdconfig.mk new file mode 100644 index 0000000..cdac6de --- /dev/null +++ b/esphttpdconfig.mk @@ -0,0 +1,28 @@ +# --------------- esphttpd config options --------------- + +# If GZIP_COMPRESSION is set to "yes" then the static css, js, and html files will be compressed with gzip before added to the espfs image +# and will be served with gzip Content-Encoding header. +# This could speed up the downloading of these files, but might break compatibility with older web browsers not supporting gzip encoding +# because Accept-Encoding is simply ignored. Enable this option if you have large static files to serve (for e.g. JQuery, Twitter bootstrap) +# By default only js, css and html files are compressed. +# If you have text based static files with different extensions what you want to serve compressed then you will need to add the extension to the following places: +# - Add the extension to this Makefile at the webpages.espfs target to the find command +# - Add the extension to the gzippedFileTypes array in the user/httpd.c file +# +# Adding JPG or PNG files (and any other compressed formats) is not recommended, because GZIP compression does not works effectively on compressed files. + +#Static gzipping is disabled by default. +GZIP_COMPRESSION ?= no + +# If COMPRESS_W_YUI is set to "yes" then the static css and js files will be compressed with yui-compressor +# This option works only when GZIP_COMPRESSION is set to "yes" +# http://yui.github.io/yuicompressor/ +#Disabled by default. +COMPRESS_W_YUI ?= no +YUI-COMPRESSOR ?= /usr/bin/yui-compressor + +#If USE_HEATSHRINK is set to "yes" then the espfs files will be compressed with Heatshrink and decompressed +#on the fly while reading the file. Because the decompression is done in the esp8266, it does not require +#any support in the browser. +USE_HEATSHRINK ?= yes + diff --git a/libesphttpd/.gitignore b/libesphttpd/.gitignore new file mode 100644 index 0000000..a4674dd --- /dev/null +++ b/libesphttpd/.gitignore @@ -0,0 +1,9 @@ +build/ +espfs/mkespfsimage/*.o +espfs/mkespfsimage/mkespfsimage +webpages.espfs +libesphttpd.a +espfs/espfstest/*.o +espfs/espfstest/espfstest +*.DS_Store +html_compressed/ diff --git a/libesphttpd/Makefile b/libesphttpd/Makefile new file mode 100644 index 0000000..0b50d8f --- /dev/null +++ b/libesphttpd/Makefile @@ -0,0 +1,140 @@ + +# Directory the Makefile is in. Please don't include other Makefiles before this. +THISDIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +#Include httpd config from lower level +-include ../esphttpdconfig.mk + + +#Default options. If you want to change them, please create ../esphttpdconfig.mk with the options you want in it. +GZIP_COMPRESSION ?= no +COMPRESS_W_YUI ?= no +YUI-COMPRESSOR ?= /usr/bin/yui-compressor +USE_HEATSHRINK ?= yes + + + +# Output directors to store intermediate compiled files +# relative to the project directory +BUILD_BASE = build + +# Base directory for the compiler. Needs a / at the end; if not set it'll use the tools that are in +# the PATH. +XTENSA_TOOLS_ROOT ?= + +# base directory of the ESP8266 SDK package, absolute +SDK_BASE ?= /opt/Espressif/ESP8266_SDK + +# name for the target project +LIB = libesphttpd.a + +# which modules (subdirectories) of the project to include in compiling +#MODULES = driver user lwip/api lwip/app lwip/core lwip/core/ipv4 lwip/netif +MODULES = espfs core util +EXTRA_INCDIR = ./include \ + . \ + lib/heatshrink/ + + +# compiler flags using during compilation of source files +CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \ + -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -D_STDINT_H \ + -Wno-address + +# various paths from the SDK used in this project +SDK_LIBDIR = lib +SDK_LDDIR = ld +SDK_INCDIR = include include/json + +# select which tools to use as compiler, librarian and linker +CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc +AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar +LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc + + + +#### +#### no user configurable options below here +#### +SRC_DIR := $(MODULES) +BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) + +SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) + +SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) +OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) + +INCDIR := $(addprefix -I,$(SRC_DIR)) +EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) +MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) + +V ?= $(VERBOSE) +ifeq ("$(V)","1") +Q := +vecho := @true +else +Q := @ +vecho := @echo +endif + +ifeq ("$(GZIP_COMPRESSION)","yes") +CFLAGS += -DGZIP_COMPRESSION +endif + +ifeq ("$(USE_HEATSHRINK)","yes") +CFLAGS += -DESPFS_HEATSHRINK +endif + +vpath %.c $(SRC_DIR) + +define compile-objects +$1/%.o: %.c + $(vecho) "CC $$<" + $(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@ +endef + +.PHONY: all checkdirs clean webpages.espfs + +all: checkdirs $(LIB) webpages.espfs + + +$(LIB): $(OBJ) + $(vecho) "AR $@" + $(Q) $(AR) cru $@ $^ + +checkdirs: $(BUILD_DIR) + +$(BUILD_DIR): + $(Q) mkdir -p $@ + + +webpages.espfs: $(HTMLDIR) espfs/mkespfsimage/mkespfsimage +ifeq ("$(COMPRESS_W_YUI)","yes") + $(Q) rm -rf html_compressed; + $(Q) cp -r ../html html_compressed; + $(Q) echo "Compression assets with yui-compressor. This may take a while..." + $(Q) for file in `find html_compressed -type f -name "*.js"`; do $(YUI-COMPRESSOR) --type js $$file -o $$file; done + $(Q) for file in `find html_compressed -type f -name "*.css"`; do $(YUI-COMPRESSOR) --type css $$file -o $$file; done + $(Q) awk "BEGIN {printf \"YUI compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s ../html/ | sed 's/\([0-9]*\).*/\1/'`)*100}" + +# mkespfsimage will compress html, css and js files with gzip by default if enabled +# override with -g cmdline parameter + $(Q) cd html_compressed; find | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..; +else + $(Q) cd ../html; find | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd .. +endif + +espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/ + $(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)" + +clean: + $(Q) rm -f $(LIB) + $(Q) find $(BUILD_BASE) -type f | xargs rm -f + $(Q) make -C espfs/mkespfsimage/ clean + $(Q) rm -rf $(FW_BASE) + $(Q) rm -f webpages.espfs +ifeq ("$(COMPRESS_W_YUI)","yes") + $(Q) rm -rf html_compressed +endif + +$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir)))) diff --git a/httpd/auth.c b/libesphttpd/core/auth.c similarity index 100% rename from httpd/auth.c rename to libesphttpd/core/auth.c diff --git a/httpd/base64.c b/libesphttpd/core/base64.c similarity index 100% rename from httpd/base64.c rename to libesphttpd/core/base64.c diff --git a/httpd/base64.h b/libesphttpd/core/base64.h similarity index 100% rename from httpd/base64.h rename to libesphttpd/core/base64.h diff --git a/httpd/httpd.c b/libesphttpd/core/httpd.c similarity index 100% rename from httpd/httpd.c rename to libesphttpd/core/httpd.c diff --git a/httpd/httpdespfs.c b/libesphttpd/core/httpdespfs.c similarity index 100% rename from httpd/httpdespfs.c rename to libesphttpd/core/httpdespfs.c diff --git a/espfs/espfs.c b/libesphttpd/espfs/espfs.c similarity index 100% rename from espfs/espfs.c rename to libesphttpd/espfs/espfs.c diff --git a/espfs/espfsformat.h b/libesphttpd/espfs/espfsformat.h similarity index 100% rename from espfs/espfsformat.h rename to libesphttpd/espfs/espfsformat.h diff --git a/espfs/espfstest/Makefile b/libesphttpd/espfs/espfstest/Makefile similarity index 100% rename from espfs/espfstest/Makefile rename to libesphttpd/espfs/espfstest/Makefile diff --git a/espfs/espfstest/main.c b/libesphttpd/espfs/espfstest/main.c similarity index 100% rename from espfs/espfstest/main.c rename to libesphttpd/espfs/espfstest/main.c diff --git a/espfs/heatshrink_config_custom.h b/libesphttpd/espfs/heatshrink_config_custom.h similarity index 100% rename from espfs/heatshrink_config_custom.h rename to libesphttpd/espfs/heatshrink_config_custom.h diff --git a/espfs/heatshrink_decoder.c b/libesphttpd/espfs/heatshrink_decoder.c similarity index 100% rename from espfs/heatshrink_decoder.c rename to libesphttpd/espfs/heatshrink_decoder.c diff --git a/espfs/mkespfsimage/Makefile b/libesphttpd/espfs/mkespfsimage/Makefile similarity index 80% rename from espfs/mkespfsimage/Makefile rename to libesphttpd/espfs/mkespfsimage/Makefile index 8a39d46..0d862e7 100644 --- a/espfs/mkespfsimage/Makefile +++ b/libesphttpd/espfs/mkespfsimage/Makefile @@ -1,7 +1,7 @@ GZIP_COMPRESSION ?= no USE_HEATSHRINK ?= yes -CFLAGS=-I../../lib/heatshrink -I.. -std=gnu99 +CFLAGS=-I../../lib/heatshrink -I../../include -I.. -std=gnu99 ifeq ("$(GZIP_COMPRESSION)","yes") CFLAGS += -DESPFS_GZIP endif diff --git a/espfs/mkespfsimage/heatshrink_encoder.c b/libesphttpd/espfs/mkespfsimage/heatshrink_encoder.c similarity index 100% rename from espfs/mkespfsimage/heatshrink_encoder.c rename to libesphttpd/espfs/mkespfsimage/heatshrink_encoder.c diff --git a/espfs/mkespfsimage/main.c b/libesphttpd/espfs/mkespfsimage/main.c similarity index 100% rename from espfs/mkespfsimage/main.c rename to libesphttpd/espfs/mkespfsimage/main.c diff --git a/httpd/auth.h b/libesphttpd/include/auth.h similarity index 100% rename from httpd/auth.h rename to libesphttpd/include/auth.h diff --git a/user/captdns.h b/libesphttpd/include/captdns.h similarity index 100% rename from user/captdns.h rename to libesphttpd/include/captdns.h diff --git a/user/cgiflash.h b/libesphttpd/include/cgiflash.h similarity index 100% rename from user/cgiflash.h rename to libesphttpd/include/cgiflash.h diff --git a/user/cgiwifi.h b/libesphttpd/include/cgiwifi.h similarity index 100% rename from user/cgiwifi.h rename to libesphttpd/include/cgiwifi.h diff --git a/include/esp8266.h b/libesphttpd/include/esp8266.h similarity index 93% rename from include/esp8266.h rename to libesphttpd/include/esp8266.h index 69e6c8a..31fa332 100644 --- a/include/esp8266.h +++ b/libesphttpd/include/esp8266.h @@ -15,4 +15,4 @@ #include #include "espmissingincludes.h" -#include "uart_hw.h" + diff --git a/espfs/espfs.h b/libesphttpd/include/espfs.h similarity index 100% rename from espfs/espfs.h rename to libesphttpd/include/espfs.h diff --git a/include/espmissingincludes.h b/libesphttpd/include/espmissingincludes.h similarity index 100% rename from include/espmissingincludes.h rename to libesphttpd/include/espmissingincludes.h diff --git a/httpd/httpd.h b/libesphttpd/include/httpd.h similarity index 100% rename from httpd/httpd.h rename to libesphttpd/include/httpd.h diff --git a/httpd/httpdespfs.h b/libesphttpd/include/httpdespfs.h similarity index 100% rename from httpd/httpdespfs.h rename to libesphttpd/include/httpdespfs.h diff --git a/libesphttpd/include/user_config.h b/libesphttpd/include/user_config.h new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/libesphttpd/include/user_config.h @@ -0,0 +1 @@ + diff --git a/lib/heatshrink b/libesphttpd/lib/heatshrink similarity index 100% rename from lib/heatshrink rename to libesphttpd/lib/heatshrink diff --git a/user/captdns.c b/libesphttpd/util/captdns.c similarity index 100% rename from user/captdns.c rename to libesphttpd/util/captdns.c diff --git a/user/cgiflash.c b/libesphttpd/util/cgiflash.c similarity index 94% rename from user/cgiflash.c rename to libesphttpd/util/cgiflash.c index 7243dbd..a502c83 100644 --- a/user/cgiflash.c +++ b/libesphttpd/util/cgiflash.c @@ -39,12 +39,17 @@ int ICACHE_FLASH_ATTR cgiReadFlash(HttpdConnData *connData) { if (*pos>=0x40200000+(512*1024)) return HTTPD_CGI_DONE; else return HTTPD_CGI_MORE; } + //Cgi that allows the ESPFS image to be replaced via http POST int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) { +//Now esphttpd is a lib and doesn't know ESPFS_POS/ESPFS_SIZE, this does not work anymore. ToDo: Find some way +//to reinstate it? +#if 0 if (connData->conn==NULL) { //Connection aborted. Clean up. return HTTPD_CGI_DONE; } + if(connData->post->len > ESPFS_SIZE){ // The uploaded file is too large os_printf("ESPFS file too large\n"); @@ -63,6 +68,7 @@ int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) { os_printf("Writing at: 0x%x\n", address); spi_flash_write(address, (uint32 *)connData->post->buff, connData->post->buffLen); os_printf("Wrote %d bytes (%dB of %d)\n", connData->post->buffSize, connData->post->received, connData->post->len);//&connData->postBuff)); +#endif if (connData->post->received == connData->post->len){ httpdSend(connData, "Finished uploading", -1); diff --git a/user/cgiwifi.c b/libesphttpd/util/cgiwifi.c similarity index 100% rename from user/cgiwifi.c rename to libesphttpd/util/cgiwifi.c diff --git a/user/stdout.c b/user/stdout.c index ce1a1b6..bb4dddb 100644 --- a/user/stdout.c +++ b/user/stdout.c @@ -9,8 +9,8 @@ * ---------------------------------------------------------------------------- */ - #include +#include static void ICACHE_FLASH_ATTR stdoutUartTxd(char c) { //Wait until there is room in the FIFO