GET Request from Arduino to Lua (ESP8266)

限于喜欢 提交于 2019-12-24 16:04:03

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!