The Message schema allows a device to control what properties are editable, and control the type of data stored to those properties. We support much of JSON Schema, but not all the options are available.

Octoblu provides some specific extensions to the standard JSON Schema. This guide will cover some of the Octoblu specific ideas, and will not be a general JSON Schema tutorial.

Multiple Message Schemas

This first thing you will notice is that Octoblu supports multiple message schemas.

{
  "schemas": {
    "message": {
      "first": { ... },
      "second": { ... },
      "third": { ... }
    }
  }
}

When the user views this message in Octoblu, they will be presented a choice between the schemas.

Grouping

Octoblu will allow you to group configurations together. For example, if a device offers different types of shells to the user, the schema author could group them by operating system.

{
  "schemas": {
    "message": {
      "powershell": {
        "x-group-name": "Windows"
      },
      "cmd.exe": {
        "x-group-name": "Windows"        
      },
      "bash": {
        "x-group-name": "UNIX-ish"
      }
    }
  }
}

Form Schema

x-form-schema is required in order to reference a Form schema. Octoblu will search the schemas.form object for a matching key and apply that form schema.

{
  "schemas": {
    "version": "2.0.0",
    "message": {
      "default": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "default": false
          }
        },
        "x-form-schema": {
          "angular": "message.default.angular"
        }
      }
    },
    "form": {
      "message": {
        "default": {
          "angular": [ ... ]
        }
      }
    }
  }
}

Default Message Schema

Any schema named default will be selected unless you override the schemas.selected.message property of your device and set it to the key of the message schema object.

{
  "name": "Device A",
  "schemas": {
    "message": {
      "not-the-default": { ... }
    },
    "selected": {
      "message": "not-the-default"
      }
  }
}

Reference an external schema

Octoblu supports the standard $ref capability of JSON Schema. Octoblu will resolve the reference and apply the schema to the device.

{
  "schemas": {
    "message": {
      "device-a": {
        "$ref": "https://data-forwarder-mongodb.octoblu.com/schemas/v1/message.json"
      }
    }
  }
}

Reference another device schema

Octoblu allows you to reference a schema on another device, provided the device is given proper permissions. You can reference any property of the device and it will be used as the configuration schema.

The URI follows this pattern: meshbludevice://uuid/#/path/to/property.

// Device A
{
  "name": "Device A",
  "meshblu": {
    "version": "2.0.0",
      "whitelists": {
      "discover": {
        "view": [
          { "uuid": "device-b" }
        ]
      } 
      }
  },
  "friendSchemas": {
      "deviceB": { ... }
  }
}

// Device B
{
  "name": "Device B",
  "schemas": {
    "message": {
      "device-a": {
        "$ref": "meshbludevice://device-a/#/friendSchemas/deviceB"
      }
    }
  }
}