Skip to content

Commit 702066e

Browse files
committed
Added commenting
1 parent f3bb155 commit 702066e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libs/reset_device/connection_monitor.py

+12
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,33 @@
77
consecutive_active_reports = 0
88
config_hash = reset_lib.config_file_hash()
99

10+
# If auto_config is set to 0 in /etc/raspiwifi/raspiwifi.conf exit this script
1011
if config_hash['auto_config'] == "0":
1112
sys.exit()
1213
else:
14+
# Main connection monitoring loop at 10 second interval
1315
while True:
1416
time.sleep(10)
1517

18+
# If iwconfig report no association with an AP add 10 to the "No
19+
# Connection Couter"
1620
if reset_lib.is_wifi_active() == False:
1721
no_conn_counter += 10
1822
consecutive_active_reports = 0
23+
# If iwconfig report association with an AP add 1 to the
24+
# consecutive_active_reports counter and 10 to the no_conn_counter
1925
else:
2026
consecutive_active_reports += 1
2127
no_conn_counter += 10
28+
# Since wpa_supplicant seems to breifly associate with an AP for
29+
# 6-8 seconds to check the network key the below will reset the
30+
# no_conn_counter to 0 only if two 10 second checks have come up active.
2231
if consecutive_active_reports >= 2:
2332
no_conn_counter = 0
2433
consecutive_active_reports = 0
2534

35+
# If the number of seconds not associated with an AP is greater or
36+
# equal to the auto_config_delay specified in the /etc/raspiwifi/raspiwifi.conf
37+
# trigger a reset into AP Host (Configuration) mode.
2638
if no_conn_counter >= int(config_hash['auto_config_delay']):
2739
reset_lib.reset_to_host_mode()

0 commit comments

Comments
 (0)