From 3b8ae02e10018a18d073700573bde63df4c6ba7e Mon Sep 17 00:00:00 2001 From: IrvingGao <1729854488@qq.com> Date: Thu, 13 Jun 2024 15:50:31 +0800 Subject: [PATCH] [wifi] fix big bugs --- wifi_manager.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wifi_manager.py b/wifi_manager.py index 0ee4870..106cbf8 100644 --- a/wifi_manager.py +++ b/wifi_manager.py @@ -152,7 +152,7 @@ def init_networkmanager_file(): # network_error_light_1() logging.info(f"{datetime.datetime.now()}: Wi-Fi NetworkManager Error: restart NetworkManager.") subprocess.Popen('sudo systemctl restart NetworkManager', shell=True) - time.sleep(3) + time.sleep(5) # 不得修改该时间,保留足够长时间给NetworkManager重启完成,并连接以往WiFi。 # 检测 Wi-Fi 连接状态 def check_wifi_connection(): @@ -183,7 +183,7 @@ def scan_wifi(): result = subprocess.run(cmd, shell=True, capture_output=True, text=True) except subprocess.CalledProcessError as e: logging.info(f"{datetime.datetime.now()}: Error scanning Wi-Fi: {e}") - network_error_light_2() + network_error_light_1() return [] logging.info(f"{datetime.datetime.now()}: Wi-Fi scan complete...") ssid_list = [] @@ -232,10 +232,12 @@ def scan_wifi(): # logging.info("强度:", strength) wifi_list.append({'ssid': ssid, 'signal': strength, 'mac': mac_address}) - with open('scaned_wifi_list.json', 'w') as f: - json.dump(wifi_list, f) if len(wifi_list) == 15: break + with open('scaned_wifi_list.json', 'w') as f: + json.dump(wifi_list, f) + logging.info(f"{datetime.datetime.now()}: Wi-Fi scaned list: {wifi_list}") + return wifi_list