(31.12.2020, 12:14)admin Wrote: This depends on what kind of router you have and how easy it is to get information from it. Mikrotik is fully supported, Unify should also be possible via HTTP API. If you want to do presence detection this way you need ARP table instead of DHCP.
Can you tell me how to do? I use os.execute('arp -a') or get info from proc/net/arp but they show nothing.
I want to find a device that use DHCP (because it doesnt has option to use static IP) and want to find it whenever it's local IP change. Currently I use this code to ping to every IP from 1 to 255 and find it but it's way too slow. So it's best if I can find IP of all device on the network, and look for it by it's name or MAC but I dont know how to do
Code:
for i = 1, 255 do
ip = '192.168.1.' .. i
res = os.execute('ping -c 2 -W 1 ' .. ip)
if res == 0 then
url='http://'..ip..'/httpapi.asp?command=getPlayerStatus'
require('socket.http')
res, err = socket.http.request(url)
if res ~= nil then
t1, t2 = string.find(res, 'Artist')
if t1 ~= nil then
--my code
break
end
end
end