{
  "name": "USB Bridge",
  "status": "rc",
  "shortId": "usbbridge",
  "camelName": "usbBridge",
  "shortName": "usbBridge",
  "extends": [
    "_base"
  ],
  "notes": {
    "short": "This service is normally not announced or otherwise exposed on the serial bus.\nIt is used to communicate with a USB-Jacdac bridge at the USB layer.\nThe host sends broadcast packets to this service to control the link layer.\nThe device responds with broadcast reports (no-one else does that).\nThese packets are not forwarded to the UART Jacdac line.\n\nPackets are sent over USB Serial (CDC).\nThe host shall set the CDC to 1Mbaud 8N1\n(even though in some cases the USB interface is connected directly to the MCU and line settings are\nignored).\n\nThe CDC line carries both Jacdac frames and serial logging output.\nJacdac frames have valid CRC and are framed by delimeter characters and possibly fragmented.\n\n`0xFE` is used as a framing byte.\nNote that bytes `0xF8`-`0xFF` are always invalid UTF-8.\n`0xFF` occurs relatively often in Jacdac packets, so is not used for framing.\n\nThe following sequences are supported:\n\n* `0xFE 0xF8` - literal 0xFE\n* `0xFE 0xF9` - reserved; ignore\n* `0xFE 0xFA` - indicates that some serial logs were dropped at this point\n* `0xFE 0xFB` - indicates that some Jacdac frames were dropped at this point\n* `0xFE 0xFC` - Jacdac frame start\n* `0xFE 0xFD` - Jacdac frame end\n\n0xFE followed by any other byte:\n* in serial, should be treated as literal 0xFE (and the byte as itself, unless it's 0xFE)\n* in frame data, should terminate the current frame fragment,\n  and ideally have all data (incl. fragment start) in the current frame fragment treated as serial"
  },
  "classIdentifier": 418781770,
  "enums": {
    "QByte": {
      "name": "QByte",
      "storage": 1,
      "members": {
        "Magic": 254,
        "LiteralMagic": 248,
        "Reserved": 249,
        "SerialGap": 250,
        "FrameGap": 251,
        "FrameStart": 252,
        "FrameEnd": 253
      }
    }
  },
  "constants": {},
  "packets": [
    {
      "kind": "report",
      "name": "command_not_implemented",
      "identifier": 3,
      "description": "This report may be emitted by a server in response to a command (action or register operation)\nthat it does not understand.\nThe `service_command` and `packet_crc` fields are copied from the command packet that was unhandled.\nNote that it's possible to get an ACK, followed by such an error report.",
      "fields": [
        {
          "name": "service_command",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "packet_crc",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "identifierName": "command_not_implemented",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "const",
      "name": "instance_name",
      "identifier": 265,
      "description": "A friendly name that describes the role of this service instance in the device.\nIt often corresponds to what's printed on the device:\nfor example, `A` for button A, or `S0` for servo channel 0.\nWords like `left` should be avoided because of localization issues (unless they are printed on the device).",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "instance_name",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "ro",
      "name": "status_code",
      "identifier": 259,
      "description": "Reports the current state or error status of the device. ``code`` is a standardized value from \nthe Jacdac status/error codes. ``vendor_code`` is any vendor specific error code describing the device\nstate. This report is typically not queried, when a device has an error, it will typically\nadd this report in frame along with the announce packet. If a service implements this register,\nit should also support the ``status_code_changed`` event defined below.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "rw",
      "name": "client_variant",
      "identifier": 9,
      "description": "An optional register in the format of a URL query string where the client can provide hints how\nthe device twin should be rendered. If the register is not implemented, the client library can simulate the register client side.",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "client_variant",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "event",
      "name": "status_code_changed",
      "identifier": 4,
      "description": "Notifies that the status code of the service changed.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code_changed",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "command",
      "name": "disable_packets",
      "identifier": 128,
      "description": "Disables forwarding of Jacdac packets.",
      "fields": [],
      "hasReport": true
    },
    {
      "kind": "report",
      "name": "disable_packets",
      "identifier": 128,
      "description": "Disables forwarding of Jacdac packets.",
      "fields": [],
      "secondary": true
    },
    {
      "kind": "command",
      "name": "enable_packets",
      "identifier": 129,
      "description": "Enables forwarding of Jacdac packets.",
      "fields": [],
      "hasReport": true
    },
    {
      "kind": "report",
      "name": "enable_packets",
      "identifier": 129,
      "description": "Enables forwarding of Jacdac packets.",
      "fields": [],
      "secondary": true
    },
    {
      "kind": "command",
      "name": "disable_log",
      "identifier": 130,
      "description": "Disables forwarding of serial log messages.",
      "fields": [],
      "hasReport": true
    },
    {
      "kind": "report",
      "name": "disable_log",
      "identifier": 130,
      "description": "Disables forwarding of serial log messages.",
      "fields": [],
      "secondary": true
    },
    {
      "kind": "command",
      "name": "enable_log",
      "identifier": 131,
      "description": "Enables forwarding of serial log messages.",
      "fields": [],
      "hasReport": true
    },
    {
      "kind": "report",
      "name": "enable_log",
      "identifier": 131,
      "description": "Enables forwarding of serial log messages.",
      "fields": [],
      "secondary": true
    }
  ],
  "tags": [
    "infrastructure"
  ]
}