Initial Ktor backend skeleton with ProtocolMessage DTO, REST and WebSocket

This commit is contained in:
2026-04-01 18:29:10 +03:00
parent b0a48e94bd
commit 6f3584fe6d
16 changed files with 80 additions and 19 deletions

View File

View File

@@ -0,0 +1,13 @@
{
"v": 1,
"id": "cmd-123",
"type": "command",
"ts": 1710000000,
"deviceId": "esp32-001",
"payload": {
"command": "setRelay",
"params": {
"state": true
}
}
}

View File

@@ -0,0 +1,12 @@
{
"v": 1,
"id": "evt-123",
"type": "event",
"ts": 1710000003,
"deviceId": "esp32-001",
"payload": {
"event": "overheat",
"level": "warning",
"message": "Temperature too high"
}
}

View File

@@ -0,0 +1,12 @@
{
"v": 1,
"id": "resp-123",
"type": "response",
"ts": 1710000001,
"deviceId": "esp32-001",
"payload": {
"requestId": "cmd-123",
"status": "ok",
"data": {}
}
}

View File

@@ -0,0 +1,12 @@
{
"v": 1,
"id": "tel-123",
"type": "telemetry",
"ts": 1710000002,
"deviceId": "esp32-001",
"payload": {
"voltage": 220.5,
"current": 1.2,
"temperature": 36.6
}
}

12
protocol/schema.json Normal file
View File

@@ -0,0 +1,12 @@
{
"type": "object",
"required": ["v", "id", "type", "ts", "deviceId", "payload"],
"properties": {
"v": { "type": "integer" },
"id": { "type": "string" },
"type": { "type": "string" },
"ts": { "type": "integer" },
"deviceId": { "type": "string" },
"payload": { "type": "object" }
}
}