UDP廣播 MAC地址


 1 enduser_setup.start()
 2 ListenPort = 8080        
 3 wifi.setmode(wifi.STATIONAP)
 4 
 5 wifi.sta.autoconnect(1)
 6 
 7 clientid = wifi.sta.getmac()
 8 print(clientid)
 9 UdpSocket = net.createUDPSocket()
10 UdpSocket:listen(ListenPort)
11 UdpSocket:on("receive", function(s, data, port, ip)
12     print(string.format("received '%s' from %s:%d", data, ip, port))
13     s:send(port, ip, "echo: " .. clientid)
14 end)
15 
16 printip = 0
17 wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
18     printip = 0
19 end)
20 wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
21    if printip == 0 then
22       print("+IP "..T.IP)
23       RSSI=wifi.sta.getrssi()--信號
24 print("RSSI is", RSSI)
25    end
26    printip = 1
27 end)

打開UDP訪問192.168.8.197   4000端口

隨意發送 

收到設備MAC地址

 

能在此遇見是我們的緣分,我願意幫助你,相信你一定可以取得成功!


掃碼關注微信公眾號  “小樊Study”獲取更多

 

QQ群 

淘寶店鋪

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM