@@ -169,6 +169,19 @@ else
169169 status = ' offline'
170170end
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+
172185if 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 )
181195elseif 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 ()
213228end
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