{
  "name": "Settings",
  "status": "experimental",
  "shortId": "settings",
  "camelName": "settings",
  "shortName": "settings",
  "extends": [
    "_base"
  ],
  "notes": {
    "short": "Non-volatile key-value storage interface for storing settings.",
    "long": "## Secrets\n\nEntries with keys starting with `$` are considered secret.\nThey can be written normally, but they read as a single `0` byte,\nunless they are empty, in which case the value returned is also empty.\nThese are typically used by other services on the same device."
  },
  "classIdentifier": 285727818,
  "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": "command",
      "name": "get",
      "identifier": 128,
      "description": "Get the value of given setting. If no such entry exists, the value returned is empty.",
      "fields": [
        {
          "name": "key",
          "type": "string",
          "storage": 0
        }
      ],
      "hasReport": true,
      "packFormat": "s"
    },
    {
      "kind": "report",
      "name": "get",
      "identifier": 128,
      "description": "Get the value of given setting. If no such entry exists, the value returned is empty.",
      "fields": [
        {
          "name": "key",
          "type": "string0",
          "storage": 0
        },
        {
          "name": "value",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "secondary": true,
      "packFormat": "z b"
    },
    {
      "kind": "command",
      "name": "set",
      "identifier": 129,
      "description": "Set the value of a given setting.",
      "fields": [
        {
          "name": "key",
          "type": "string0",
          "storage": 0
        },
        {
          "name": "value",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "restricted": true,
      "packFormat": "z b"
    },
    {
      "kind": "command",
      "name": "delete",
      "identifier": 132,
      "description": "Delete a given setting.",
      "fields": [
        {
          "name": "key",
          "type": "string",
          "storage": 0
        }
      ],
      "restricted": true,
      "packFormat": "s"
    },
    {
      "kind": "command",
      "name": "list_keys",
      "identifier": 130,
      "description": "Return keys of all settings.",
      "fields": [
        {
          "name": "results",
          "type": "pipe",
          "storage": 12
        }
      ],
      "pipeType": "list_keys",
      "packFormat": "b[12]"
    },
    {
      "kind": "pipe_report",
      "name": "listed_key",
      "identifier": 0,
      "description": "Return keys of all settings.",
      "fields": [
        {
          "name": "key",
          "type": "string",
          "storage": 0
        }
      ],
      "pipeType": "list_keys",
      "packFormat": "s"
    },
    {
      "kind": "command",
      "name": "list",
      "identifier": 131,
      "description": "Return keys and values of all settings.",
      "fields": [
        {
          "name": "results",
          "type": "pipe",
          "storage": 12
        }
      ],
      "pipeType": "list",
      "packFormat": "b[12]"
    },
    {
      "kind": "pipe_report",
      "name": "listed_entry",
      "identifier": 0,
      "description": "Return keys and values of all settings.",
      "fields": [
        {
          "name": "key",
          "type": "string0",
          "storage": 0
        },
        {
          "name": "value",
          "type": "bytes",
          "storage": 0,
          "isSimpleType": true
        }
      ],
      "pipeType": "list",
      "packFormat": "z b"
    },
    {
      "kind": "command",
      "name": "clear",
      "identifier": 133,
      "description": "Clears all keys.",
      "fields": [],
      "restricted": true
    },
    {
      "kind": "event",
      "name": "change",
      "identifier": 3,
      "description": "Notifies that some setting have been modified.",
      "fields": [],
      "identifierName": "change"
    }
  ],
  "tags": []
}