4 Commits
Author SHA1 Message Date
linyimin abbf30d7c0 pref: wifi连接成功重新登录 2026-06-25 12:17:58 +08:00
linyimin 5cf752bb3f fix: maixcam wifi连接 2026-06-25 12:02:39 +08:00
linyimin 6d8de56bfa fix: maixcam wifi连接 2026-06-25 11:02:19 +08:00
linyimin aee1a92760 fix: wifi连接 2026-06-25 10:06:36 +08:00
4 changed files with 31 additions and 15 deletions
+1 -3
View File
@@ -1,6 +1,6 @@
id: t11
name: t11
version: 2.15.15
version: 2.15.18
author: t11
icon: ''
desc: t11
@@ -18,8 +18,6 @@ files:
- laser_manager.py
- logger_manager.py
- main.py
- model_270139.cvimodel
- model_270139.mud
- network.py
- ota_curl.sh
- ota_manager.py
+25 -10
View File
@@ -474,10 +474,10 @@ class NetworkManager:
def select_network(self, prefer_wifi=None):
"""
自动选择网络(WiFi优先)
Args:
prefer_wifi: 是否优先使用WiFiNone表示使用默认策略)
Returns:
"wifi""4g" 或 None(无可用网络)
"""
@@ -624,6 +624,11 @@ class NetworkManager:
password = inner_data.get("password")
ota_res_url = inner_data.get("url")
try:
for _f in ("/etc/wpa_supplicant.conf", "/boot/wpa_supplicant.conf", "/boot/wifi.ssid", "/boot/wifi.pass"):
try:
os.remove(_f)
except OSError:
pass
w = network.wifi.Wifi()
e = w.connect(ssid, password, wait=True, timeout=15)
err.check_raise(e, "connect wifi failed")
@@ -665,6 +670,11 @@ class NetworkManager:
ssid = inner_data.get("ssid")
password = inner_data.get("password")
try:
for _f in ("/etc/wpa_supplicant.conf", "/boot/wpa_supplicant.conf", "/boot/wifi.ssid", "/boot/wifi.pass"):
try:
os.remove(_f)
except OSError:
pass
w = network.wifi.Wifi()
e = w.connect(ssid, password, wait=True, timeout=15)
err.check_raise(e, "connect wifi failed")
@@ -678,6 +688,11 @@ class NetworkManager:
},
2,
)
self._session_force_4g = False
self.disconnect_server()
self._tcp_connected = False
self._network_type = None
self.logger.info("[conn wifi] WiFi已连接,等待主循环重新登录")
except Exception as e:
self.logger.error(f"cmd600 失败: {e}")
self.safe_enqueue(
@@ -697,7 +712,7 @@ class NetworkManager:
def connect_server(self):
"""
连接到服务器(自动选择WiFi或4G)
Returns:
bool: 是否连接成功
"""
@@ -973,11 +988,11 @@ class NetworkManager:
def tcp_send_raw(self, data: bytes, max_retries=2) -> bool:
"""
统一的TCP发送接口(自动选择WiFi或4G)
Args:
data: 要发送的数据
max_retries: 最大重试次数
Returns:
bool: 是否发送成功
"""
@@ -1148,10 +1163,10 @@ class NetworkManager:
def receive_tcp_data_via_wifi(self, timeout_ms=100):
"""
通过WiFi接收TCP数据
Args:
timeout_ms: 超时时间(毫秒)
Returns:
bytes: 接收到的数据,如果没有数据则返回 b""
"""
@@ -1189,7 +1204,7 @@ class NetworkManager:
def _upload_log_file(self, upload_url, wifi_ssid=None, wifi_password=None, include_rotated=True, max_files=None,
archive_format="tgz"):
"""上传日志文件到指定URL
Args:
upload_url: 上传目标URL,例如 "https://example.com/upload/"
wifi_ssid: WiFi SSID(可选,如果未连接WiFi则尝试连接)
@@ -1197,7 +1212,7 @@ class NetworkManager:
include_rotated: 是否包含轮转日志(app.log.1 等)
max_files: 最多打包多少个日志文件(包含 app.log 本身),None=按 backupCount 自动推断
archive_format: 打包格式:tgz 或 zip
Note:
该功能仅在 WiFi 连接时可用,4G 网络暂不支持文件上传
"""
@@ -2148,7 +2163,7 @@ class NetworkManager:
self.logger.info(f"password: {password}")
ota_manager._start_update_thread()
self._spawn_cmd_thread(ota_manager.handle_wifi_and_update,
(ssid, password, ota_url))
(ssid, password, ota_url))
elif inner_cmd == 6:
try:
ip = os.popen(
+4 -1
View File
@@ -25,4 +25,7 @@
# 2.15.12 优化算法
# 2.15.13 优化算法
# 2.15.14 优化算法
# 2.15.15 优化wifi连接
# 2.15.15 优化wifi连接
# 2.15.16 修复wifi连接问题
# 2.15.17 修复wifi连接问题
# 2.15.18 wifi连接成功重新登录
+1 -1
View File
@@ -4,6 +4,6 @@
应用版本号
每次 OTA 更新时,只需要更新这个文件中的版本号
"""
VERSION = '2.15.15'
VERSION = '2.15.18'