@alteriom/mqtt-schema 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +252 -174
- package/dist/cjs/schemas/control_response.schema.json +15 -15
- package/dist/cjs/schemas/envelope.schema.json +16 -16
- package/dist/cjs/schemas/firmware_status.schema.json +17 -17
- package/dist/cjs/schemas/gateway_info.schema.json +21 -21
- package/dist/cjs/schemas/gateway_metrics.schema.json +26 -26
- package/dist/cjs/schemas/mqtt_v1_bundle.json +14 -14
- package/dist/cjs/schemas/sensor_data.schema.json +33 -33
- package/dist/cjs/schemas/sensor_heartbeat.schema.json +14 -14
- package/dist/cjs/schemas/sensor_status.schema.json +14 -14
- package/dist/cjs/schemas/validation_rules.md +44 -44
- package/dist/esm/schemas/control_response.schema.json +15 -15
- package/dist/esm/schemas/envelope.schema.json +16 -16
- package/dist/esm/schemas/firmware_status.schema.json +17 -17
- package/dist/esm/schemas/gateway_info.schema.json +21 -21
- package/dist/esm/schemas/gateway_metrics.schema.json +26 -26
- package/dist/esm/schemas/mqtt_v1_bundle.json +14 -14
- package/dist/esm/schemas/sensor_data.schema.json +33 -33
- package/dist/esm/schemas/sensor_heartbeat.schema.json +14 -14
- package/dist/esm/schemas/sensor_status.schema.json +14 -14
- package/dist/esm/schemas/validation_rules.md +44 -44
- package/package.json +39 -7
- package/types/ota-manifest.d.ts +63 -0
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
@@ -1,174 +1,252 @@
|
|
1
|
-
# @alteriom/mqtt-schema
|
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
|
-
const
|
62
|
-
if (
|
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
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
1
|
+
# @alteriom/mqtt-schema
|
2
|
+
|
3
|
+

|
4
|
+

|
5
|
+

|
6
|
+

|
7
|
+

|
8
|
+

|
9
|
+

|
10
|
+

|
11
|
+
[](https://bundlephobia.com/package/@alteriom/mqtt-schema)
|
12
|
+
|
13
|
+
Alteriom MQTT v1 JSON Schemas, TypeScript types, and production‑ready validation helpers for integrating firmware MQTT payloads into web or backend services.
|
14
|
+
|
15
|
+
> NOTE: OTA manifest CI validation workflow file could not be added via automated API due to path constraints; it can be added manually post-merge if still absent.
|
16
|
+
|
17
|
+
See also: `docs/SCHEMA_MAP.md` for complete schema listing.
|
18
|
+
|
19
|
+
## OTA Firmware Manifest Schema (NEW in 0.3.0)
|
20
|
+
|
21
|
+
The package now includes the OTA firmware manifest schema used by build + deployment tooling.
|
22
|
+
|
23
|
+
Import the schema JSON directly:
|
24
|
+
```ts
|
25
|
+
import otaManifestSchema from '@alteriom/mqtt-schema/schemas/ota/ota-manifest.schema.json';
|
26
|
+
```
|
27
|
+
|
28
|
+
Types:
|
29
|
+
```ts
|
30
|
+
import { OtaManifest, isRichManifest } from '@alteriom/mqtt-schema/types/ota-manifest';
|
31
|
+
```
|
32
|
+
|
33
|
+
Shapes supported (oneOf):
|
34
|
+
- Rich manifest:
|
35
|
+
```json
|
36
|
+
{
|
37
|
+
"environment": "universal-sensor",
|
38
|
+
"branch": "main",
|
39
|
+
"manifests": { "dev": { /* richEntry */ }, "prod": { /* richEntry */ } }
|
40
|
+
}
|
41
|
+
```
|
42
|
+
- Minimal environment map:
|
43
|
+
```json
|
44
|
+
{
|
45
|
+
"universal-sensor": { "dev": { /* minimalChannel */ } }
|
46
|
+
}
|
47
|
+
```
|
48
|
+
|
49
|
+
Chunk hashing variants (mutually exclusive):
|
50
|
+
1. Structured objects (offset + size + sha256)
|
51
|
+
2. Array of lowercase sha256 strings
|
52
|
+
|
53
|
+
Validation example:
|
54
|
+
```ts
|
55
|
+
import Ajv from 'ajv';
|
56
|
+
import schema from '@alteriom/mqtt-schema/schemas/ota/ota-manifest.schema.json';
|
57
|
+
import { OtaManifest } from '@alteriom/mqtt-schema/types/ota-manifest';
|
58
|
+
|
59
|
+
const ajv = new Ajv({ allErrors: true });
|
60
|
+
const validate = ajv.compile<OtaManifest>(schema as any);
|
61
|
+
const manifest: OtaManifest = JSON.parse(raw);
|
62
|
+
if (!validate(manifest)) {
|
63
|
+
console.error(validate.errors);
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
---
|
68
|
+
|
69
|
+
## Why this exists
|
70
|
+
Firmware emits structured MQTT payloads that must remain tightly aligned with web, analytics, and gateway logic. This package is the single source of truth for:
|
71
|
+
|
72
|
+
- Canonical, versioned JSON Schemas (`schema_version: 1` series)
|
73
|
+
- Embedded (tree‑shakeable) schema objects — no runtime file I/O
|
74
|
+
- Precompiled Ajv validators (fast + consistent across CJS / ESM)
|
75
|
+
- TypeScript interfaces & type guards generated from the same source schema set
|
76
|
+
- Message classification helper that infers the schema kind heuristically
|
77
|
+
- Forward‑compatible design: unknown extra properties are ignored unless explicitly constrained
|
78
|
+
|
79
|
+
## Features
|
80
|
+
|
81
|
+
- Dual build: CommonJS + ESM (Node 16+ / bundlers)
|
82
|
+
- Zero configuration: just import and validate
|
83
|
+
- Helpful error paths (JSON Pointer style)
|
84
|
+
- Lightweight (Ajv peer dependency, schemas embedded)
|
85
|
+
- Ships original schema JSON files (optional consumption)
|
86
|
+
|
87
|
+
## Installation
|
88
|
+
|
89
|
+
```bash
|
90
|
+
npm install @alteriom/mqtt-schema ajv ajv-formats
|
91
|
+
```
|
92
|
+
|
93
|
+
## Quick Start
|
94
|
+
|
95
|
+
Validate a JSON payload (object already parsed):
|
96
|
+
|
97
|
+
```ts
|
98
|
+
import { validators } from '@alteriom/mqtt-schema';
|
99
|
+
|
100
|
+
const payload = JSON.parse(rawMqttString);
|
101
|
+
const result = validators.sensorData(payload);
|
102
|
+
if (!result.valid) {
|
103
|
+
console.error('Invalid sensor data', result.errors);
|
104
|
+
}
|
105
|
+
```
|
106
|
+
|
107
|
+
Classify and validate automatically:
|
108
|
+
|
109
|
+
```ts
|
110
|
+
import { classifyAndValidate } from '@alteriom/mqtt-schema';
|
111
|
+
|
112
|
+
const { kind, result } = classifyAndValidate(payload);
|
113
|
+
if (result.valid) {
|
114
|
+
console.log('Message kind:', kind);
|
115
|
+
} else {
|
116
|
+
console.warn('Validation errors', result.errors);
|
117
|
+
}
|
118
|
+
```
|
119
|
+
|
120
|
+
Use strong TypeScript types after classification:
|
121
|
+
|
122
|
+
```ts
|
123
|
+
import { classifyAndValidate, isSensorDataMessage, SensorDataMessage } from '@alteriom/mqtt-schema';
|
124
|
+
|
125
|
+
const { result } = classifyAndValidate(payload);
|
126
|
+
if (result.valid && isSensorDataMessage(payload)) {
|
127
|
+
const data: SensorDataMessage = payload;
|
128
|
+
Object.entries(data.sensors).forEach(([name, s]) => {
|
129
|
+
console.log(name, s.value, s.unit);
|
130
|
+
});
|
131
|
+
}
|
132
|
+
```
|
133
|
+
|
134
|
+
Access raw schema JSON (if you need to introspect or power form generation):
|
135
|
+
|
136
|
+
```ts
|
137
|
+
import envelopeSchema from '@alteriom/mqtt-schema/schemas/envelope.schema.json';
|
138
|
+
```
|
139
|
+
|
140
|
+
## API Surface
|
141
|
+
|
142
|
+
```ts
|
143
|
+
import { validators, validateMessage, classifyAndValidate } from '@alteriom/mqtt-schema';
|
144
|
+
|
145
|
+
// 1. Direct validator by message kind
|
146
|
+
validators.sensorData(payload); // => { valid: boolean; errors?: string[] }
|
147
|
+
|
148
|
+
// 2. Generic function
|
149
|
+
validateMessage('sensorData', payload);
|
150
|
+
|
151
|
+
// 3. Classify unknown payload then validate
|
152
|
+
const { kind, result } = classifyAndValidate(payload);
|
153
|
+
|
154
|
+
// 4. Type guards (when available)
|
155
|
+
// if (isSensorDataMessage(payload)) { ... }
|
156
|
+
```
|
157
|
+
|
158
|
+
Validation result format:
|
159
|
+
|
160
|
+
```ts
|
161
|
+
interface ValidationResult {
|
162
|
+
valid: boolean;
|
163
|
+
errors?: string[]; // Each item contains instancePath + message
|
164
|
+
}
|
165
|
+
```
|
166
|
+
|
167
|
+
### Performance Notes
|
168
|
+
|
169
|
+
All Ajv validator functions are compiled once at module load. For typical web usage (tens to hundreds of validations per page/session) this is faster and simpler than on‑demand compilation. If you need custom Ajv options (e.g., different formats), open an issue—an override hook can be added without breaking changes.
|
170
|
+
|
171
|
+
### Embedded Schemas
|
172
|
+
|
173
|
+
`schema_data.ts` is auto‑generated during build. This avoids dynamic `require()` / `import` of JSON and works cleanly in both Node ESM and bundlers without JSON import assertions. The original JSON files are still published under `schemas/` for tooling or documentation pipelines.
|
174
|
+
|
175
|
+
## Provided Schemas (v1)
|
176
|
+
|
177
|
+
| File | Purpose |
|
178
|
+
|------|---------|
|
179
|
+
| envelope.schema.json | Base required envelope fields |
|
180
|
+
| sensor_data.schema.json | Telemetry payload with sensors map |
|
181
|
+
| sensor_heartbeat.schema.json | Lightweight heartbeat (firmware_version may be omitted) |
|
182
|
+
| sensor_status.schema.json | Sensor status / presence updates |
|
183
|
+
| gateway_info.schema.json | Gateway identity & capabilities |
|
184
|
+
| gateway_metrics.schema.json | Gateway performance metrics |
|
185
|
+
| firmware_status.schema.json | Firmware update lifecycle events |
|
186
|
+
| control_response.schema.json | Command/control response messages |
|
187
|
+
|
188
|
+
## Exports
|
189
|
+
|
190
|
+
| Export | Type | Description |
|
191
|
+
|--------|------|-------------|
|
192
|
+
| `validators` | object | Precompiled validators per message type |
|
193
|
+
| `validateMessage(kind,data)` | fn | Run a specific validator by key |
|
194
|
+
| `classifyAndValidate(data)` | fn | Heuristic classification + validation |
|
195
|
+
| `SensorDataMessage` etc. | TS interfaces | Strongly typed shapes |
|
196
|
+
| `isSensorDataMessage` etc. | type guards | Runtime narrowing helpers |
|
197
|
+
| `schemas/*.json` | JSON | Original schema assets (optional) |
|
198
|
+
| `schemas/ota/ota-manifest.schema.json` | JSON | OTA firmware manifest schema (rich + minimal) |
|
199
|
+
| `types/ota-manifest` | TS types | OtaManifest union + helpers |
|
200
|
+
|
201
|
+
### Validator Keys
|
202
|
+
|
203
|
+
`sensorData`, `sensorHeartbeat`, `sensorStatus`, `gatewayInfo`, `gatewayMetrics`, `firmwareStatus`, `controlResponse`
|
204
|
+
|
205
|
+
### Classification Heuristics (Simplified)
|
206
|
+
|
207
|
+
- `metrics` → `gatewayMetrics`
|
208
|
+
- `sensors` → `sensorData`
|
209
|
+
- `progress_pct` or OTA status keywords → `firmwareStatus`
|
210
|
+
- `status` + `device_type: sensor` → `sensorStatus`
|
211
|
+
- `status: ok|error` (no other match) → `controlResponse`
|
212
|
+
- `device_type: gateway` → `gatewayInfo`
|
213
|
+
- fallback → `sensorHeartbeat`
|
214
|
+
|
215
|
+
## Versioning Policy
|
216
|
+
|
217
|
+
Schema stability is paramount. We track two related versions:
|
218
|
+
|
219
|
+
| Concept | Meaning |
|
220
|
+
|---------|---------|
|
221
|
+
| `schema_version` (in payload) | Wire format major. Only increments for breaking changes. |
|
222
|
+
| npm package version | Follows semver; patch/minor may add optional properties or tooling, major aligns with `schema_version` bump. |
|
223
|
+
|
224
|
+
Backward‑compatible additions: new optional properties or enums, documented in CHANGELOG. Breaking: new required fields, structural changes, or removed properties (triggers parallel `v2` schema path & coordinated firmware rollout).
|
225
|
+
|
226
|
+
Backward-compatible schema additions to OTA manifest WILL use minor bumps.
|
227
|
+
|
228
|
+
## TypeScript / Bundler Notes
|
229
|
+
|
230
|
+
- Works in TS >= 5, Node >= 16, Vite / Webpack / ESBuild.
|
231
|
+
- Tree shaking: unused validators pruned when using ESM builds.
|
232
|
+
- No side effects besides Ajv instance creation.
|
233
|
+
|
234
|
+
## Roadmap
|
235
|
+
|
236
|
+
- Optional custom Ajv injection hook
|
237
|
+
- JSON Schema → Zod conversion example
|
238
|
+
- Runtime metrics helper (count validation categories)
|
239
|
+
- Signed OTA manifest extension
|
240
|
+
- Delta / compressed OTA metadata fields
|
241
|
+
|
242
|
+
## Contributing
|
243
|
+
|
244
|
+
Issues & PRs welcome. Ensure firmware repo schemas remain the authoritative source—do not manually edit generated `schema_data.ts`.
|
245
|
+
|
246
|
+
## Security
|
247
|
+
|
248
|
+
Schemas are static. No network access. Supply-chain risk minimized by keeping dependencies minimal (Ajv + formats only).
|
249
|
+
|
250
|
+
## License
|
251
|
+
|
252
|
+
MIT
|
@@ -1,15 +1,15 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
-
"$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json",
|
4
|
-
"title": "Control / Command Response v1",
|
5
|
-
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
-
"type": "object",
|
7
|
-
"required": ["status"],
|
8
|
-
"properties": {
|
9
|
-
"command": {"type": "string"},
|
10
|
-
"status": {"type": "string", "enum": ["ok", "error"]},
|
11
|
-
"message": {"type": "string"},
|
12
|
-
"result": {"type": ["object", "array", "string", "number", "boolean", "null"]}
|
13
|
-
},
|
14
|
-
"additionalProperties": true
|
15
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/control_response.schema.json",
|
4
|
+
"title": "Control / Command Response v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"required": ["status"],
|
8
|
+
"properties": {
|
9
|
+
"command": {"type": "string"},
|
10
|
+
"status": {"type": "string", "enum": ["ok", "error"]},
|
11
|
+
"message": {"type": "string"},
|
12
|
+
"result": {"type": ["object", "array", "string", "number", "boolean", "null"]}
|
13
|
+
},
|
14
|
+
"additionalProperties": true
|
15
|
+
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
-
"$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json",
|
4
|
-
"title": "Alteriom MQTT Base Envelope v1",
|
5
|
-
"type": "object",
|
6
|
-
"required": ["schema_version", "device_id", "device_type", "timestamp", "firmware_version"],
|
7
|
-
"properties": {
|
8
|
-
"schema_version": {"type": "integer", "const": 1},
|
9
|
-
"device_id": {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$"},
|
10
|
-
"device_type": {"type": "string", "enum": ["sensor", "gateway"]},
|
11
|
-
"timestamp": {"type": "string", "format": "date-time"},
|
12
|
-
"firmware_version": {"type": "string", "minLength": 1, "maxLength": 40},
|
13
|
-
"hardware_version": {"type": "string", "maxLength": 80}
|
14
|
-
},
|
15
|
-
"additionalProperties": true
|
16
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/envelope.schema.json",
|
4
|
+
"title": "Alteriom MQTT Base Envelope v1",
|
5
|
+
"type": "object",
|
6
|
+
"required": ["schema_version", "device_id", "device_type", "timestamp", "firmware_version"],
|
7
|
+
"properties": {
|
8
|
+
"schema_version": {"type": "integer", "const": 1},
|
9
|
+
"device_id": {"type": "string", "minLength": 1, "maxLength": 64, "pattern": "^[A-Za-z0-9_-]+$"},
|
10
|
+
"device_type": {"type": "string", "enum": ["sensor", "gateway"]},
|
11
|
+
"timestamp": {"type": "string", "format": "date-time"},
|
12
|
+
"firmware_version": {"type": "string", "minLength": 1, "maxLength": 40},
|
13
|
+
"hardware_version": {"type": "string", "maxLength": 80}
|
14
|
+
},
|
15
|
+
"additionalProperties": true
|
16
|
+
}
|
@@ -1,17 +1,17 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
-
"$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json",
|
4
|
-
"title": "Firmware Update Status v1",
|
5
|
-
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
-
"type": "object",
|
7
|
-
"required": ["status"],
|
8
|
-
"properties": {
|
9
|
-
"event": {"type": "string"},
|
10
|
-
"from_version": {"type": "string"},
|
11
|
-
"to_version": {"type": "string"},
|
12
|
-
"status": {"type": "string", "enum": ["pending", "downloading", "flashing", "verifying", "rebooting", "completed", "failed"]},
|
13
|
-
"progress_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
14
|
-
"error": {"type": ["string", "null"]}
|
15
|
-
},
|
16
|
-
"additionalProperties": true
|
17
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/firmware_status.schema.json",
|
4
|
+
"title": "Firmware Update Status v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"required": ["status"],
|
8
|
+
"properties": {
|
9
|
+
"event": {"type": "string"},
|
10
|
+
"from_version": {"type": "string"},
|
11
|
+
"to_version": {"type": "string"},
|
12
|
+
"status": {"type": "string", "enum": ["pending", "downloading", "flashing", "verifying", "rebooting", "completed", "failed"]},
|
13
|
+
"progress_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
14
|
+
"error": {"type": ["string", "null"]}
|
15
|
+
},
|
16
|
+
"additionalProperties": true
|
17
|
+
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
-
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json",
|
4
|
-
"title": "Gateway Info v1",
|
5
|
-
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
-
"type": "object",
|
7
|
-
"properties": {
|
8
|
-
"mac_address": {"type": "string", "pattern": "^[0-9A-Fa-f:]{17}$"},
|
9
|
-
"ip_address": {"type": "string", "format": "ipv4"},
|
10
|
-
"capabilities": {
|
11
|
-
"type": "object",
|
12
|
-
"properties": {
|
13
|
-
"max_nodes": {"type": "integer", "minimum": 0},
|
14
|
-
"supports_mesh": {"type": "boolean"},
|
15
|
-
"firmware_update": {"type": "boolean"}
|
16
|
-
},
|
17
|
-
"additionalProperties": true
|
18
|
-
}
|
19
|
-
},
|
20
|
-
"additionalProperties": true
|
21
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_info.schema.json",
|
4
|
+
"title": "Gateway Info v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"mac_address": {"type": "string", "pattern": "^[0-9A-Fa-f:]{17}$"},
|
9
|
+
"ip_address": {"type": "string", "format": "ipv4"},
|
10
|
+
"capabilities": {
|
11
|
+
"type": "object",
|
12
|
+
"properties": {
|
13
|
+
"max_nodes": {"type": "integer", "minimum": 0},
|
14
|
+
"supports_mesh": {"type": "boolean"},
|
15
|
+
"firmware_update": {"type": "boolean"}
|
16
|
+
},
|
17
|
+
"additionalProperties": true
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"additionalProperties": true
|
21
|
+
}
|
@@ -1,26 +1,26 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
-
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json",
|
4
|
-
"title": "Gateway Metrics v1",
|
5
|
-
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
-
"type": "object",
|
7
|
-
"required": ["metrics"],
|
8
|
-
"properties": {
|
9
|
-
"metrics": {
|
10
|
-
"type": "object",
|
11
|
-
"required": ["uptime_s"],
|
12
|
-
"properties": {
|
13
|
-
"uptime_s": {"type": "integer", "minimum": 0},
|
14
|
-
"cpu_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
15
|
-
"memory_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
16
|
-
"temperature_c": {"type": "number"},
|
17
|
-
"connected_devices": {"type": "integer", "minimum": 0},
|
18
|
-
"mesh_nodes": {"type": "integer", "minimum": 0},
|
19
|
-
"packet_loss_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
20
|
-
"data_throughput_kbps": {"type": "number", "minimum": 0}
|
21
|
-
},
|
22
|
-
"additionalProperties": true
|
23
|
-
}
|
24
|
-
},
|
25
|
-
"additionalProperties": true
|
26
|
-
}
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$id": "https://schemas.alteriom.io/mqtt/v1/gateway_metrics.schema.json",
|
4
|
+
"title": "Gateway Metrics v1",
|
5
|
+
"allOf": [{"$ref": "envelope.schema.json"}],
|
6
|
+
"type": "object",
|
7
|
+
"required": ["metrics"],
|
8
|
+
"properties": {
|
9
|
+
"metrics": {
|
10
|
+
"type": "object",
|
11
|
+
"required": ["uptime_s"],
|
12
|
+
"properties": {
|
13
|
+
"uptime_s": {"type": "integer", "minimum": 0},
|
14
|
+
"cpu_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
15
|
+
"memory_usage_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
16
|
+
"temperature_c": {"type": "number"},
|
17
|
+
"connected_devices": {"type": "integer", "minimum": 0},
|
18
|
+
"mesh_nodes": {"type": "integer", "minimum": 0},
|
19
|
+
"packet_loss_pct": {"type": "number", "minimum": 0, "maximum": 100},
|
20
|
+
"data_throughput_kbps": {"type": "number", "minimum": 0}
|
21
|
+
},
|
22
|
+
"additionalProperties": true
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"additionalProperties": true
|
26
|
+
}
|