|
[nodemcu lua] nodemcu ping ip地址
- ip = "992.166.10.10"
- function ping_resp(b, ip, sq, tm)
- print(string.format("%d bytes from %s, icmp_seq=%d time=%dms", b, ip, sq, tm))
- if b == 0 then
- print("i am not here")
- end
- if b ~= 0 then
- print("i am here")
- end
- end
- net.ping(ip, 1, ping_resp)
- tmr.create():alarm(1000, tmr.ALARM_SINGLE, function() net.ping(ip, 1, ping_resp) end)
复制代码 可以用作检测ip地址能否ping通然后作出反应.
|
|