Skip to content

Commit 86d51b5

Browse files
committed
Remove IW retries on boot
1 parent 9458d72 commit 86d51b5

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/common/wifi.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def connect(conn_type=config.type_hotspot,
178178
elif conn_type != config.type_hotspot:
179179
# Restart hotspot as connection failed
180180
logger.warning("Connection attempt failed.")
181-
start_hotspot()
181+
connect()
182182
else:
183183
raise WifiHotspotStartFailed
184184
except Exception:
@@ -187,7 +187,7 @@ def connect(conn_type=config.type_hotspot,
187187
if conn_type == config.type_hotspot:
188188
raise WifiHotspotStartFailed
189189
else:
190-
start_hotspot() # Restart hotspot as connection failed
190+
connect() # Restart hotspot as connection failed
191191
raise WifiConnectionFailed
192192

193193

@@ -224,7 +224,8 @@ def forget(create_new_hotspot=False):
224224
conn.Delete()
225225

226226
if create_new_hotspot:
227-
start_hotspot()
227+
refresh_networks()
228+
connect()
228229

229230
except Exception:
230231
logger.exception("Failed to delete network.")
@@ -321,12 +322,3 @@ def refresh_networks(retries=5):
321322
logger.warning("IW is not accessible. This can happen on some devices "
322323
"and is usually nothing to worry about.")
323324
return False
324-
325-
326-
def start_hotspot():
327-
# On some devices, fetching available wifi networks in the area is only
328-
# possible before the hotspot is started and therefore called here.
329-
refresh_networks()
330-
331-
# Start the connection
332-
return connect()

src/run.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from common.errors import logger
77
from common.wifi import check_wifi_status
88
from common.wifi import dnsmasq
9-
from common.wifi import start_hotspot
9+
from common.wifi import connect
10+
from common.wifi import refresh_networks
1011
from resources.system_routes import system_health_check
1112
from resources.wifi_routes import wifi_connect
1213
from resources.wifi_routes import wifi_connection_status
@@ -49,7 +50,8 @@ def handle_sigterm(*args):
4950
logger.info('Wi-Fi connection already established.')
5051
else:
5152
logger.info('Starting hotspot...')
52-
start_hotspot()
53+
refresh_networks(retries=1)
54+
connect()
5355

5456
# Configure endpoints #
5557

0 commit comments

Comments
 (0)