From 287b8a0c717412a970c14c2603058bc041b11928 Mon Sep 17 00:00:00 2001 From: Rutger Huijgen Date: Thu, 23 Apr 2020 20:01:41 +0200 Subject: [PATCH 1/2] Made the embed.py script OS undepended --- tools/embed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/embed.py b/tools/embed.py index 9388b38..c80d5b3 100755 --- a/tools/embed.py +++ b/tools/embed.py @@ -15,7 +15,7 @@ def gen_embedded(content): def process_part(part): return "\n".join( "\"" + line.lstrip().replace('"', '\\"') + "\"" - for line in part.split("\n") + for line in part.splitlines() if line.strip() ) From d31ff82f4c355c99c8b11b7babff8b1e8c63456f Mon Sep 17 00:00:00 2001 From: Rutger Huijgen Date: Fri, 1 May 2020 17:33:08 +0200 Subject: [PATCH 2/2] Made the HTTP socket reusable --- src/wifi_config.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wifi_config.c b/src/wifi_config.c index 92cf58a..ebe3c12 100644 --- a/src/wifi_config.c +++ b/src/wifi_config.c @@ -371,12 +371,13 @@ static void http_task(void *arg) { INFO("Starting HTTP server"); struct sockaddr_in serv_addr; - int listenfd = socket(AF_INET, SOCK_STREAM, 0); + int listenfd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); memset(&serv_addr, '0', sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(WIFI_CONFIG_SERVER_PORT); int flags; + int enable = 1; if ((flags = lwip_fcntl(listenfd, F_GETFL, 0)) < 0) { ERROR("Failed to get HTTP socket flags"); lwip_close(listenfd); @@ -389,6 +390,11 @@ static void http_task(void *arg) { vTaskDelete(NULL); return; } + if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) < 0) { + ERROR("Error in setsockopt"); + lwip_close(listenfd); + return; + } bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); listen(listenfd, 2);