{
  "edition": "R3-draft",
  "wire_version": [
    0,
    2
  ],
  "profile": 2,
  "status": "proposed documentation contract; no MCU or TLS qualification",
  "limits": {
    "header_bytes": 24,
    "body_bytes": 4096,
    "depth": 8,
    "map_items": 32,
    "array_items": 256,
    "text_bytes": 128,
    "byte_string_bytes": 1024,
    "extension_key_min": 128,
    "extension_key_max": 255
  },
  "errors": {
    "OK": 0,
    "UNAUTHORIZED": 1,
    "BOOT_MISMATCH": 2,
    "FENCE_MISMATCH": 3,
    "ID_CONFLICT": 4,
    "RESULT_EVICTED": 5,
    "INVALID_VALUE": 6,
    "MANUAL_HOLD": 7,
    "EXPIRED": 9,
    "RESOURCE_LIMIT": 10,
    "UNKNOWN_COMMAND": 11,
    "PROFILE_MISMATCH": 12,
    "INVALID_FRAME": 13,
    "SYNC_REQUIRED": 14,
    "STORAGE_FAILURE": 15,
    "STATE_CONFLICT": 8
  },
  "definitions": {
    "ChannelDescriptor": {
      "fields": {
        "1": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 1,
          "maximum": 65535
        },
        "2": {
          "name": "capability",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "enum": [
            1,
            2,
            3,
            4
          ]
        },
        "3": {
          "name": "unit",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "enum": [
            0,
            1,
            2
          ]
        },
        "4": {
          "name": "writable",
          "type": "bool"
        },
        "5": {
          "name": "placement_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615
        },
        "6": {
          "name": "observability",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "enum": [
            0,
            1,
            2
          ]
        },
        "7": {
          "name": "mode_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535
        }
      }
    }
  },
  "messages": {
    "Hello": {
      "id": 1,
      "fields": {
        "1": {
          "name": "profile",
          "type": "uint",
          "minimum": 2,
          "maximum": 2,
          "const": 2
        },
        "2": {
          "name": "installation_id",
          "type": "bytes",
          "length": 16,
          "description": "installation_id bstr16"
        },
        "3": {
          "name": "peer_id",
          "type": "bytes",
          "length": 16,
          "description": "peer_id bstr16"
        },
        "4": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "5": {
          "name": "role",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            1,
            2
          ],
          "description": "role uint: 1=Core,2=MCU"
        },
        "6": {
          "name": "max_body",
          "type": "uint",
          "minimum": 256,
          "maximum": 4096
        },
        "7": {
          "name": "capabilities",
          "type": "array",
          "max_items": 16,
          "items": {
            "name": "value",
            "type": "uint",
            "minimum": 0,
            "maximum": 18446744073709551615
          },
          "description": "capabilities array uint, max16"
        }
      }
    },
    "Ready": {
      "id": 2,
      "fields": {
        "1": {
          "name": "profile",
          "type": "uint",
          "minimum": 2,
          "maximum": 2,
          "const": 2
        },
        "2": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        },
        "3": {
          "name": "accepted",
          "type": "bool",
          "description": "accepted bool"
        },
        "4": {
          "name": "max_body",
          "type": "uint",
          "minimum": 256,
          "maximum": 4096
        }
      }
    },
    "Describe": {
      "id": 16,
      "fields": {
        "1": {
          "name": "device_id",
          "type": "bytes",
          "length": 16,
          "description": "device_id bstr16"
        },
        "2": {
          "name": "descriptor_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "descriptor_revision uint64"
        },
        "3": {
          "name": "channels",
          "type": "array",
          "max_items": 16,
          "items": {
            "type": "ref",
            "ref": "ChannelDescriptor"
          }
        },
        "4": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        }
      }
    },
    "Snapshot": {
      "id": 17,
      "fields": {
        "1": {
          "name": "device_id",
          "type": "bytes",
          "length": 16,
          "description": "device_id bstr16"
        },
        "2": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "3": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "4": {
          "name": "controller_fence",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "controller_fence uint64"
        },
        "5": {
          "name": "output_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "output_revision uint64"
        },
        "6": {
          "name": "manual_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "manual_revision uint64"
        },
        "7": {
          "name": "output",
          "type": "bool",
          "description": "output bool"
        },
        "8": {
          "name": "manual_mode",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            0,
            1,
            2
          ],
          "description": "manual_mode uint:0=AUTO,1=HOLD,2=BOOT_INHIBIT"
        },
        "9": {
          "name": "execution_highwater",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "execution_highwater uint64"
        },
        "10": {
          "name": "sample_device_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "sample_device_us uint64"
        },
        "11": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        },
        "12": {
          "name": "descriptor_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "descriptor_revision uint64"
        }
      }
    },
    "Observation": {
      "id": 32,
      "fields": {
        "1": {
          "name": "device_id",
          "type": "bytes",
          "length": 16,
          "description": "device_id bstr16"
        },
        "2": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 1,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "3": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "4": {
          "name": "sample_seq",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "sample_seq uint64"
        },
        "5": {
          "name": "sample_start_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "sample_start_us uint64"
        },
        "6": {
          "name": "sample_end_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "sample_end_us uint64"
        },
        "7": {
          "name": "mantissa",
          "type": "int",
          "minimum": -9223372036854775808,
          "maximum": 9223372036854775807,
          "description": "mantissa int64"
        },
        "8": {
          "name": "exponent",
          "type": "int",
          "minimum": -6,
          "maximum": 3,
          "description": "exponent int -6..3"
        },
        "9": {
          "name": "unit",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            1,
            2,
            3
          ],
          "description": "unit uint:1=degC,2=lux,3=percent"
        },
        "10": {
          "name": "status",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            0,
            1,
            2
          ],
          "description": "status uint:0=VALID,1=INVALID,2=WARMING"
        },
        "11": {
          "name": "flags",
          "type": "uint",
          "minimum": 0,
          "maximum": 7,
          "description": "flags uint32: heater=1,saturation=2,delayed=4"
        },
        "12": {
          "name": "descriptor_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "descriptor_revision uint64"
        },
        "13": {
          "name": "placement_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "placement_revision uint64"
        },
        "14": {
          "name": "mode_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "mode_id uint16"
        },
        "15": {
          "name": "delivery_kind",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            0,
            1
          ],
          "description": "delivery_kind uint:0=LIVE,1=BACKFILL"
        }
      }
    },
    "Event": {
      "id": 33,
      "fields": {
        "1": {
          "name": "device_id",
          "type": "bytes",
          "length": 16,
          "description": "device_id bstr16"
        },
        "2": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "3": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "4": {
          "name": "sample_seq",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "sample_seq uint64"
        },
        "5": {
          "name": "device_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "device_us uint64"
        },
        "6": {
          "name": "event_kind",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            1,
            2,
            3
          ],
          "description": "event_kind uint:1=button,2=motion,3=gap"
        },
        "7": {
          "name": "value",
          "type": "bool_or_uint"
        },
        "8": {
          "name": "delivery_kind",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            0,
            1
          ],
          "description": "delivery_kind uint:0=LIVE,1=BACKFILL"
        }
      },
      "conditions": [
        {
          "if": {
            "field": 6,
            "equals": 3
          },
          "then": {
            "field": 7,
            "type": "uint"
          }
        },
        {
          "if": {
            "field": 6,
            "in": [
              1,
              2
            ]
          },
          "then": {
            "field": 7,
            "type": "bool"
          }
        }
      ]
    },
    "Command": {
      "id": 48,
      "fields": {
        "1": {
          "name": "command_id",
          "type": "bytes",
          "length": 16,
          "description": "command_id bstr16"
        },
        "2": {
          "name": "target_device_id",
          "type": "bytes",
          "length": 16,
          "description": "target_device_id bstr16"
        },
        "3": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 1,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "4": {
          "name": "expected_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "expected_boot_id bstr16"
        },
        "5": {
          "name": "controller_fence",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "controller_fence uint64"
        },
        "6": {
          "name": "execution_seq",
          "type": "uint",
          "minimum": 1,
          "maximum": 18446744073709551615,
          "description": "execution_seq uint64 >0"
        },
        "7": {
          "name": "expected_output_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "expected_output_revision uint64"
        },
        "8": {
          "name": "expected_manual_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "expected_manual_revision uint64"
        },
        "9": {
          "name": "not_after_device_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "not_after_device_us uint64"
        },
        "10": {
          "name": "operation",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            1,
            2
          ],
          "description": "operation uint:1=SET,2=RELEASE_MANUAL"
        },
        "11": {
          "name": "argument",
          "type": "bool_or_null"
        },
        "12": {
          "name": "cause",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            0,
            1
          ],
          "description": "cause uint:0=AUTOMATION,1=EXPLICIT_USER"
        }
      },
      "conditions": [
        {
          "if": {
            "field": 10,
            "equals": 1
          },
          "then": {
            "field": 11,
            "type": "bool"
          }
        },
        {
          "if": {
            "field": 10,
            "equals": 2
          },
          "then": {
            "field": 11,
            "type": "null"
          }
        },
        {
          "if": {
            "field": 10,
            "equals": 2
          },
          "then": {
            "field": 12,
            "equals": 1
          }
        }
      ]
    },
    "CommandResult": {
      "id": 49,
      "fields": {
        "1": {
          "name": "command_id",
          "type": "bytes",
          "length": 16,
          "description": "command_id bstr16"
        },
        "2": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "3": {
          "name": "execution_seq",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "execution_seq uint64"
        },
        "4": {
          "name": "status",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "enum": [
            1,
            2
          ],
          "description": "status uint: 1=APPLIED, 2=REJECTED; 3 reserved in R3-draft",
          "reserved": [
            3
          ]
        },
        "5": {
          "name": "error_code",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "error_code uint16",
          "enum": [
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15
          ]
        },
        "6": {
          "name": "output_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "output_revision uint64"
        },
        "7": {
          "name": "manual_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "manual_revision uint64"
        },
        "8": {
          "name": "output_at_result",
          "type": "bool",
          "description": "output_at_result bool"
        },
        "9": {
          "name": "result_device_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "result_device_us uint64"
        },
        "10": {
          "name": "controller_fence",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "controller_fence uint64"
        },
        "11": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        }
      },
      "conditions": [
        {
          "if": {
            "field": 4,
            "equals": 1
          },
          "then": {
            "field": 5,
            "equals": 0
          }
        },
        {
          "if": {
            "field": 4,
            "equals": 2
          },
          "then": {
            "field": 5,
            "not_equals": 0
          }
        }
      ]
    },
    "StatusQuery": {
      "id": 50,
      "fields": {
        "1": {
          "name": "command_id",
          "type": "bytes",
          "length": 16,
          "description": "command_id bstr16"
        },
        "2": {
          "name": "target_device_id",
          "type": "bytes",
          "length": 16,
          "description": "target_device_id bstr16"
        },
        "3": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "4": {
          "name": "expected_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "expected_boot_id bstr16"
        }
      }
    },
    "Resync": {
      "id": 51,
      "fields": {
        "1": {
          "name": "target_device_id",
          "type": "bytes",
          "length": 16,
          "description": "target_device_id bstr16"
        },
        "2": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "3": {
          "name": "known_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "known_boot_id bstr16"
        },
        "4": {
          "name": "known_output_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "known_output_revision uint64"
        },
        "5": {
          "name": "known_manual_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "known_manual_revision uint64"
        },
        "6": {
          "name": "known_descriptor_revision",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "known_descriptor_revision uint64"
        }
      }
    },
    "Ping": {
      "id": 64,
      "fields": {
        "1": {
          "name": "nonce",
          "type": "bytes",
          "length": 16,
          "description": "nonce bstr16"
        },
        "2": {
          "name": "core_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "core_boot_id bstr16"
        },
        "3": {
          "name": "c1_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "c1_us uint64"
        }
      }
    },
    "Pong": {
      "id": 65,
      "fields": {
        "1": {
          "name": "nonce",
          "type": "bytes",
          "length": 16,
          "description": "nonce bstr16"
        },
        "2": {
          "name": "core_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "core_boot_id bstr16"
        },
        "3": {
          "name": "device_boot_id",
          "type": "bytes",
          "length": 16,
          "description": "device_boot_id bstr16"
        },
        "4": {
          "name": "c1_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "c1_us uint64"
        },
        "5": {
          "name": "d2_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "d2_us uint64"
        },
        "6": {
          "name": "d3_us",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "d3_us uint64"
        },
        "7": {
          "name": "clock_mode",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "clock_mode uint16"
        },
        "8": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        }
      }
    },
    "TelemetryAck": {
      "id": 66,
      "fields": {
        "1": {
          "name": "device_id",
          "type": "bytes",
          "length": 16,
          "description": "device_id bstr16"
        },
        "2": {
          "name": "channel_id",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "channel_id uint16"
        },
        "3": {
          "name": "boot_id",
          "type": "bytes",
          "length": 16,
          "description": "boot_id bstr16"
        },
        "4": {
          "name": "durable_through_seq",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "durable_through_seq uint64"
        },
        "5": {
          "name": "credit",
          "type": "uint",
          "minimum": 0,
          "maximum": 256,
          "description": "credit uint16 0..256"
        }
      }
    },
    "Error": {
      "id": 255,
      "fields": {
        "1": {
          "name": "error_code",
          "type": "uint",
          "minimum": 0,
          "maximum": 65535,
          "description": "error_code uint16",
          "enum": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15
          ]
        },
        "2": {
          "name": "reply_to",
          "type": "uint",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "reply_to uint64"
        },
        "3": {
          "name": "diagnostic",
          "type": "text",
          "max_bytes": 128,
          "description": "diagnostic text max128, no secrets"
        }
      }
    }
  },
  "policies": {
    "manual_mode": "indefinite HOLD; explicit RELEASE_MANUAL; reboot BOOT_INHIBIT",
    "unknown_result": "CommandResult status3 reserved; StatusQuery unknown returns Error UNKNOWN_COMMAND; no fabricated historical fields",
    "unsolicited_snapshot": "reply_to=0",
    "event_provenance": "wire0.2 relocation needs explicit admission barrier; richer Event requires future profile"
  }
}
