Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit916bce7

Browse files
Fix WifiService
1 parent0e88f9c commit916bce7

File tree

1 file changed

+12
-9
lines changed
  • internal_filesystem/lib/mpos

1 file changed

+12
-9
lines changed

‎internal_filesystem/lib/mpos/wifi.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@
2020
classWifiService():
2121

2222
wifi_busy=False# crude lock on wifi
23+
access_points= {}
2324

2425
@staticmethod
2526
defconnect():
27+
wlan=network.WLAN(network.STA_IF)
28+
wlan.active(False)# restart WiFi hardware in case it's in a bad state
29+
wlan.active(True)
2630
networks=wlan.scan()
2731
forninnetworks:
2832
ssid=n[0].decode()
2933
print(f"auto_connect: checking ssid '{ssid}'")
30-
ifssidinaccess_points:
31-
password=access_points.get(ssid).get("password")
34+
ifssidinWifiService.access_points:
35+
password=WifiService.access_points.get(ssid).get("password")
3236
print(f"auto_connect: attempting to connect to saved network{ssid} with password{password}")
33-
ifattempt_connecting(ssid,password):
37+
ifWifiService.attempt_connecting(ssid,password):
3438
print(f"auto_connect: Connected to{ssid}")
3539
returnTrue
3640
else:
@@ -44,6 +48,7 @@ def connect():
4448
defattempt_connecting(ssid,password):
4549
print(f"auto_connect.py attempt_connecting: Attempting to connect to SSID:{ssid}")
4650
try:
51+
wlan=network.WLAN(network.STA_IF)
4752
wlan.connect(ssid,password)
4853
foriinrange(10):
4954
ifwlan.isconnected():
@@ -66,8 +71,8 @@ def auto_connect():
6671
print("auto_connect thread running")
6772

6873
# load config:
69-
access_points=mpos.config.SharedPreferences("com.micropythonos.system.wifiservice").get_dict("access_points")
70-
ifnotlen(access_points):
74+
WifiService.access_points=mpos.config.SharedPreferences("com.micropythonos.system.wifiservice").get_dict("access_points")
75+
ifnotlen(WifiService.access_points):
7176
print("WifiService.py: not access points configured, exiting...")
7277
return
7378

@@ -78,13 +83,11 @@ def auto_connect():
7883
time.sleep(10)
7984
print("auto_connect: wifi connect simulation done")
8085
else:
81-
wlan=network.WLAN(network.STA_IF)
82-
wlan.active(False)# restart WiFi hardware in case it's in a bad state
83-
wlan.active(True)
84-
ifconnect():
86+
ifWifiService.connect():
8587
print("WifiService.py managed to connect.")
8688
else:
8789
print("WifiService.py did not manage to connect.")
90+
wlan=network.WLAN(network.STA_IF)
8891
wlan.active(False)# disable to conserve power
8992
WifiService.wifi_busy=False
9093

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp