GET Request from Arduino to Lua (ESP8266)

2019-08-10 20:20发布

I have a problem with my GET request. ESP8266 with NodeMCU. My code in Arduino:

String cmd = "conn:send(\"GET /json.htm?type=command&param=udevice&idx=2&nvalue=0&svalue=11 HTTP/1.1\r\nHost: 192.168.0.101\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n\")";
wifi.println("conn=nil");
wifi.println("conn=net.createConnection(net.TCP, 0)");
wifi.println("conn:on(\"receive\", function(conn, payload) print(payload) end)");
wifi.println("conn:connect(8080, \"192.168.0.101\")");
wifi.println(cmd);

Error:

")stdin:1: unfinished string near '"GET /json.htm?type=command&param=udevice&idx=2&nvalue=0&svalue=11 HTTP/1.1Host: 192'

Doesn't Lua see \r\n in GET requests?

1条回答
ら.Afraid
2楼-- · 2019-08-10 21:12

You might need to use double \\ instead, depending on where you are using it (Send box for example).

And since you are using \" to escape the quotes, \\n should probably do it.

查看更多
登录 后发表回答