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:
@@ -179,14 +179,20 @@ async def send_presets(request, session):
|
||||
batch = test_batch
|
||||
last_msg = test_msg
|
||||
else:
|
||||
await send_chunk(batch)
|
||||
try:
|
||||
await send_chunk(batch)
|
||||
except Exception:
|
||||
return json.dumps({"error": "ESP-NOW send failed"}), 503, {'Content-Type': 'application/json'}
|
||||
await asyncio.sleep_ms(SEND_DELAY_MS)
|
||||
messages_sent += 1
|
||||
batch = {name: preset_obj}
|
||||
last_msg = build_message(presets=batch, save=save_flag, default=default_id)
|
||||
|
||||
if batch:
|
||||
await send_chunk(batch)
|
||||
try:
|
||||
await send_chunk(batch)
|
||||
except Exception:
|
||||
return json.dumps({"error": "ESP-NOW send failed"}), 503, {'Content-Type': 'application/json'}
|
||||
await asyncio.sleep_ms(SEND_DELAY_MS)
|
||||
messages_sent += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user