376 lines
12 KiB
JSON
376 lines
12 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"$id": "https://example.com/wh-telemetry.schema.json",
|
|
"title": "WH Telemetry Protocol v1 Message",
|
|
"description": "JSON Schema definition for a WH Telemetry Protocol (WHTP) telemetry message.",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"version",
|
|
"msg_type",
|
|
"dev_id",
|
|
"dev_type",
|
|
"timestamp",
|
|
"fields"
|
|
],
|
|
"properties": {
|
|
"version": {
|
|
"type": "integer",
|
|
"const": 1,
|
|
"description": "Protocol major version, currently fixed to 1."
|
|
},
|
|
"msg_type": {
|
|
"type": "string",
|
|
"const": "telemetry",
|
|
"description": "Message type, only 'telemetry' is supported for now."
|
|
},
|
|
"mode": {
|
|
"type": "string",
|
|
"enum": [
|
|
"descriptive",
|
|
"strict"
|
|
],
|
|
"description": "Operating mode of the message."
|
|
},
|
|
"dev_id": {
|
|
"type": "string",
|
|
"format": "uuid",
|
|
"description": "Device unique identifier (UUID v4)."
|
|
},
|
|
"dev_type": {
|
|
"description": "Device model identifier.",
|
|
"oneOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"oneOf": [
|
|
{
|
|
"required": [
|
|
"type_id"
|
|
],
|
|
"properties": {
|
|
"type_id": {
|
|
"type": "string",
|
|
"format": "uuid"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
{
|
|
"required": [
|
|
"type_name"
|
|
],
|
|
"properties": {
|
|
"type_name": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"timestamp": {
|
|
"$ref": "#/definitions/Timestamp"
|
|
},
|
|
"fields": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {
|
|
"$ref": "#/definitions/Field"
|
|
}
|
|
},
|
|
"metadata": {
|
|
"$ref": "#/definitions/MessageMetadata"
|
|
}
|
|
},
|
|
"definitions": {
|
|
"Timestamp": {
|
|
"description": "Flexible timestamp supporting multiple formats.",
|
|
"oneOf": [
|
|
{
|
|
"type": "number"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"oneOf": [
|
|
{
|
|
"required": [
|
|
"unix_s"
|
|
],
|
|
"properties": {
|
|
"unix_s": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"required": [
|
|
"unix_ms"
|
|
],
|
|
"properties": {
|
|
"unix_ms": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"required": [
|
|
"unix_us"
|
|
],
|
|
"properties": {
|
|
"unix_us": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"required": [
|
|
"unix_ns"
|
|
],
|
|
"properties": {
|
|
"unix_ns": {
|
|
"type": "number"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"required": [
|
|
"iso8601"
|
|
],
|
|
"properties": {
|
|
"iso8601": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"SampleInterval": {
|
|
"oneOf": [
|
|
{
|
|
"type": "number"
|
|
},
|
|
{
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"minProperties": 1,
|
|
"properties": {
|
|
"ms": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"s": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"m": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"h": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"d": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"w": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"Confidence": {
|
|
"oneOf": [
|
|
{
|
|
"type": "number",
|
|
"minimum": 0,
|
|
"maximum": 1
|
|
},
|
|
{
|
|
"type": "array",
|
|
"items": {
|
|
"type": "number",
|
|
"minimum": 0,
|
|
"maximum": 1
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"InlineEnum": {
|
|
"type": "object",
|
|
"minProperties": 1,
|
|
"patternProperties": {
|
|
"^[A-Za-z_][A-Za-z0-9_]*$": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"FieldMetadata": {
|
|
"type": "object",
|
|
"description": "Metadata describing a field value.",
|
|
"required": [
|
|
"data_type"
|
|
],
|
|
"properties": {
|
|
"data_type": {
|
|
"type": "string"
|
|
},
|
|
"timestamp": {
|
|
"$ref": "#/definitions/Timestamp"
|
|
},
|
|
"sample_interval": {
|
|
"$ref": "#/definitions/SampleInterval"
|
|
},
|
|
"unit": {
|
|
"type": "string"
|
|
},
|
|
"label": {
|
|
"type": "string"
|
|
},
|
|
"confidence": {
|
|
"$ref": "#/definitions/Confidence"
|
|
},
|
|
"error_code": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"error_msg": {
|
|
"type": "string"
|
|
},
|
|
"enum": {
|
|
"$ref": "#/definitions/InlineEnum"
|
|
},
|
|
"user": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"Field": {
|
|
"type": "object",
|
|
"description": "Single telemetry measurement field.",
|
|
"required": [
|
|
"id",
|
|
"value",
|
|
"metadata"
|
|
],
|
|
"properties": {
|
|
"id": {
|
|
"type": "string",
|
|
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
|
|
},
|
|
"value": {
|
|
"oneOf": [
|
|
{
|
|
"type": [
|
|
"string",
|
|
"number",
|
|
"boolean"
|
|
]
|
|
},
|
|
{
|
|
"type": "array"
|
|
},
|
|
{
|
|
"type": "object"
|
|
}
|
|
]
|
|
},
|
|
"metadata": {
|
|
"$ref": "#/definitions/FieldMetadata"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"EnumDefinition": {
|
|
"type": "object",
|
|
"required": [
|
|
"id",
|
|
"value"
|
|
],
|
|
"properties": {
|
|
"id": {
|
|
"type": "string"
|
|
},
|
|
"value": {
|
|
"$ref": "#/definitions/InlineEnum"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"Location": {
|
|
"type": "object",
|
|
"required": [
|
|
"coordinates"
|
|
],
|
|
"properties": {
|
|
"coordinates": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "number"
|
|
},
|
|
"minItems": 2,
|
|
"maxItems": 2
|
|
},
|
|
"coordinate_system": {
|
|
"type": "string",
|
|
"enum": [
|
|
"wgs84",
|
|
"gcj02",
|
|
"bd09"
|
|
]
|
|
},
|
|
"accuracy": {
|
|
"type": "number",
|
|
"minimum": 0
|
|
},
|
|
"altitude": {
|
|
"type": "number"
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
},
|
|
"MessageMetadata": {
|
|
"type": "object",
|
|
"properties": {
|
|
"enums": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/definitions/EnumDefinition"
|
|
}
|
|
},
|
|
"location": {
|
|
"$ref": "#/definitions/Location"
|
|
},
|
|
"battery": {
|
|
"type": "number",
|
|
"minimum": 0,
|
|
"maximum": 100
|
|
},
|
|
"seq": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"user": {
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}
|
|
},
|
|
"additionalProperties": false
|
|
}
|
|
}
|
|
} |