저는 ESP8266에 새로 입문했습니다. 루아 코드에 WebSockets을 추가하려고 시도하지만, documentation을보고 WebSocket을 사용할 때마다, 장치는 글로벌 websocket
(nil
값) 색인을 생성하려고 시도 할 때 오류를 던집니다. 나는 수입 할 것이 있다면 정말로 확신하지 못합니다. 누구든지 이걸 도와주세요.글로벌 'websocket'색인 생성 시도
function connectToSocket()
print ("Connect to socket called, OK.")
local ws_client = websocket.createClient()
end
wifi.setphymode(wifi.PHYMODE_N)
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PWD")
wifi.sta.eventMonReg(wifi.STA_IDLE, function() print("IDLE") end)
wifi.sta.eventMonReg(wifi.STA_CONNECTING, function() print("CONNECTING...") end)
wifi.sta.eventMonReg(wifi.STA_WRONGPWD, function() print("WRONG PASSWORD!!!") end)
wifi.sta.eventMonReg(wifi.STA_APNOTFOUND, function() print("NO SUCH SSID FOUND") end)
wifi.sta.eventMonReg(wifi.STA_FAIL, function() print("FAILED TO CONNECT") end)
wifi.sta.eventMonReg(wifi.STA_GOTIP, function()
print("GOT IP "..wifi.sta.getip())
connectToSocket()
end)
wifi.sta.eventMonStart()
wifi.sta.connect()
NodeMCU 펌웨어 빌드를 어떻게 구성 했습니까? (https://nodemcu-build.com/) 스크립트의 첫 줄에'websocket = require ("websocket")'을 넣으려고 했습니까? –