国内综合精彩aⅤ无码不卡_日本少妇做爰全过程_欧美性爱在线播放免费_午夜?V日韩一区二区_免费a级毛片无码免费播放_成在人线av无码喷水_亚洲精品网站色视频_国产婷婷精品成人_老师撩起裙子让我桶的视频_秋霞影院国产

設備之間通過路由器連接

作者:zjmike | 更新時間:2019-12-26 | 瀏覽量:1457

兩個nodemcu8266通過路由器,一個作主設備,一個作從設備,沒連接成功

主設備代碼 code

gpio.mode(4,gpio.OUTPUT)
gpio.write(4,gpio.HIGH)
wifi.setmode(wifi.STATION)
cfg={}         //換了個新一點的固件,這里要用這種格式
cfg.ssid="zhou"
cfg.pwd="a12345678"
wifi.sta.config(cfg)
wifi.sta.connect()
tmr.alarm(0,1000,tmr.ALARM_AUTO,function()
if(wifi.sta.getip()==nil) then
print("wait...")
else
tmr.stop(0)
print(wifi.sta.getip())
ip_cfg={
ip="192.168.2.104",
netmask="255.255.255.0",
gateway="192.168.2.1"
}
wifi.sta.setip(ip_cfg)
print(wifi.sta.getip())
cl=net.createServer(net.TCP)
cl:listen(8181,function(sck)
sck:on("receive",function(sck,data)
print("receive:"..data)
sck:send("receive:"..data)
if (data=="play") then
gpio.write(4,gpio.LOW)
else
gpio.write(4,gpio.HIGH)
end
end)
end)
end
end)

/code

舊的固件建的服務端寫入要報錯,不知道哪里的問題

客戶端

wifi.setmode(wifi.STATION)
cfg={}
cfg.ssid="zhoujing_1"
cfg.pwd="a12345678"
wifi.sta.config(cfg)
wifi.sta.connect()
tmr.alarm(0,1000,tmr.ALARM_AUTO,function()
if(wifi.sta.getip()==nil) then
print("wait...")
else
tmr.stop(0)
print(wifi.sta.getip())
cl=net.createConnection(net.TCP)
cl:connect(8181,"192.168.2.104")
cl:on("receive", function(sck,data)
print(data)
sck:send("ok")
end)
end
end)

 


評論:共1條

18855815672 評論于:2021-12-27 08:17:27
學習中,謝謝分享。
返回頂部