{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://univip.org/schemas/v0.2/telemetry.schema.json",
  "title": "UNIVIP telemetry sample v0.2",
  "type": "object",
  "required": ["schema", "device_id", "session_id", "timestamp", "sequence", "time", "link", "vehicle", "health"],
  "properties": {
    "schema": { "type": "string", "pattern": "^univip\\.telemetry\\.v0\\.[0-9]+$", "description": "Any 0.x MINOR is accepted (Part 01 §1.5)" },
    "device_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/DeviceId" },
    "session_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
    "timestamp": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Timestamp" },
    "sequence": { "type": "integer", "minimum": 0 },
    "replayed": { "type": "boolean", "description": "True when flushed from an offline store-and-forward buffer after reconnect (Part 07 §7.9.1)" },
    "time": {
      "type": "object",
      "required": ["source"],
      "properties": {
        "source": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/TimeSource" },
        "accuracy_ms": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" }
      }
    },
    "position": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Position" },
    "local_pose": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/LocalPose" },
    "motion": {
      "type": "object",
      "properties": {
        "age_ms": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative", "description": "Age of these values at timestamp (Part 07 §7.1)" },
        "heading_deg": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Degrees360" },
        "course_deg": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Degrees360" },
        "ground_speed_mps": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "velocity_north_mps": { "type": "number" },
        "velocity_east_mps": { "type": "number" },
        "velocity_down_mps": { "type": "number" },
        "roll_deg": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Degrees180" },
        "pitch_deg": { "type": "number", "minimum": -90, "maximum": 90 },
        "yaw_deg": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Degrees360" },
        "roll_rate_degps": { "type": "number" },
        "pitch_rate_degps": { "type": "number" },
        "yaw_rate_degps": { "type": "number" }
      }
    },
    "power": {
      "type": "object",
      "required": ["battery_pct"],
      "properties": {
        "age_ms": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative", "description": "Age of these values at timestamp (Part 07 §7.1)" },
        "battery_pct": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Percent" },
        "voltage_v": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "current_a": { "type": "number" },
        "remaining_endurance_s": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "batteries": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id"],
            "properties": {
              "id": { "type": "string" },
              "pct": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Percent" },
              "voltage_v": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
              "temperature_c": { "type": "number" },
              "cycles": { "type": "integer", "minimum": 0 }
            }
          }
        }
      }
    },
    "remote_id": {
      "type": "object",
      "required": ["state"],
      "properties": { "state": { "enum": ["ACTIVE", "INACTIVE", "FAULT", "UNKNOWN"], "description": "Whether the vehicle's own Remote ID broadcast is active; UNIVIP does not carry the broadcast (Part 13 §13.20)" } }
    },
    "link": {
      "type": "object",
      "required": ["state"],
      "properties": {
        "state": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/LinkState" },
        "signal_quality_pct": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Percent" },
        "rssi_dbm": { "type": "number" },
        "latency_ms": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "uplink_kbps": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "downlink_kbps": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "transport": { "enum": ["RADIO", "CELLULAR", "WIFI", "SATELLITE", "TETHER", "ACOUSTIC", "OPTICAL", "OTHER"] }
      }
    },
    "vehicle": {
      "type": "object",
      "required": ["vehicle_state"],
      "properties": {
        "vehicle_state": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/VehicleState" },
        "domain_state": { "type": "string", "description": "Domain-specific state as shown to the operator, e.g. FLYING, HOVERING, SUBMERGED, SURFACED" },
        "flight_mode": { "type": "string", "description": "Vendor mode string (kept for aerial familiarity; underwater vehicles use it for control mode)" },
        "armed": { "type": "boolean" },
        "home": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/GeoPoint" },
        "distance_from_home_m": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "operation_time_s": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "in_geofence": { "type": "boolean" },
        "control": {
          "type": "object",
          "properties": {
            "vehicle_lease_id": { "type": "string" },
            "pilot_override": { "type": "boolean" },
            "source": { "enum": ["PILOT", "CLIENT", "AUTONOMOUS", "FAILSAFE", "UNKNOWN"] }
          }
        }
      }
    },
    "payloads": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["payload_id", "type"],
        "properties": {
          "age_ms": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative", "description": "Age of these values at timestamp (Part 07 §7.1)" },
          "payload_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
          "type": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/PayloadType" },
          "gimbal": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/GimbalOrientation" },
          "zoom_ratio": { "type": "number", "minimum": 0 },
          "focal_length_mm": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
          "hfov_deg": { "type": "number", "exclusiveMinimum": 0, "maximum": 360 },
          "vfov_deg": { "type": "number", "exclusiveMinimum": 0, "maximum": 180 },
          "recording": {
            "type": "object",
            "required": ["active"],
            "properties": {
              "active": { "type": "boolean" },
              "started_at": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Timestamp" },
              "media_id": { "type": "string" }
            }
          },
          "stream_ids": { "type": "array", "items": { "type": "string" } },
          "thermal": {
            "type": "object",
            "properties": { "palette": { "type": "string" }, "gain_mode": { "type": "string" } }
          },
          "geospatial": { "$ref": "https://univip.org/schemas/v0.2/geospatial.schema.json#/$defs/Footprint" },
          "status": { "enum": ["IDLE", "ACTIVE", "WARMING_UP", "FAULT", "UNKNOWN"] },
          "measurements": { "type": "object", "additionalProperties": { "type": "number" }, "description": "Unit-suffixed scalar sensor readings (Part 07 §7.9)" }
        }
      }
    },
    "autonomy": {
      "type": "object",
      "description": "Profile A runtime autonomy, goal and ODD state (Part 15 §15.2.3)",
      "required": ["state"],
      "properties": {
        "state": { "enum": ["IDLE", "PLANNING", "EXECUTING_GOAL", "REPLANNING", "AWAITING_ASSIST", "ODD_DEGRADED", "FALLBACK", "UNKNOWN"] },
        "active_goal_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
        "goal_type": { "type": "string" },
        "goal_progress_pct": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Percent" },
        "localization_confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "perception_status": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/HealthStatus" },
        "odd": {
          "type": "object",
          "required": ["in_odd"],
          "properties": {
            "in_odd": { "type": "boolean" },
            "margin_pct": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Percent" },
            "limiting_factors": { "type": "array", "items": { "type": "string" } }
          }
        }
      }
    },
    "fleet": {
      "type": "object",
      "description": "Profile F fleet readiness, dock state and operation correlation (Part 15 §15.3.2)",
      "required": ["availability"],
      "properties": {
        "availability": { "enum": ["AVAILABLE", "ASSIGNED", "DEPLOYED", "TURNAROUND", "CHARGING", "MAINTENANCE", "OFFLINE", "UNKNOWN"] },
        "fleet_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
        "operation_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
        "assigned_dock_id": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Id" },
        "dock_state": { "enum": ["CLOSED", "OPENING", "OPEN", "CLOSING", "CHARGING", "READY", "WEATHER_HOLD", "FAULT", "UNKNOWN"] },
        "turnaround_eta_s": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" },
        "deployable_range_m": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" }
      }
    },
    "health": {
      "type": "object",
      "required": ["status", "gnss"],
      "properties": {
        "status": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/HealthStatus" },
        "gnss": {
          "type": "object",
          "required": ["fix"],
          "properties": {
            "fix": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/GnssFix" },
            "satellites": { "type": "integer", "minimum": 0 },
            "hdop": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/NonNegative" }
          }
        },
        "faults": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["code", "severity"],
            "properties": {
              "code": { "type": "string" },
              "severity": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Severity" },
              "message": { "type": "string" },
              "since": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/Timestamp" }
            }
          }
        },
        "sensors": { "type": "object", "additionalProperties": { "$ref": "https://univip.org/schemas/v0.2/common.schema.json#/$defs/HealthStatus" } },
        "temperature_c": { "type": "number" }
      }
    }
  }
}
