feat: update CAN integration and T2G seat firmware

This commit is contained in:
vee
2026-08-01 15:55:21 +08:00
parent 8cda026ac2
commit 4aded5c21d
1443 changed files with 1007122 additions and 4978 deletions
+29 -2
View File
@@ -14,7 +14,7 @@ from http.cookies import CookieError, SimpleCookie
from http import HTTPStatus
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.parse import quote, unquote, urlparse
from urllib.parse import parse_qs, quote, unquote, urlparse
from cognitive_agent.config_loader import load_local_env
@@ -62,7 +62,8 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
server_version = "CognitiveAgentCabinDemo/2.0"
def do_GET(self) -> None: # noqa: N802 - stdlib handler API
path = unquote(urlparse(self.path).path)
parsed_url = urlparse(self.path)
path = unquote(parsed_url.path)
if path == "/favicon.ico":
self.send_response(HTTPStatus.NO_CONTENT)
self._send_security_headers()
@@ -94,6 +95,32 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
if path == "/api/runtime":
self._json(self.service.runtime_info())
return
if path == "/api/hardware/seat-state":
query = parse_qs(parsed_url.query)
conversation_id = str(query.get("conversation_id", [""])[0])
vehicle_id = str(query.get("vehicle_id", [""])[0]) or None
try:
self._json(
self.service.synchronize_hardware_state(
conversation_id,
vehicle_id,
)
)
except ValueError as exc:
self._json(
{"error": "invalid_request", "message": str(exc)},
HTTPStatus.BAD_REQUEST,
)
except Exception as exc: # noqa: BLE001 - surface passive CAN availability
self.log_error("physical seat-state synchronization failed: %s", exc)
self._json(
{
"error": "hardware_state_unavailable",
"message": str(exc),
},
HTTPStatus.SERVICE_UNAVAILABLE,
)
return
if path == "/api/gesture/runtime":
self._json(self.gesture.runtime_info())
return