NodeMCU를 사용하여 웹 서버의 LED를 켜고 끌고 싶지만 같은 오류가 발생할 때마다 컴파일합니다. 나는 초급 단계이므로 도움이 필요하다. 이 오류는 함수 listen()과 관련이 있다고 생각합니다. DNS를 변경했기 때문에 포트 80을 사용할 수 없습니다.루아 NodeMCU 웹 서버 연결 오류 (주소 스택 추적 사용 중)
오류 :
dofile("ConectarRedeWireless.lua");
192.168.137.57 255.255.255.0 192.168.137.1
ConectarRedeWireless.lua:13: address in use
stack traceback:
[C]: in function 'listen'
ConectarRedeWireless.lua:13: in main chunk
[C]: in function 'dofile'
stdin:1: in main chunk
코드 : 모든
-- Conexao na rede Wifi
wifi.setmode(wifi.STATION)
wifi.sta.config("goncalo","936674888")
print(wifi.sta.getip())
-- Definicoes do pino do led
led1 = 1
gpio.mode(led1, gpio.OUTPUT)
-- Definicoes do Web Server
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
buf = buf.."<h1><u>FILIPEFLOP</u></h1>";
buf = buf.."<h2><i>ESP8266 Web Server</i></h2>";
buf = buf.."<p><a href=\"?pin=LIGA1\"><button><b>LED 1 LIG</b></button></a> <br/><br/><a href=\"?pin=DESLIGA1\"><button><b>LED 1 DES</b></button></a></p>";
local _on,_off = "",""
if(_GET.pin == "LIGA1")then
gpio.write(led1, gpio.HIGH);
elseif(_GET.pin == "DESLIGA1")then
gpio.write(led1, gpio.LOW);
end
client:send(buf);
client:close();
collectgarbage();
end)
end)
해결 되었습니까? 더 많은 피드백이 필요합니까? –