Battery-optimized command delivery for IoT devices.
GET /dev/{device_id}/cmd
Authorization: Bearer {api_key}Returns pending commands immediately.
GET /dev/{device_id}/cmd/poll?wait=30
Authorization: Bearer {api_key}Waits up to 30 seconds for commands. Returns immediately if command arrives.
GET /dev/{device_id}/cmd/stream?wait=30
Authorization: Bearer {api_key}
Accept: text/event-streamServer-Sent Events stream. Sends keepalives and commands.
HTTP Poll:
{"commands": [{"command_id": "cmd_xxx", "action": "reboot", "params": {}}]}SSE Stream:
event:keepalive
data:{"time":"2025-12-22T20:39:31Z"}
event:command
data:[{"command_id":"cmd_xxx","action":"reboot"}]
1. Device sends data → POST /dev/{id}/data
Response: {"status":"ok", "commands_pending": 1}
2. If commands_pending > 0:
→ GET /dev/{id}/cmd/poll?wait=30
3. Execute command
4. Acknowledge:
→ POST /dev/{id}/cmd/{cmd_id}/ack
5. Sleep, repeat
./tests/sse_test.sh