[wifi] short wait time
This commit is contained in:
parent
a64b22c329
commit
3e88c60997
|
@ -128,7 +128,7 @@ def close_hotspot():
|
|||
def check_wifi_connection():
|
||||
cmd = "nmcli dev status"
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||
time.sleep(2)
|
||||
time.sleep(0.5)
|
||||
output = result.stdout.strip()
|
||||
lines = output.split("\n")[1:] # Skip the header line
|
||||
for line in lines:
|
||||
|
@ -162,7 +162,7 @@ def check_wifi_connection():
|
|||
network_error_light_1()
|
||||
subprocess.Popen('sudo systemctl restart NetworkManager', shell=True)
|
||||
# subprocess.run(['sudo', 'systemctl', 'restart', 'NetworkManager'], check=True)
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
return check_wifi_connection()
|
||||
return False, None
|
||||
|
||||
|
@ -249,7 +249,7 @@ def connect_wifi(ssid, password):
|
|||
def disconnect_wifi():
|
||||
try:
|
||||
output = subprocess.check_output(['nmcli', 'dev', 'disconnect', 'iface', 'wlan0'])
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
output_str = output.decode('utf-8') # 将输出转换为字符串
|
||||
if "successfully disconnected" in output_str:
|
||||
print(f"{datetime.datetime.now()}: Wi-Fi disconnected successfully")
|
||||
|
@ -308,9 +308,9 @@ def submit():
|
|||
# 关闭热点
|
||||
close_hotspot()
|
||||
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
scan_wifi()
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
|
||||
# 连接到用户选择的 Wi-Fi 网络
|
||||
if connect_wifi(ssid, password):
|
||||
|
|
Loading…
Reference in New Issue