-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscale_websocket.schema.json
More file actions
156 lines (156 loc) · 3.47 KB
/
scale_websocket.schema.json
File metadata and controls
156 lines (156 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/adcondev/scale-daemon/api/v1/websocket.schema.json",
"title": "Scale Daemon WebSocket Protocol",
"description": "Schema for mixed-mode WebSocket protocol (JSON Objects for control, JSON Strings for data)",
"definitions": {
"ClientMessage": {
"type": "object",
"description": "Messages sent from client to server (Strictly JSON Objects)",
"required": [
"tipo"
],
"properties": {
"tipo": {
"type": "string",
"enum": [
"config"
]
}
},
"oneOf": [
{
"$ref": "#/definitions/ConfigMessage"
}
]
},
"ServerMessage": {
"description": "Messages sent from server to client. Can be an Object (Control) or a String (Weight/Error).",
"oneOf": [
{
"$ref": "#/definitions/EnvironmentInfo"
},
{
"$ref": "#/definitions/WeightReading"
},
{
"$ref": "#/definitions/ErrorCode"
}
]
},
"ConfigMessage": {
"type": "object",
"required": [
"tipo",
"puerto",
"marca",
"modoPrueba",
"auth_token"
],
"properties": {
"tipo": {
"const": "config"
},
"puerto": {
"type": "string",
"examples": [
"COM3"
]
},
"marca": {
"type": "string",
"examples": [
"Rhino BAR 8RS"
]
},
"modoPrueba": {
"type": "boolean"
},
"authToken": {
"type": "string",
"description": "Authentication token required to authorize config changes. Injected into dashboard HTML at render time."
}
}
},
"ErrorResponse": {
"type": "object",
"required": [
"tipo",
"error"
],
"properties": {
"tipo": {
"const": "error"
},
"error": {
"type": "string",
"enum": [
"AUTH_INVALID_TOKEN",
"RATE_LIMITED"
],
"description": "Error code for rejected operations"
}
}
},
"EnvironmentInfo": {
"type": "object",
"required": [
"tipo",
"ambiente",
"version",
"config"
],
"properties": {
"tipo": {
"const": "ambiente"
},
"ambiente": {
"type": "string"
},
"version": {
"type": "string"
},
"config": {
"type": "object",
"properties": {
"puerto": {
"type": "string"
},
"marca": {
"type": "string"
},
"modoPrueba": {
"type": "boolean"
},
"ambiente": {
"type": "string"
}
}
}
}
},
"WeightReading": {
"type": "string",
"description": "Raw weight reading sent as a JSON string literal.",
"pattern": "^\\d+(\\.\\d+)?$",
"examples": [
"12.50",
"0.00",
"5.45"
]
},
"ErrorCode": {
"type": "string",
"description": "Error code broadcast as a JSON string literal.",
"enum": [
"ERR_SCALE_CONN",
"ERR_EOF",
"ERR_TIMEOUT",
"ERR_READ"
],
"examples": [
"ERR_SCALE_CONN"
]
}
}
}