{
  "$defs": {
    "genericTimeSource": {
      "properties": {
        "error": {
          "description": "estimated error in seconds, with arbitrary sub-second precision",
          "type": "number"
        },
        "state": {
          "description": "state of the source",
          "enum": [
            "best",
            "combined",
            "not_combined",
            "maybe_error",
            "unstable",
            "unusable"
          ],
          "type": "string"
        },
        "stratum": {
          "description": "stratum of the clock source",
          "minimum": 0,
          "type": "integer"
        },
        "type": {
          "description": "type of the time source",
          "enum": [
            "ntp",
            "pps",
            "nmea"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "stratum",
        "state",
        "error"
      ],
      "type": "object"
    },
    "nmeaTimeSource": {
      "allOf": [
        {
          "$ref": "#/$defs/genericTimeSource"
        },
        {
          "properties": {
            "stratum": {
              "const": 0
            },
            "type": {
              "const": "nmea"
            }
          },
          "type": "object"
        }
      ],
      "type": "object"
    },
    "ntpTimeSource": {
      "allOf": [
        {
          "$ref": "#/$defs/genericTimeSource"
        },
        {
          "properties": {
            "host": {
              "description": "IP or hostname of the NTP server",
              "type": "string"
            },
            "stratum": {
              "minimum": 1
            },
            "type": {
              "const": "ntp"
            }
          },
          "required": [
            "host"
          ],
          "type": "object"
        }
      ],
      "type": "object"
    },
    "ppsTimeSource": {
      "allOf": [
        {
          "$ref": "#/$defs/genericTimeSource"
        },
        {
          "properties": {
            "label": {
              "description": "PPS label/name",
              "type": "string"
            },
            "stratum": {
              "const": 0
            },
            "type": {
              "const": "pps"
            }
          },
          "required": [
            "label"
          ],
          "type": "object"
        }
      ],
      "type": "object"
    }
  },
  "$id": "https://Orange-OpenSource.github.io/its-client/schema/status",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Status JSON schema",
  "properties": {
    "cellular": {
      "description": "cellular connections",
      "items": {
        "description": "cellular connection status",
        "properties": {
          "connection": {
            "description": "connection details",
            "properties": {
              "signal": {
                "description": "signal quality metrics",
                "properties": {
                  "ecio": {
                    "type": "number"
                  },
                  "io": {
                    "type": "number"
                  },
                  "rscp": {
                    "type": "number"
                  },
                  "rsrp": {
                    "type": "number"
                  },
                  "rsrq": {
                    "type": "number"
                  },
                  "rssi": {
                    "type": "number"
                  },
                  "sinr": {
                    "type": "number"
                  },
                  "snr": {
                    "type": "number"
                  }
                },
                "type": "object"
              },
              "technology": {
                "examples": [
                  "gsm",
                  "cdma1x",
                  "evdo",
                  "umts",
                  "lte",
                  "5G"
                ],
                "type": "string"
              }
            },
            "type": "object"
          },
          "hardware": {
            "description": "harddware informatsion",
            "properties": {
              "model": {
                "type": "string"
              },
              "revision": {
                "type": "string"
              },
              "vendor": {
                "type": "string"
              }
            },
            "type": "object"
          },
          "operator": {
            "description": "cellular operator",
            "properties": {
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "required": [
          "hardware"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "id": {
      "description": "unique id all over the world for this device",
      "type": "string"
    },
    "system": {
      "additionalProperties": true,
      "description": "system low-level info",
      "properties": {
        "cpu_load": {
          "description": "CPU load, as a 3-tuple: [1min_load, 5min_load, 15min_load]",
          "items": {
            "minimum": 0.0,
            "type": "number"
          },
          "maxItems": 3,
          "minItems": 3,
          "type": "array"
        },
        "hardware": {
          "description": "type of hardware",
          "examples": [
            "vtc6221",
            "vtc7251",
            "rpi2"
          ],
          "type": "string"
        },
        "memory": {
          "description": "RAM usage, in bytes, as a 2-tuple: [total_ram, available_ram]",
          "items": {
            "type": "integer"
          },
          "maxItems": 2,
          "minItems": 2,
          "type": "array"
        },
        "os_release": {
          "$comment": "all keys of os-release are optional; see https://www.freedesktop.org/software/systemd/man/os-release.html",
          "additionalProperties": true,
          "description": "a key-value representation of the os-release of the running OS",
          "properties": {
            "ID": {
              "type": "string"
            },
            "NAME": {
              "type": "string"
            },
            "PRETTY_NAME": {
              "type": "string"
            },
            "VERSION": {
              "type": "string"
            },
            "VERSION_ID": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "storage": {
          "description": "writable storage for data, as a 2-tuple: [total_space, free_space]",
          "items": {
            "type": "integer"
          },
          "maxItems": 2,
          "minItems": 2,
          "type": "array"
        }
      },
      "required": [
        "hardware",
        "os_release",
        "memory",
        "storage",
        "cpu_load"
      ],
      "type": "object"
    },
    "time_sources": {
      "description": "status of time-keeping services",
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/ntpTimeSource"
          },
          {
            "$ref": "#/$defs/ppsTimeSource"
          },
          {
            "$ref": "#/$defs/nmeaTimeSource"
          }
        ],
        "type": "object"
      },
      "type": "array"
    },
    "timestamp": {
      "description": "date the information was generated, in seconds since 1970-01-01 00:00:00 +00:00, with arbitrary sub-second precision",
      "minimum": 0.0,
      "type": "number"
    },
    "type": {
      "description": "type of the server",
      "enum": [
        "obu",
        "other"
      ],
      "type": "string"
    },
    "version": {
      "const": "1.0.0",
      "description": "version of the format of this JSON message",
      "type": "string"
    }
  },
  "required": [
    "version",
    "id",
    "type",
    "timestamp",
    "system",
    "time_sources",
    "cellular"
  ],
  "type": "object"
}