When compiling the following lua script in Arduino 1.8.16 to be loaded to NodeMCU 8266 MOD 12-F I get a failure message (attached after the script). I am new in the whole Arduino (and SW overall..) topics and just trying to build some DYI based on the NodeMCU. I would appreciate an advice on what is wrong or missing here.. Thanks a lot in advance!
wifi.setmode (wifi.STATION)
wifi.sta.config ("BudSpencer", "PaPAT2xx1", 1)
wifi.sta.connect ()
print (wifi.sta.getip ())
bell1 = 2
pin1 = 3
led1 = 4
gpio.mode (pin1, gpio.OUTPUT)
gpio.mode (led1, gpio.OUTPUT)
gpio.mode (bell1, gpio.INPUT, gpio.PULLUP);
gpio.write (pin1, gpio.LOW)
gpio.write (led1, gpio.HIGH)
srv = net.createServer (net.TCP) srv: listen (80, function (conn)
conn: on ("receive", function ( client, request)
local buf = "";
local , , method, path, vars = string.find (request, "([AZ] +) HTTP"). (+)? (+.);
if (method == nil) then
,, method, path = string.find (request, "([AZ] +) (. +) HTTP");
end
local _GET = {}
if (vars ~ = nil) then
for k, v in string.gmatch (vars, "(% w +) = (% w +) & *") do
_GET [k] = v
end
end
buf = buf .. "
NodeMCU Door Opener
";
buf = buf .. "Door OPEN
";
local _on, _off = "", ""
if (_GET.pin == "OPEN") then
gpio.write (led1, gpio.LOW)
gpio.write (pin1, gpio.HIGH)
tmr.delay (1000 * 2000)
gpio.write (led1, gpio.
end
client: send (buf);
client: close ();
collectgarbage ();
end)
end)
lock = 0
function callback ()
if lock == 0 then
lock = 1
print ("called")
print ("notify ()")
http.post ('http://192.168.178.5:9999/bell ',
' Content-Type: application / json \ r \ n ',
' {"hello": "world"} ',
nil)
lock = 0
end
end
gpio.trig (bell1, "up", callback)
The failure message - Arduino: 1.8.16 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
sketch_oct05a:26:21: error: missing terminating " character
26 | buf = buf.."
| ^
sketch_oct05a:28:2: error: missing terminating " character
28 | ";
| ^~
sketch_oct05a:29:21: error: missing terminating " character
29 | buf = buf.."Door OPEN
| ^~~~~~~~~~
sketch_oct05a:30:1: error: missing terminating " character
30 | ";
| ^~
sketch_oct05a:1:1: error: 'wifi' does not name a type
1 | wifi.setmode(wifi.STATION)
| ^~~~
sketch_oct05a:11:2: error: 'gpio' does not name a type
11 | gpio.write(pin1, gpio.LOW)
| ^~~~
sketch_oct05a:16:10: error: 'local' does not name a type
16 | local , , method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
| ^~~~~
sketch_oct05a:17:10: error: expected unqualified-id before 'if'
17 | if(method == nil) then
| ^~
sketch_oct05a:19:10: error: 'end' does not name a type
19 | end
| ^~~
sketch_oct05a:21:10: error: expected unqualified-id before 'if'
21 | if (vars ~= nil)then
| ^~
sketch_oct05a:40:16: error: found ':' in nested-name-specifier, expected '::'
40 | client:close();
| ^
| ::
sketch_oct05a:40:10: error: 'client' does not name a type
40 | client:close();
| ^~~~~~
sketch_oct05a:41:26: error: expected constructor, destructor, or type conversion before ';' token
41 | collectgarbage();
| ^
sketch_oct05a:42:6: error: 'end' does not name a type
42 | end)
| ^~~
exit status 1
missing terminating " character
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.