feat(driver): add HTTP routes, startup split, and binary envelope support

Wire controller messages through new modules (background tasks, runtime state,
startup) and add binary envelope handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-03 14:54:12 +12:00
parent 74b4b495f9
commit 3ee89ce3b4
6 changed files with 457 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
import json
import socket
from binary_envelope import parse_binary_envelope
from utils import convert_and_reorder_colors
try:
@@ -12,13 +13,22 @@ except ImportError:
def process_data(payload, settings, presets, controller_ip=None):
"""Read one controller message; json.loads (bytes or str), then apply fields."""
try:
data = json.loads(payload)
print(payload)
if data.get("v", "") != "1":
"""Read one controller message; binary v1 envelope or JSON v1, then apply fields."""
data = None
if isinstance(payload, (bytes, bytearray)):
data = parse_binary_envelope(payload)
if data is None:
try:
data = json.loads(payload)
except (ValueError, TypeError):
return
else:
try:
data = json.loads(payload)
except (ValueError, TypeError):
return
except (ValueError, TypeError):
print(payload)
if data.get("v", "") != "1":
return
if "b" in data:
apply_brightness(data, settings, presets)