Fix example server-side scripts to work on new nodemcu-firmware. Specifically, call coroutine.yield() after each connection:send() except the last one, since we can no longer queue sends.

This commit is contained in:
Marcos Kirsch
2016-02-15 14:20:28 -06:00
parent 4ff7b2b78d
commit 4d4442318d
4 changed files with 32 additions and 38 deletions

View File

@@ -17,6 +17,7 @@ local function pushTheButton(connection, pin)
-- Send back JSON response.
connection:send("HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
coroutine.yield()
connection:send('{"error":0, "message":"OK"}')
end
@@ -27,6 +28,7 @@ return function (connection, args)
elseif args.door == "2" then pushTheButton(connection, 2) -- GPIO2
else
connection:send("HTTP/1.0 400 OK\r\nContent-Type: application/json\r\nCache-Control: private, no-store\r\n\r\n")
coroutine.yield()
connection:send('{"error":-1, "message":"Bad door"}')
end
end