Merge branch 'claude/fervent-ride' : lecture config XIAO au démarrage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
j.foucher 2026-02-18 13:49:43 +01:00
commit 6d15a3f14f

View File

@ -142,7 +142,18 @@ async def ble_loop():
await client.start_notify(DEBUG_CHAR_UUID, debug_callback) await client.start_notify(DEBUG_CHAR_UUID, debug_callback)
await client.start_notify(SHOT_CHAR_UUID, shot_callback) await client.start_notify(SHOT_CHAR_UUID, shot_callback)
ble_status = f"{display_name} ({addr})" ble_status = f"{display_name} ({addr})"
# À la connexion : envoyer config + activer debug FULL automatiquement # À la connexion : lire la config sauvegardée dans le XIAO (flash)
try:
raw = await client.read_gatt_char(CONFIG_CHAR_UUID)
if len(raw) >= 22:
vals = struct.unpack_from('<ffH', raw, 0)
thresholds["accel"] = round(vals[0], 1)
thresholds["gyro"] = round(vals[1], 1)
thresholds["audio"] = int(vals[2])
print(f"📥 Config lue depuis XIAO → Accel:{thresholds['accel']:.1f}G Gyro:{thresholds['gyro']:.0f}°/s Audio:{thresholds['audio']}")
except Exception as ex:
print(f"⚠️ Lecture config XIAO impossible: {ex}")
# Envoyer debug FULL (sans écraser les seuils du XIAO)
try: try:
payload = build_config_payload(include_debug=True) payload = build_config_payload(include_debug=True)
await client.write_gatt_char(CONFIG_CHAR_UUID, payload, response=True) await client.write_gatt_char(CONFIG_CHAR_UUID, payload, response=True)