feat: 新版本ota

This commit is contained in:
2026-06-03 13:20:46 +08:00
parent 86cd8cd46e
commit 959635f461
3 changed files with 29 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ import json
import re
from math import e
import struct
from maix import time
from maix import time,network
import hmac
import hashlib
import ujson
@@ -21,7 +21,7 @@ from hardware import hardware_manager
from power import get_bus_voltage, voltage_to_percent
from logger_manager import logger_manager
from wifi import wifi_manager
import subprocess
@@ -2097,7 +2097,30 @@ class NetworkManager:
self.logger.info("[LASER] cmd200 在后台线程执行检测")
import _thread
_thread.start_new_thread(self._cmd200_detect_laser, ())
elif inner_cmd == 300:
inner_data = data_obj.get("data", {}) if isinstance(data_obj, dict) else {}
self.logger.info(f"[New Ota] cmd300 , data: {inner_data}")
ssid = inner_data.get("ssid")
password = inner_data.get("password")
ota_res_url = inner_data.get("url")
try:
w = network.wifi.Wifi()
w.connect(ssid, password, wait=True, timeout=15)
if self.logger:
self.logger.info(f"[ota] Connect success, got ip{w.get_ip()}")
subprocess.run(
["sh", "/maixapp/apps/t11/ota_curl.sh", ota_res_url])
except Exception as e:
self.logger.error(f"[ota] cmd300 失败: {e}")
self.safe_enqueue(
{
"cmd": 300,
"result": "ota fail",
"reason": str(e),
},
2,
)
hardware_manager.start_idle_timer()
else: # data的结构不是 dict
self.logger.info(f"[NET] body={body}, {time.time()}")
else: