{
  "name": "bit:radio",
  "status": "stable",
  "shortId": "bitradio",
  "camelName": "bitRadio",
  "shortName": "bitRadio",
  "extends": [
    "_base"
  ],
  "notes": {
    "short": "Support for sending and receiving packets using the [Bit Radio protocol](https://github.com/microsoft/pxt-common-packages/blob/master/libs/radio/docs/reference/radio.md), typically used between micro:bit devices."
  },
  "classIdentifier": 449414863,
  "enums": {},
  "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": "rw",
      "name": "enabled",
      "identifier": 1,
      "description": "Turns on/off the radio antenna.",
      "fields": [
        {
          "name": "_",
          "type": "bool",
          "storage": 1
        }
      ],
      "identifierName": "intensity",
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "group",
      "identifier": 128,
      "description": "Group used to filter packets",
      "fields": [
        {
          "name": "_",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "transmission_power",
      "identifier": 129,
      "description": "Antenna power to increase or decrease range.",
      "fields": [
        {
          "name": "_",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true,
          "defaultValue": 6,
          "absoluteMin": 1,
          "absoluteMax": 7
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "frequency_band",
      "identifier": 130,
      "description": "Change the transmission and reception band of the radio to the given channel.",
      "fields": [
        {
          "name": "_",
          "type": "u8",
          "storage": 1,
          "isSimpleType": true,
          "defaultValue": 7,
          "absoluteMax": 83,
          "absoluteMin": 0
        }
      ],
      "packFormat": "u8"
    },
    {
      "kind": "command",
      "name": "send_string",
      "identifier": 128,
      "description": "Sends a string payload as a radio message, maximum 18 characters.",
      "fields": [
        {
          "name": "message",
          "type": "string",
          "storage": 0
        }
      ],
      "unique": true,
      "packFormat": "s"
    },
    {
      "kind": "command",
      "name": "send_number",
      "identifier": 129,
      "description": "Sends a double precision number payload as a radio message",
      "fields": [
        {
          "name": "value",
          "isFloat": true,
          "type": "f64",
          "storage": 8
        }
      ],
      "unique": true,
      "packFormat": "f64"
    },
    {
      "kind": "command",
      "name": "send_value",
      "identifier": 130,
      "description": "Sends a double precision number and a name payload as a radio message",
      "fields": [
        {
          "name": "value",
          "isFloat": true,
          "type": "f64",
          "storage": 8
        },
        {
          "name": "name",
          "type": "string",
          "storage": 0
        }
      ],
      "unique": true,
      "packFormat": "f64 s"
    },
    {
      "kind": "command",
      "name": "send_buffer",
      "identifier": 131,
      "description": "Sends a payload of bytes as a radio message",
      "fields": [
        {
          "name": "data",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "unique": true,
      "packFormat": "b"
    },
    {
      "kind": "report",
      "name": "string_received",
      "identifier": 144,
      "description": "Raised when a string packet is received",
      "fields": [
        {
          "name": "time",
          "unit": "ms",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "device_serial_number",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "rssi",
          "unit": "dB",
          "type": "i8",
          "storage": -1,
          "isSimpleType": true
        },
        {
          "name": "padding",
          "type": "u8[1]",
          "storage": 1
        },
        {
          "name": "message",
          "type": "string",
          "storage": 0
        }
      ],
      "packFormat": "u32 u32 i8 b[1] s"
    },
    {
      "kind": "report",
      "name": "number_received",
      "identifier": 145,
      "description": "Raised when a number packet is received",
      "fields": [
        {
          "name": "time",
          "unit": "ms",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "device_serial_number",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "rssi",
          "unit": "dB",
          "type": "i8",
          "storage": -1,
          "isSimpleType": true
        },
        {
          "name": "padding",
          "type": "u8[3]",
          "storage": 3
        },
        {
          "name": "value",
          "isFloat": true,
          "type": "f64",
          "storage": 8
        },
        {
          "name": "name",
          "type": "string",
          "storage": 0
        }
      ],
      "packed": true,
      "packFormat": "u32 u32 i8 b[3] f64 s"
    },
    {
      "kind": "report",
      "name": "buffer_received",
      "identifier": 146,
      "description": "Raised when a buffer packet is received",
      "fields": [
        {
          "name": "time",
          "unit": "ms",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "device_serial_number",
          "type": "u32",
          "storage": 4,
          "isSimpleType": true
        },
        {
          "name": "rssi",
          "unit": "dB",
          "type": "i8",
          "storage": -1,
          "isSimpleType": true
        },
        {
          "name": "padding",
          "type": "u8[1]",
          "storage": 1
        },
        {
          "name": "data",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "packFormat": "u32 u32 i8 b[1] b"
    }
  ],
  "tags": []
}