Add a wifi scan trigger for when the nodes detected becomes zero

This commit is contained in:
Tim Wilkinson 2022-09-10 10:50:05 -07:00 committed by Joe AE6XE
parent e37708641e
commit 5efd0276fe
1 changed files with 9 additions and 0 deletions

View File

@ -58,6 +58,7 @@ if not file_exists(logfile) then
end end
local multiple_ant = false local multiple_ant = false
local last_station_count = 0
local log = aredn.log.open(logfile, 16000) local log = aredn.log.open(logfile, 16000)
@ -101,9 +102,11 @@ function run_monitor()
os.execute("/usr/sbin/iw " .. wifiiface .. " scan freq " .. aredn_info.getFreq() .. " passive") os.execute("/usr/sbin/iw " .. wifiiface .. " scan freq " .. aredn_info.getFreq() .. " passive")
end end
local station_count = 0
local rssi = get_rssi(wifiiface) local rssi = get_rssi(wifiiface)
for mac, info in pairs(rssi) for mac, info in pairs(rssi)
do do
station_count = station_count + 1
local rssih = rssi_hist[mac] local rssih = rssi_hist[mac]
if rssih and now - rssih.last < 3600 then if rssih and now - rssih.last < 3600 then
local hit = 0 local hit = 0
@ -188,7 +191,13 @@ function run_monitor()
rssih.num = rssih.num + 1 rssih.num = rssih.num + 1
end end
end end
elseif station_count == 0 and last_station_count ~= 0 then
-- reset
os.execute("/usr/sbin/iw " .. wifiiface .. " scan freq " .. aredn_info.getFreq() .. " passive")
wait_for_ticks(5)
log:write("No stations detected")
end end
last_station_count = station_count
local f = io.open(datfile, "w") local f = io.open(datfile, "w")
if f then if f then