首页 > 系统服务 > 详细

UDP广播 MAC地址

时间:2019-03-22 10:34:10      阅读:311      评论:0      收藏:0      [点我收藏+]
 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地址

 

UDP广播 MAC地址

原文:https://www.cnblogs.com/fw-qql/p/10575950.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!