问题
I have a problem with my GET request. ESP8266 with NodeMCU. My code in Arduino:
String cmd = "conn:send(\"GET /json.htm?type=command¶m=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¶m=udevice&idx=2&nvalue=0&svalue=11 HTTP/1.1Host: 192'
Doesn't Lua see \r\n
in GET requests?
回答1:
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.
来源:https://stackoverflow.com/questions/34568769/get-request-from-arduino-to-lua-esp8266