This commit is contained in:
gcw_4spBpAfv
2026-01-20 11:25:17 +08:00
parent 83fe0776eb
commit 0ce140a210
11 changed files with 2713 additions and 156 deletions

View File

@@ -46,7 +46,7 @@ class OTAManager:
self._ota_url = None
self._ota_mode = None
self._lock = threading.Lock()
self._is_https = False
self._initialized = True
# ==================== 状态访问(只读属性)====================
@@ -699,11 +699,14 @@ class OTAManager:
return False, "bad_url (no host)"
# 很多 ML307R 的 MHTTP 对 https 不稳定;对已知域名做降级
if isinstance(url, str) and url.startswith("https://static.shelingxingqiu.com/"):
base_url = "http://static.shelingxingqiu.com"
base_url = "https://static.shelingxingqiu.com"
# TODO使用https看看是否能成功
self._is_https = True
else:
base_url = f"http://{host}"
self._is_https = False
logger = logger_manager.logger
def _log(*a):
@@ -786,6 +789,15 @@ class OTAManager:
_hard_reset_http()
resp = hardware_manager.at_client.send(f'AT+MHTTPCREATE="{base_url}"', "OK", 8000)
hid = _parse_httpid(resp)
if self._is_https:
resp = hardware_manager.at_client.send(f'AT+MHTTPCFG="ssl",{hid},1,1', "OK", 2000)
if "ERROR" in resp or "CME ERROR" in resp:
logger_manager.logger.error(f"MHTTPCFG SSL failed: {resp}")
# 尝试https 降级到http
downgraded_base_url = base_url.replace("https://", "http://")
resp = hardware_manager.at_client.send(f'AT+MHTTPCREATE="{downgraded_base_url}"', "OK", 8000)
hid = _parse_httpid(resp)
return hid, resp
def _fetch_range_into_buf(start, want_len, out_buf, full_reset=False):