Minimize contract, add ADC read and send its data to coonsole
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "contract/ingest/common.schema.json",
|
||||
"type": "object",
|
||||
"required": ["v", "id", "type", "ts", "deviceId", "payload"],
|
||||
"required": ["v", "t", "id", "ts", "d", "p"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"v": {
|
||||
@@ -10,28 +10,68 @@
|
||||
"const": 1
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 4294967295,
|
||||
"description": "Autoincrement message id. Unique per session"
|
||||
},
|
||||
"type": {
|
||||
"t": {
|
||||
"type": "string",
|
||||
"enum": ["telemetry", "event"]
|
||||
"enum": ["t", "e", "c"],
|
||||
"description": "Message type (<t>elemetry, <e>vent, <c>ommand)"
|
||||
},
|
||||
"ts": {
|
||||
"type": "integer",
|
||||
"minimum": 1600000000000,
|
||||
"description": "Unix time in milliseconds (UTC)"
|
||||
"minimum": 1600000000,
|
||||
"description": "Unix time in seconds (UTC)"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
"d": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "Device ID. Unique per scope"
|
||||
},
|
||||
"payload": {
|
||||
"type": "object"
|
||||
},
|
||||
"meta": {
|
||||
"p": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
"description": "User data. Type-specific."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"required": ["t"],
|
||||
"properties": { "t": { "const": "t" } }
|
||||
},
|
||||
"then": {
|
||||
"required": ["p"],
|
||||
"properties": {
|
||||
"p": { "$ref": "telemetry.schema.json" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"required": ["t"],
|
||||
"properties": { "t": { "const": "e" } }
|
||||
},
|
||||
"then": {
|
||||
"required": ["p"],
|
||||
"properties": {
|
||||
"p": { "$ref": "event.schema.json" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"required": ["t"],
|
||||
"properties": { "t": { "const": "c" } }
|
||||
},
|
||||
"then": {
|
||||
"required": ["p"],
|
||||
"properties": {
|
||||
"p": { "$ref": "command.schema.json" }
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,46 +1,44 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "contract/ingest/telemetry.schema.json",
|
||||
"allOf": [
|
||||
{ "$ref": "contract/ingest/common.schema.json" },
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"payload": {
|
||||
"type": "object",
|
||||
"required": ["measurements"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"measurements": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["metric", "value"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"metric": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"value": {
|
||||
"type": ["number", "string", "boolean"]
|
||||
},
|
||||
"unit": {
|
||||
"type": "string"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"ts": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"type": "object",
|
||||
"required": ["m", "s", "u", "v"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"m": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "Metric type (e.g. t=temperature, h=humidity)"
|
||||
},
|
||||
"s": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "Source identifier (sensor/channel)"
|
||||
},
|
||||
"u": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "Unit (e.g. c, pct, v)"
|
||||
},
|
||||
"v": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
"maxItems": 2,
|
||||
"items": [
|
||||
{
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "Delta time (seconds) from base ts"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"description": "Measured value"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user