Luaを使用しているESP8266 WiFiモジュールを使用してページからデータを取得しようとしている間にペイロードがゼロになっています。ESP8266のサーバーページへのGET要求後の空のペイロードLua
は、ここに私の擬似コードです:私はNodeMCU Luaのを使用してい
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
wifi.sta.connect()
tmr.alarm(1,10000, 1, function()
if (wifi.sta.getip() == nil) then
print("IP unavaiable, Waiting...")
else
foo()
end
end)
function foo()
print("Inside foo function"..node.heap());
conn = nil
conn=net.createConnection(net.TCP,0) -- 30 seconds timeout time of server
conn:on("receive", function(conn, payload)
-- local buf = "";
startRead = false
gpioData = ""
print("payload : "..#payload);
for i = 1, #payload do
print(i);
end
end)
conn:connect(80,"server.co.in")
conn:on("connection", function(conn, payload)
print("Server Connected, sending event")
conn:send("GET /mypage?id=deadbeef HTTP/1.1 200 OK\r\nHost: server.co.in\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") end)
conn:on("sent",function(conn)
print("Closing server connection")
conn:close()
end)
end
、との推測では、私はArduinoのフレームワークを使用していても同じになります。
NodeMCU custom build by frightanic.com
branch: master
commit: 22e1adc4b06c931797539b986c85e229e5942a5f
SSL: false
modules: adc,bit,cjson,file,gpio,http,i2c,mdns,mqtt,net,node,ow,struct,tmr,uart,websocket,wifi
build built on: 2017-05-03 11:24
powered by Lua 5.1.4 on SDK 2.0.0(656edbf)
私のサーバー上のすべてのリクエストを見ることができます。つまり、サーバーのリクエストコードはOKですが、ペイロード/レスポンスは空白になります。
出力が空白になりました...
助けてください。
ドキュメントのサンプルをhttps://nodemcu.readthedocs.io/en/latest/en/modules/net/#example_5およびhttps://nodemcu.readthedocs.io/en/でご覧ください。最新/ en/modules/net /#example_6。 –