ESP-NOW: STA interface, notify browser on send failure

- Activate STA interface before ESP-NOW to fix ESP_ERR_ESPNOW_IF
- Notify browser on send failure: WebSocket sends error JSON; preset API returns 503
- Use exceptions for failure (not return value) to avoid false errors when send succeeds
- presets.js: handle server error messages in WebSocket onmessage

Made-with: Cursor
This commit is contained in:
2026-03-08 23:47:55 +13:00
parent 91bd78ab31
commit 0fdc11c0b0
4 changed files with 38 additions and 6 deletions

View File

@@ -99,7 +99,13 @@ async def main(port=80):
print("WS received raw:", data)
# Forward raw JSON payload over ESPNow to configured peers
await esp.send(data)
try:
await esp.send(data)
except Exception:
try:
await ws.send(json.dumps({"error": "ESP-NOW send failed"}))
except Exception:
pass
else:
break