From 871105dc64d2982a6d1143ccbafbcd4052b324cc Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Wed, 1 Apr 2015 22:30:35 -0500 Subject: [PATCH 1/4] Support for modifying the serial port baud rate. --- makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index 011962b..f48463a 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,8 @@ NODEMCU-UPLOADER=../nodemcu-uploader/nodemcu-uploader.py # Serial port PORT=/dev/cu.usbserial-A602HRAZ +# Bauds for the serial connection +SPEED=9600 ###################################################################### # End of user config @@ -20,13 +22,13 @@ usage: # Upload HTTP files only upload_http: $(HTTP_FILES) - @$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) # Upload httpserver lua files (init and server module) upload_server: $(LUA_FILES) - @$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) # Upload all upload: $(LUA_FILES) $(HTTP_FILES) - @$(NODEMCU-UPLOADER) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) From f7969ae12d244cf7019aba55b45527e5f848868a Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Wed, 1 Apr 2015 22:56:47 -0500 Subject: [PATCH 2/4] Fix typo in HTTP headers. I need to refactor so header creation is single sourced. Oh well. This may fix issues in Firefox --- http/args.lua | 2 +- http/file_list.lua | 2 +- http/garage_door_opener.lua | 4 ++-- http/node_info.lua | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/http/args.lua b/http/args.lua index e359f90..51e3463 100644 --- a/http/args.lua +++ b/http/args.lua @@ -1,5 +1,5 @@ return function (connection, args) - connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\Cache-Control: private, no-store\r\n\r\n") + connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n") connection:send('Arguments') connection:send('') connection:send('

Arguments

') diff --git a/http/file_list.lua b/http/file_list.lua index 8f334e3..55c1389 100644 --- a/http/file_list.lua +++ b/http/file_list.lua @@ -1,5 +1,5 @@ return function (connection, args) - connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\Cache-Control: private, no-store\r\n\r\n") + connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n") connection:send('Server File Listing') connection:send('') connection:send('

Server File Listing

') diff --git a/http/garage_door_opener.lua b/http/garage_door_opener.lua index baca7d3..65b34e4 100644 --- a/http/garage_door_opener.lua +++ b/http/garage_door_opener.lua @@ -16,7 +16,7 @@ local function pushTheButton(connection, pin) gpio.mode(pin, gpio.INPUT) -- Send back JSON response. - connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\Cache-Control: private, no-store\r\n\r\n") + connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n") connection:send('{"error":0, "message":"OK"}') end @@ -26,7 +26,7 @@ return function (connection, args) if args.door == "1" then pushTheButton(connection, 3) -- GPIO0 elseif args.door == "2" then pushTheButton(connection, 4) -- GPIO2 else - connection:send("HTTP/1.0 400 OK\r\nContent-Type: application/json\r\Cache-Control: private, no-store\r\n\r\n") + connection:send("HTTP/1.0 400 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n") connection:send('{"error":-1, "message":"Bad door"}') end end diff --git a/http/node_info.lua b/http/node_info.lua index 5d19055..0cd02d1 100644 --- a/http/node_info.lua +++ b/http/node_info.lua @@ -1,5 +1,5 @@ local function sendHeader(connection) - connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\Cache-Control: private, no-store\r\n\r\n") + connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\rCache-Control: private, no-store\r\n\r\n") end local function sendAttr(connection, attr, val) From f09fe9a6106c2124616d1a173d1833921eb6d424 Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Wed, 1 Apr 2015 22:58:25 -0500 Subject: [PATCH 3/4] Fix typo: It's json not josn --- httpserver-static.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httpserver-static.lua b/httpserver-static.lua index e48e5ce..7448fe8 100644 --- a/httpserver-static.lua +++ b/httpserver-static.lua @@ -4,7 +4,7 @@ local function getMimeType(ext) -- A few MIME types. Keep list short. If you need something that is missing, let's add it. - local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", josn="application/json", png = "image/png"} + local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", json="application/json", png = "image/png"} if mt[ext] then return mt[ext] else return "text/plain" end end From 2357415466bb24cba8ee33109146f6a6a2df0282 Mon Sep 17 00:00:00 2001 From: Marcos Kirsch Date: Wed, 1 Apr 2015 23:14:52 -0500 Subject: [PATCH 4/4] Retrofit for newer nodemcu-uploader --- makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/makefile b/makefile index f48463a..a8ddd25 100644 --- a/makefile +++ b/makefile @@ -6,7 +6,7 @@ NODEMCU-UPLOADER=../nodemcu-uploader/nodemcu-uploader.py # Serial port PORT=/dev/cu.usbserial-A602HRAZ # Bauds for the serial connection -SPEED=9600 +SPEED=115200 ###################################################################### # End of user config @@ -22,13 +22,13 @@ usage: # Upload HTTP files only upload_http: $(HTTP_FILES) - @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, $(f)) # Upload httpserver lua files (init and server module) upload_server: $(LUA_FILES) - @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, $(f)) # Upload all upload: $(LUA_FILES) $(HTTP_FILES) - @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, -f $(f) -d $(f)) + @$(NODEMCU-UPLOADER) -b $(SPEED) -p $(PORT) upload $(foreach f, $^, $(f))