fix ip none issue

This commit is contained in:
gcw_4spBpAfv
2026-04-28 17:06:09 +08:00
parent 4a3b111ce4
commit 5e7db5e271

View File

@@ -144,6 +144,13 @@ class WiFiManager:
wifi = network.wifi.Wifi()
if wifi.is_connected():
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
except:
self.logger.warning("Failed to check WiFi connection using MaixPy network", exc_info=True)