{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "content": {
      "$ref": "#/definitions/content"
    },
    "problem": {
      "$ref": "#/definitions/problem"
    },
    "reason": {
      "description": "Human-readable interpretation of status code",
      "type": "string"
    },
    "status": {
      "description": "Status code, always equal to the HTTP response status code",
      "maximum": 999,
      "minimum": 100,
      "type": "integer"
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false,
  "definitions": {
    "problem": {
      "additionalProperties": true,
      "properties": {
        "message": {
          "description": "Additional message string describing problem",
          "type": "string"
        },
        "title": {
          "description": "Human-readable interpretation of problem",
          "type": "string"
        },
        "type": {
          "description": "Problem classification tag",
          "type": "string"
        }
      },
      "required": [
        "type",
        "title"
      ],
      "type": "object"
    },
    "content": {
      "oneOf": [
        {
          "$ref": "#/definitions/gnss-location"
        },
        {
          "$ref": "#/definitions/gnss-velocity"
        },
        {
          "$ref": "#/definitions/imu-accel"
        },
        {
          "$ref": "#/definitions/imu-gyro"
        },
        {
          "$ref": "#/definitions/led-status"
        },
        {
          "$ref": "#/definitions/modem-state"
        },
        {
          "$ref": "#/definitions/system-status"
        },
        {
          "$ref": "#/definitions/time-timestamp"
        },
        {
          "$ref": "#/definitions/time-iso-date"
        }
      ]
    },
    "gnss-location": {
      "additionalProperties": false,
      "properties": {
        "altitude": {
          "description": "Altitude above sealevel, in meters",
          "type": "number"
        },
        "altitude-error": {
          "description": "Estimated vertical error, in meters",
          "type": "number"
        },
        "latitude": {
          "description": "Latitude north-south position as angle, in degrees",
          "type": "number"
        },
        "latitude-error": {
          "description": "Latitude error estimate, in meters",
          "type": "number"
        },
        "longitude": {
          "description": "Longitude east/west position as angle, in degrees",
          "type": "number"
        },
        "longitude-error": {
          "description": "Longitude error estimate, in meters",
          "type": "number"
        }
      },
      "type": "object"
    },
    "gnss-velocity": {
      "additionalProperties": false,
      "properties": {
        "climb": {
          "description": "Climb (positive) or sink (negative) rate, m/s",
          "type": "number"
        },
        "climb-error": {
          "description": "Climb/sink error estimate in m/s",
          "type": "number"
        },
        "speed": {
          "description": "Speed over ground, m/s",
          "type": "number"
        },
        "speed-error": {
          "description": "Speed error estimate in m/s",
          "type": "number"
        },
        "track": {
          "description": "Course over ground, degrees from true north",
          "type": "number"
        },
        "track-error": {
          "description": "Direction error estimate in degrees",
          "type": "number"
        }
      },
      "type": "object"
    },
    "imu-accel": {
      "additionalProperties": false,
      "properties": {
        "x": {
          "description": "current x-axis force, m/s^2",
          "type": "number"
        },
        "y": {
          "description": "current y-axis force, m/s^2",
          "type": "number"
        },
        "z": {
          "description": "current z-axis force, m/s^2",
          "type": "number"
        }
      },
      "type": "object"
    },
    "imu-gyro": {
      "additionalProperties": false,
      "properties": {
        "x": {
          "description": "current x-axis angular rate, degree/s",
          "type": "number"
        },
        "y": {
          "description": "current y-axis angular rate, degree/s",
          "type": "number"
        },
        "z": {
          "description": "current z-axis angular rate, degree/s",
          "type": "number"
        }
      },
      "type": "object"
    },
    "led-status": {
      "type": "object",
      "required": [
        "system",
        "mobile1",
        "mobile2",
        "vpn",
        "wlan1",
        "wlan2",
        "gnss",
        "misc"
      ],
      "maxProperties": 8,
      "additionalProperties": {
        "type": "object",
        "required": ["state"],
        "maxProperties": 1,
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "off",
              "red",
              "orange",
              "green"
            ]
          }
        }
      }
    },
    "modem-state": {
      "type": "object",
      "patternProperties": {
        "^(mbm)[0-9]$": {
          "type": "object",
          "properties": {
            "state": {
              "description": "Modem connection state",
              "type": "string",
              "enum": [
                "ue",
                "sim",
                "net",
                "pdp",
                "ip"
              ]
            },
            "gsm": {
              "description": "2G/GSM signal information",
              "type": "object",
              "properties": {
                "rssi": {
                  "description": "GSM Received Signal Strength Indicator, dBm",
                  "type": "number"
                }
              },
              "additionalProperties": false
            },
            "umts": {
              "description": "3G/UMTS signal information",
              "type": "object",
              "properties": {
                "rssi": {
                  "description": "UMTS Received Signal Strength Indicator, dBm",
                  "type": "number"
                },
                "ecio": {
                  "description": "EC/IO signal quality indicator, dB",
                  "type": "number"
                }
              },
              "additionalProperties": false
            },
            "lte": {
              "description": "4G/LTE signal information",
              "type": "object",
              "properties": {
                "rssi": {
                  "description": "LTE Received Signal Strength Indicator, dBm",
                  "type": "number"
                },
                "rsrp": {
                  "description": "Reference Signal Received Power, dBm",
                  "type": "number"
                },
                "rsrq": {
                  "description": "Reference Signal Received Quality, dB",
                  "type": "number"
                },
                "sinr": {
                  "description": "Signal to Interference plus Noise Ratio, dB",
                  "type": "number"
                }
              },
              "additionalProperties": false
            },
            "5g": {
              "description": "5G signal information",
              "type": "object",
              "properties": {
                "rsrp": {
                  "description": "Reference Signal Received Power, dBm",
                  "type": "number"
                },
                "rsrq": {
                  "description": "Reference Signal Received Quality, dB",
                  "type": "number"
                }
              },
              "additionalProperties": false
            }
          },
          "required": ["state"],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "system-status": {
      "type": "object",
      "required": [
        "id",
        "hardware-revision",
        "software-version",
        "fallback"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique device identifier: 'Manufacturer/Model/Serial'"
        },
        "hardware-revision": {
          "type": "string",
          "description": "Device hardware revision"
        },
        "software-version": {
          "type": "string",
          "description": "Current software version"
        },
        "fallback": {
          "type": "boolean",
          "description": "True if device is running in fallback state"
        }
      }
    },
    "time-timestamp": {
      "type": "object",
      "required": [
        "time",
        "raw"
      ],
      "additionalProperties": false,
      "properties": {
        "time": {
          "description": "System time, gradually adjusted, microseconds since Unix Epoch",
          "type": "number"
        },
        "raw": {
          "description": "Raw system time, more accurate but affected by discontinuous jumps, microseconds since Unix Epoch",
          "type": "number"
        }
      }
    },
    "time-iso-date": {
      "type": "object",
      "required": [
        "time",
        "raw"
      ],
      "additionalProperties": false,
      "properties": {
        "time": {
          "description": "System time, gradually adjusted, IS0-8601 formatted, zero UTC offset",
          "type": "string"
        },
        "raw": {
          "description": "System time, more accurate but affected by discontinuous jumps, IS0-8601 formatted, zero UTC offset",
          "type": "string"
        }
      }
    }
  }
}
