From 5efd0276fe5925964c132a6b71af25ca2c2e93cb Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Sat, 10 Sep 2022 10:50:05 -0700 Subject: [PATCH] Add a wifi scan trigger for when the nodes detected becomes zero --- files/usr/local/bin/mgr/rssi_monitor.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/files/usr/local/bin/mgr/rssi_monitor.lua b/files/usr/local/bin/mgr/rssi_monitor.lua index 532e862b..8b540340 100644 --- a/files/usr/local/bin/mgr/rssi_monitor.lua +++ b/files/usr/local/bin/mgr/rssi_monitor.lua @@ -58,6 +58,7 @@ if not file_exists(logfile) then end local multiple_ant = false +local last_station_count = 0 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") end + local station_count = 0 local rssi = get_rssi(wifiiface) for mac, info in pairs(rssi) do + station_count = station_count + 1 local rssih = rssi_hist[mac] if rssih and now - rssih.last < 3600 then local hit = 0 @@ -188,7 +191,13 @@ function run_monitor() rssih.num = rssih.num + 1 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 + last_station_count = station_count local f = io.open(datfile, "w") if f then