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
7 changed files with 39 additions and 34 deletions
+1 -4
View File
@@ -1,6 +1,6 @@
id: t11 id: t11
name: t11 name: t11
version: 2.15.15 version: 2.15.18
author: t11 author: t11
icon: '' icon: ''
desc: t11 desc: t11
@@ -18,14 +18,11 @@ files:
- laser_manager.py - laser_manager.py
- logger_manager.py - logger_manager.py
- main.py - main.py
- model_270139.cvimodel
- model_270139.mud
- network.py - network.py
- ota_curl.sh - ota_curl.sh
- ota_manager.py - ota_manager.py
- power.py - power.py
- server.pem - server.pem
- set_autostart.py
- shoot_manager.py - shoot_manager.py
- shot_id_generator.py - shot_id_generator.py
- target_roi_yolo.py - target_roi_yolo.py
+1 -1
View File
@@ -341,7 +341,7 @@ PIN_MAPPINGS = {
} }
# ==================== 电源配置 ==================== # ==================== 电源配置 ====================
AUTO_POWER_OFF_IN_SECONDS = 0 # 自动关机时间(秒),0表示不自动关机 AUTO_POWER_OFF_IN_SECONDS = 10 * 60 # 自动关机时间(秒),0表示不自动关机
BATTERY_SOC_LPF_ALPHA = 0.5 BATTERY_SOC_LPF_ALPHA = 0.5
BATTERY_SOC_AVG_WINDOW = 5 BATTERY_SOC_AVG_WINDOW = 5
+7 -8
View File
@@ -29,7 +29,7 @@ class HardwareManager:
self._adc_obj = None # ADC对象 self._adc_obj = None # ADC对象
self._at_client = None # AT客户端 self._at_client = None # AT客户端
self._last_active_ticks = None # 上次活跃时刻(ticks_ms,单调递增,不受校时影响) self._last_active_time = 0 # 用于记录用户的最后一次活跃的时间
self._stop_timer = False # 用于停止定时器的标志 self._stop_timer = False # 用于停止定时器的标志
self._initialized = True self._initialized = True
@@ -111,7 +111,7 @@ class HardwareManager:
def start_idle_timer(self): def start_idle_timer(self):
self._stop_timer = False self._stop_timer = False
self._last_active_ticks = time.ticks_ms() self._last_active_time = time.time()
def stop_idle_timer(self): def stop_idle_timer(self):
self._stop_timer = True self._stop_timer = True
@@ -119,13 +119,12 @@ class HardwareManager:
def get_idle_time_in_sec(self): def get_idle_time_in_sec(self):
if self._stop_timer: if self._stop_timer:
return 0 return 0
if self._last_active_ticks is None: diff = time.time() - self._last_active_time
if diff < 0:
# 时间可能被重置了,重新计时
self._last_active_time = time.time()
return 0 return 0
diff_ms = time.ticks_diff(time.ticks_ms(), self._last_active_ticks) return diff
if diff_ms < 0:
self._last_active_ticks = time.ticks_ms()
return 0
return diff_ms / 1000.0
# 创建全局单例实例 # 创建全局单例实例
+1 -9
View File
@@ -275,11 +275,6 @@ def cmd_str():
hardware_manager.start_idle_timer() hardware_manager.start_idle_timer()
if logger: if logger:
_auto_power_off = int(getattr(config, "AUTO_POWER_OFF_IN_SECONDS", 0) or 0)
if _auto_power_off <= 0:
logger.info("[MAIN] 自动关机已禁用 (AUTO_POWER_OFF_IN_SECONDS=0)")
else:
logger.info(f"[MAIN] 自动关机: {_auto_power_off} 秒无活动")
logger.info("系统准备完成...") logger.info("系统准备完成...")
last_adc_trigger = 0 last_adc_trigger = 0
@@ -343,10 +338,7 @@ def cmd_str():
# 不在 OTA 状态下,检测是否空闲足够长,自动关机 # 不在 OTA 状态下,检测是否空闲足够长,自动关机
# print(f"[MAIN] 空闲时间: {hardware_manager.get_idle_time_in_sec() }秒") # print(f"[MAIN] 空闲时间: {hardware_manager.get_idle_time_in_sec() }秒")
# print(f"配置关机时间:{config.AUTO_POWER_OFF_IN_SECONDS} 秒") # print(f"配置关机时间:{config.AUTO_POWER_OFF_IN_SECONDS} 秒")
if ( if hardware_manager.get_idle_time_in_sec() > config.AUTO_POWER_OFF_IN_SECONDS:
config.AUTO_POWER_OFF_IN_SECONDS > 0
and hardware_manager.get_idle_time_in_sec() > config.AUTO_POWER_OFF_IN_SECONDS
):
logger.info("[MAIN] 超过设定时间未检测活动,自动关机") logger.info("[MAIN] 超过设定时间未检测活动,自动关机")
network_manager.safe_enqueue({"poweroff": "超过设定时间未检测活动,自动关机"}, 2) network_manager.safe_enqueue({"poweroff": "超过设定时间未检测活动,自动关机"}, 2)
time.sleep_ms(100) time.sleep_ms(100)
+16 -1
View File
@@ -624,6 +624,11 @@ class NetworkManager:
password = inner_data.get("password") password = inner_data.get("password")
ota_res_url = inner_data.get("url") ota_res_url = inner_data.get("url")
try: 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() w = network.wifi.Wifi()
e = w.connect(ssid, password, wait=True, timeout=15) e = w.connect(ssid, password, wait=True, timeout=15)
err.check_raise(e, "connect wifi failed") err.check_raise(e, "connect wifi failed")
@@ -665,6 +670,11 @@ class NetworkManager:
ssid = inner_data.get("ssid") ssid = inner_data.get("ssid")
password = inner_data.get("password") password = inner_data.get("password")
try: 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() w = network.wifi.Wifi()
e = w.connect(ssid, password, wait=True, timeout=15) e = w.connect(ssid, password, wait=True, timeout=15)
err.check_raise(e, "connect wifi failed") err.check_raise(e, "connect wifi failed")
@@ -678,6 +688,11 @@ class NetworkManager:
}, },
2, 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: except Exception as e:
self.logger.error(f"cmd600 失败: {e}") self.logger.error(f"cmd600 失败: {e}")
self.safe_enqueue( self.safe_enqueue(
@@ -2148,7 +2163,7 @@ class NetworkManager:
self.logger.info(f"password: {password}") self.logger.info(f"password: {password}")
ota_manager._start_update_thread() ota_manager._start_update_thread()
self._spawn_cmd_thread(ota_manager.handle_wifi_and_update, self._spawn_cmd_thread(ota_manager.handle_wifi_and_update,
(ssid, password, ota_url)) (ssid, password, ota_url))
elif inner_cmd == 6: elif inner_cmd == 6:
try: try:
ip = os.popen( ip = os.popen(
+3 -1
View File
@@ -26,4 +26,6 @@
# 2.15.13 优化算法 # 2.15.13 优化算法
# 2.15.14 优化算法 # 2.15.14 优化算法
# 2.15.15 优化wifi连接 # 2.15.15 优化wifi连接
# 2.15.16 修复不关机,空闲计时改用 ticks_ms(不受校时影响),启动时打印自动关机配置 # 2.15.16 修复wifi连接问题
# 2.15.17 修复wifi连接问题
# 2.15.18 wifi连接成功重新登录
+1 -1
View File
@@ -4,6 +4,6 @@
应用版本号 应用版本号
每次 OTA 更新时,只需要更新这个文件中的版本号 每次 OTA 更新时,只需要更新这个文件中的版本号
""" """
VERSION = '2.15.16' VERSION = '2.15.18'