Skip to content

Commit

Permalink
reduce calls to revert and reconf
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Nov 3, 2024
1 parent 55f4f07 commit 7052fdc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ffac-ssid-changer/luasrc/lib/gluon/ssid-changer/ssid-changer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ end

if status == 'online' then
log_debug("node is online")
os.execute('uci revert wireless && wifi reconf')
elseif status == 'offline' then
-- only revert and reconf if we were offline in the current monitoring timeframe or before
-- to reduce impact
if off_count > 0 then
uci:revert('wireless')
os.execute('wifi reconf')
end
elseif status == 'offline' or off_count > 0 then
-- either we are offline or the tq is in the variable range and was considered offline before
log_debug("node is considered offline")
local first = tonumber(uci:get('ssid-changer', 'settings', 'first') or 5)
-- set SSID offline, only if uptime is less than FIRST or exactly a multiplicative of switch_timeframe
Expand All @@ -165,6 +171,7 @@ elseif status == 'offline' then
if owe_ssid then
uci:set('wireless', 'owe_radio' .. i, 'enabled', 0)
end
-- save does not commit
uci:save('wireless')
end
os.execute('wifi reconf')
Expand All @@ -178,6 +185,10 @@ end

if is_switch_time == 0 then
file = io.open(tmp, 'w')
file:write("0")
if status == 'offline' then
file:write("1")
else
file:write("0")
end
file:close()
end

0 comments on commit 7052fdc

Please sign in to comment.