Skip to content

Commit bf77b5f

Browse files
committed
ffac-ssid-changer:
this did not set the offline_ssid correctly if switch_timeframe is larger than 1
1 parent 1dcca7b commit bf77b5f

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

ffac-ssid-changer/luasrc/lib/gluon/ssid-changer/ssid-changer.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ else
169169
status = 'offline'
170170
end
171171

172+
local set_status(status) then
173+
file = io.open(tmp, 'w')
174+
state_file = io.open(tmp_state, 'w')
175+
if status == 'offline' then
176+
file:write("1")
177+
state_file:write("1")
178+
else
179+
file:write("0")
180+
state_file:write("0")
181+
end
182+
file:close()
183+
end
184+
172185
if status == 'online' then
173186
log_debug("node is online")
174187
-- only revert and reconf if we were offline in the current monitoring timeframe or before
@@ -178,6 +191,7 @@ if status == 'online' then
178191
uci:revert('wireless')
179192
os.execute('wifi reconf')
180193
end
194+
set_status(status)
181195
elseif status == 'offline' then
182196
log_debug("node is considered offline")
183197
local first = tonumber(uci:get('ssid-changer', 'settings', 'first') or 5)
@@ -186,6 +200,7 @@ elseif status == 'offline' then
186200

187201
-- check if off_count is more than half of the monitor duration
188202
if is_offline == 0 and off_count >= math.floor(monitor_duration / 2) then
203+
set_status(status)
189204
-- if has been offline for at least half checks in monitor duration
190205
-- set the SSID to the offline SSID
191206
-- and disable owe client radios
@@ -211,17 +226,3 @@ elseif status == 'offline' then
211226
file:write(tostring(off_count))
212227
file:close()
213228
end
214-
215-
if is_switch_time == 0 then
216-
file = io.open(tmp, 'w')
217-
state_file = io.open(tmp_state, 'w')
218-
219-
if status == 'offline' then
220-
file:write("1")
221-
state_file:write("1")
222-
else
223-
file:write("0")
224-
state_file:write("0")
225-
end
226-
file:close()
227-
end

0 commit comments

Comments
 (0)