29.08.2016, 16:37
That shell solution assumes that your iOS device has a fixed IP, you can do in Lua like this. I cannot guarantee that this code will work, you have to try and debug it yourself
When phone/tablet is locked (in sleep state) sending UDP packets to port 5353 causes it to wake for a short period. During that period device can be pinged to check if it's in the network or not.
Code:
function checkiosdev(ip)
local sock, res
sock = require('socket').udp()
for i = 1, 10 do
sock:sendto('123', ip, 5353)
os.sleep(1)
end
res = os.execute('ping -c 2 -W 10 ' .. ip)
return res == 0
end
seen = checkiosdev('192.168.1.10')
grp.update('1/1/1', seen)
When phone/tablet is locked (in sleep state) sending UDP packets to port 5353 causes it to wake for a short period. During that period device can be pinged to check if it's in the network or not.