remove unseed code
This commit is contained in:
@@ -383,6 +383,27 @@ def _ensure_hostapd_modern_security(logger=None) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _cleanup_ap_flag_if_needed(logger):
|
||||
"""若 /boot/wifi.ap 残留,删除它并恢复 /boot/wifi.sta,避免 main.py 误判为 AP 配网模式。"""
|
||||
ap_flag = "/boot/wifi.ap"
|
||||
sta_flag = "/boot/wifi.sta"
|
||||
if not os.path.exists(ap_flag):
|
||||
return
|
||||
try:
|
||||
os.remove(ap_flag)
|
||||
logger.info(f"[WIFI-AP] 已清理残留标记 {ap_flag}")
|
||||
except Exception as e:
|
||||
logger.warning(f"[WIFI-AP] 清理 {ap_flag} 失败: {e}")
|
||||
return
|
||||
if not os.path.exists(sta_flag):
|
||||
try:
|
||||
with open(sta_flag, "w", encoding="utf-8") as f:
|
||||
f.write("")
|
||||
logger.info(f"[WIFI-AP] 已恢复 {sta_flag}")
|
||||
except Exception as e:
|
||||
logger.warning(f"[WIFI-AP] 恢复 {sta_flag} 失败: {e}")
|
||||
|
||||
|
||||
def _switch_boot_to_ap_mode(logger):
|
||||
"""
|
||||
去掉 STA 标志、建立 AP 标志,由 S30wifi 起 hostapd(与 Maix start_ap 二选一,以系统脚本为准)。
|
||||
@@ -449,6 +470,8 @@ def maybe_start_wifi_ap_fallback(logger=None):
|
||||
logger.info(f"[WIFI-AP] 兜底检测(quick):sta关联={wifi_ok}, 4g={g4_ok}")
|
||||
if wifi_ok or g4_ok:
|
||||
logger.info("[WIFI-AP] STA 或 4G 可用,不启动热点配网")
|
||||
# 清理上次开机可能残留的 /boot/wifi.ap 标记,避免 main.py 误判为 AP 配网模式
|
||||
_cleanup_ap_flag_if_needed(logger)
|
||||
return
|
||||
|
||||
# 两者均不可用:再按配置等待一段时间后复检,避免开机瞬态误判
|
||||
@@ -466,6 +489,7 @@ def maybe_start_wifi_ap_fallback(logger=None):
|
||||
|
||||
if wifi_ok or g4_ok:
|
||||
logger.info("[WIFI-AP] STA 或 4G 可用,不启动热点配网")
|
||||
_cleanup_ap_flag_if_needed(logger)
|
||||
return
|
||||
|
||||
logger.warning("[WIFI-AP] STA 与 4G 均不可用,启动热点配网(/boot/wifi.ap + HTTP)")
|
||||
|
||||
Reference in New Issue
Block a user