diff --git a/components/wifi-manager/CMakeLists.txt b/components/wifi-manager/CMakeLists.txt index 4d0b9cb3..b3cd1206 100644 --- a/components/wifi-manager/CMakeLists.txt +++ b/components/wifi-manager/CMakeLists.txt @@ -2,7 +2,8 @@ idf_component_register(SRCS "dns_server.c" "http_server.c" "wifi_manager.c" INCLUDE_DIRS . REQUIRES esp_common PRIV_REQUIRES newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant cmd_system - EMBED_FILES style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz + EMBED_FILES style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz battery-0.svg battery-1.svg battery-2.svg battery-3.svg battery-4.svg + ) - \ No newline at end of file + diff --git a/components/wifi-manager/component.mk b/components/wifi-manager/component.mk index d4559677..ab0b7a49 100644 --- a/components/wifi-manager/component.mk +++ b/components/wifi-manager/component.mk @@ -6,7 +6,8 @@ # lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable, # please read the SDK documents if you need to do this. # -COMPONENT_EMBED_FILES := style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz +COMPONENT_EMBED_FILES := style.css code.js index.html bootstrap.min.css.gz jquery.min.js.gz popper.min.js.gz bootstrap.min.js.gz battery-0.svg battery-1.svg battery-2.svg battery-3.svg battery-4.svg + #CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_DEBUG CFLAGS += -D LOG_LOCAL_LEVEL=ESP_LOG_INFO \ -I$(COMPONENT_PATH)/../tools diff --git a/components/wifi-manager/http_server.c b/components/wifi-manager/http_server.c index 2e96b0d1..d9c50775 100644 --- a/components/wifi-manager/http_server.c +++ b/components/wifi-manager/http_server.c @@ -77,6 +77,16 @@ extern const uint8_t code_js_start[] asm("_binary_code_js_start"); extern const uint8_t code_js_end[] asm("_binary_code_js_end"); extern const uint8_t index_html_start[] asm("_binary_index_html_start"); extern const uint8_t index_html_end[] asm("_binary_index_html_end"); +extern const uint8_t battery-0_svg_start[] asm("_binary_battery-0_svg_start"); +extern const uint8_t battery-0_svg_end[] asm("_binary_battery-0_svg_end"); +extern const uint8_t battery-1_svg_start[] asm("_binary_battery-1_svg_start"); +extern const uint8_t battery-1_svg_end[] asm("_binary_battery-1_svg_end"); +extern const uint8_t battery-2_svg_start[] asm("_binary_battery-2_svg_start"); +extern const uint8_t battery-2_svg_end[] asm("_binary_battery-2_svg_end"); +extern const uint8_t battery-3_svg_start[] asm("_binary_battery-3_svg_start"); +extern const uint8_t battery-3_svg_end[] asm("_binary_battery-3_svg_end"); +extern const uint8_t battery-4_svg_start[] asm("_binary_battery-4_svg_start"); +extern const uint8_t battery-4_svg_end[] asm("_binary_battery-4_svg_end"); /* const http headers stored in ROM */ @@ -84,6 +94,7 @@ const static char http_hdr_template[] = "HTTP/1.1 200 OK\nContent-type: %s\nAcce const static char http_html_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/html\nAccess-Control-Allow-Origin: *\nAccept-Encoding: identity\n\n"; const static char http_css_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/css\nCache-Control: public, max-age=31536000\nAccess-Control-Allow-Origin: *\n\n"; const static char http_js_hdr[] = "HTTP/1.1 200 OK\nContent-type: text/javascript\nAccess-Control-Allow-Origin: *\n\n"; +const static char http_svg_hdr[] = "HTTP/1.1 200 OK\nContent-type: image/svg+xml\nAccess-Control-Allow-Origin: *\n\n"; const static char http_400_hdr[] = "HTTP/1.1 400 Bad Request\nContent-Length: 0\n\n"; const static char http_404_hdr[] = "HTTP/1.1 404 Not Found\nContent-Length: 0\n\n"; const static char http_503_hdr[] = "HTTP/1.1 503 Service Unavailable\nContent-Length: 0\n\n"; @@ -393,6 +404,26 @@ void http_server_netconn_serve(struct netconn *conn) { else if(strstr(line, "GET /bootstrap.css ")) { http_server_send_resource_file(conn,bootstrap_css_gz_start, bootstrap_css_gz_end, "text/css", "gzip" ); } + else if(strstr(line, "GET /battery-0.svg ")) { + netconn_write(conn, http_svg_hdr, sizeof(http_svg_hdr) - 1, NETCONN_NOCOPY); + netconn_write(conn, battery-0_svg_start, battery-0_svg_end - battery-0_svg_start, NETCONN_NOCOPY); + } + else if(strstr(line, "GET /battery-1.svg ")) { + netconn_write(conn, http_svg_hdr, sizeof(http_svg_hdr) - 1, NETCONN_NOCOPY); + netconn_write(conn, battery-1_svg_start, battery-1_svg_end - battery-1_svg_start, NETCONN_NOCOPY); + } + else if(strstr(line, "GET /battery-2.svg ")) { + netconn_write(conn, http_svg_hdr, sizeof(http_svg_hdr) - 1, NETCONN_NOCOPY); + netconn_write(conn, battery-2_svg_start, battery-2_svg_end - battery-2_svg_start, NETCONN_NOCOPY); + } + else if(strstr(line, "GET /battery-3.svg ")) { + netconn_write(conn, http_svg_hdr, sizeof(http_svg_hdr) - 1, NETCONN_NOCOPY); + netconn_write(conn, battery-3_svg_start, battery-3_svg_end - battery-3_svg_start, NETCONN_NOCOPY); + } + else if(strstr(line, "GET /battery-4.svg ")) { + netconn_write(conn, http_svg_hdr, sizeof(http_svg_hdr) - 1, NETCONN_NOCOPY); + netconn_write(conn, battery-4_svg_start, battery-4_svg_end - battery-4_svg_start, NETCONN_NOCOPY); + } //dynamic stuff else if(strstr(line, "GET /scan.json ")) {