fix ip none issue
This commit is contained in:
7
wifi.py
7
wifi.py
@@ -144,6 +144,13 @@ class WiFiManager:
|
|||||||
wifi = network.wifi.Wifi()
|
wifi = network.wifi.Wifi()
|
||||||
if wifi.is_connected():
|
if wifi.is_connected():
|
||||||
self._wifi_connected = True
|
self._wifi_connected = True
|
||||||
|
# MaixPy 的 is_connected 可能不会同步填充 IP,这里用系统命令补齐一次
|
||||||
|
try:
|
||||||
|
ip = os.popen("ifconfig wlan0 2>/dev/null | grep 'inet ' | awk '{print $2}'").read().strip()
|
||||||
|
if ip:
|
||||||
|
self._wifi_ip = ip
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
self.logger.warning("Failed to check WiFi connection using MaixPy network", exc_info=True)
|
self.logger.warning("Failed to check WiFi connection using MaixPy network", exc_info=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user