feat: 4g模块按行升级
This commit is contained in:
23
main.py
23
main.py
@@ -335,7 +335,7 @@ class ATClient:
|
||||
# OTA 升级地址与本地路径
|
||||
# url = "https://static.shelingxingqiu.com/shoot/202511031031/main.py"
|
||||
local_filename = "/maixapp/apps/t11/main_tmp.py"
|
||||
app_version = '1.0.0'
|
||||
app_version = '1.0.2'
|
||||
# OTA 下发参数(由后端指令写入)
|
||||
OTA_URL = None
|
||||
OTA_MODE = None # "4g" / "wifi" / None
|
||||
@@ -1017,7 +1017,7 @@ def connect_server():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
raw_line_data = []
|
||||
def tcp_main():
|
||||
"""TCP 主通信循环:登录、心跳、处理指令、发送数据"""
|
||||
global tcp_connected, high_send_queue, normal_send_queue, queue_lock, laser_calibration_active, laser_calibration_result, laser_calibration_lock, update_thread_started
|
||||
@@ -1089,6 +1089,21 @@ def tcp_main():
|
||||
last_heartbeat_ack_time = time.ticks_ms()
|
||||
print("✅ 收到心跳确认")
|
||||
|
||||
elif logged_in and msg_type == 40:
|
||||
if isinstance(body, dict):
|
||||
t = body.get('t', 0)
|
||||
v = body.get('v')
|
||||
raw_line_data.append(body)
|
||||
if len(raw_line_data) >= int(t):
|
||||
print(f"下载完成")
|
||||
stock_array = list(map(lambda x: x.get('d'), raw_line_data))
|
||||
with open(local_filename, 'w', encoding='utf-8') as file:
|
||||
file.write("\n".join(stock_array))
|
||||
apply_ota_and_reboot()
|
||||
else:
|
||||
safe_enqueue({'data':{'l': len(raw_line_data), 'v': v}, 'cmd': 41})
|
||||
print(f"已下载{len(raw_line_data)} 全部:{t} 版本:{v}")
|
||||
|
||||
# 处理业务指令
|
||||
elif logged_in and isinstance(body, dict):
|
||||
# 重要:每个包都要重新解析 inner_cmd,避免上一次的 cmd “粘住”导致反复执行
|
||||
@@ -1831,6 +1846,6 @@ if __name__ == "__main__":
|
||||
# print("has lock")
|
||||
# finally:
|
||||
# pass
|
||||
import config
|
||||
print("env: ", config.get_env())
|
||||
# import config
|
||||
# print("env: ", config.get_env())
|
||||
cmd_str()
|
||||
Reference in New Issue
Block a user