从Arduino到Lua的GET请求(ESP8266) [英] GET Request from Arduino to Lua (ESP8266)

查看:659
本文介绍了从Arduino到Lua的GET请求(ESP8266)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的GET请求有问题. ESP8266与NodeMCU.我在Arduino中的代码:

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);

错误:

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

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

Lua在GET请求中看不到\r\n吗?

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

推荐答案

您可能需要使用双\\来代替,具体取决于您在哪里使用它(例如,发送框).

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

并且由于您正在使用\"来转义引号,因此\\n应该应该这样做.

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

这篇关于从Arduino到Lua的GET请求(ESP8266)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆