Control Unit Metadata is the way the Control Unit's interface is presented to the RM and is mandatory in order to work in any way with a Control Unit (device or component).

The MQTT Device Adapter Package provides several methods for sending Metadata to the RM – via a REST call by sending a message via MQTT (this method is used primarily for sending components' Metadata, because it requires an established connection between a device and the RM, i.e. the device must have already provided its Metadata by another method) and by providing the Metadata in the initial configuration folder.

The concept of "Metadata" is also related to Control Units' icons so this section also contains instructions on how to provide icons for a specific Control Unit or its actions to the RM.+

REST

Metadata

Request URL: http://<rm ip>:<rm port>/rspi/mqtt/{deviceType}/metadata/{cuType}/{version}?isAbstract={boolean}&isDeviceType={boolean}

Request method: POST

Request headers:

  • "Accept: application/json"

  • "Content-Type: application/xml"

  • "Authorization: Basic <credentials>"

Request payload: <metadata xml content>

Icon

Request URL: http://<rm ip>:<rm port>/rspi/mqtt/{deviceType}/{deviceId}/metadata/{cuType}/{version}/icons/{ocdId}/{size}

Request method: POST

Request headers:

  • "Accept: application/json"

  • "Content-Type: application/octet-stream"

  • "Authorization: Basic <credentials>"

Request payload: <icon as byte[]>

  • {ocdId} stands for "object class definition id" – for detailed explanation see the Control Unit Metatyping page.

  • {size} is the size of the icon in pixels


MQTT

Metadata

Request

Topic
backend/<device-type>/<device-id>/metadata/<cu-type>/<cu-version>
Payload
{
  "token" : <string>,
  "requestId" : <string>,
  "needAck" : <boolean>,
  "metadata" : <string>,
  "isAbstract" : <boolean>,
  "isDeviceType" : <boolean>
}
  • "token" - this field is mandatory and is part of the security concept for the messaging protocol. For more information check the Security section in the MQTT Device Management Model page.

  • "requestId" and "needAck" - these fields are required if:

    • message delivery acknowledgment is required;

    • confirmation of successful request is required (success is defined as an absence of error);

    • data is expected as a result of the request;

      Note that if the fields are omitted no response of any kind will be sent by the backend and if an error has occurred the device won't be notified of it.
  • "metadata" - this field is mandatory and must contain the Metadata xml

  • "isAbstract" - this field is mandatory and must be set to true if the Control Unit type is abstract

  • "isDeviceType" - this field is mandatory and must be set to true if the Control Unit is a device


Response

Topic
device/<device-type>/<device-id>/<token>/metadata/<cu-type>/<cu-version>
Payload
{
  "requestId" : <string>,
  "error" : <string>
}
  • "requestId" - this field will be included only if it was present in the request message and its value will match the value sent with the request.

  • "error" - this field will be included only if an error occurred during the fulfilling of the request. Note that if the field is present, the payload will not contain any other fields, except for "requestId".


Icon

Request

Topic
backend/<device-type>/<device-id>/icon/<cu-type>/<cu-version>/<ocd-id>/<size>
  • <ocd Id> stands for "object class definition id" – for detailed explanation see the Control Unit Metatyping page.

  • <size> is the size of the icon in pixels

Payload
{
  "token" : <string>,
  "requestId" : <string>,
  "needAck" : <boolean>,
  "icon" : <byte[]>
}
  • "token" – this field is mandatory and is part of the security concept for the messaging protocol. For more information check the Security section in the MQTT Device Management Model page.

  • "requestId" and "needAck" – these fields are required if:

    • message delivery acknowledgment is required;

    • confirmation of successful request is required (success is defined as an absence of error);

    • data is expected as a result of the request;

      Note that if the fields are omitted no response of any kind will be sent by the backend and if an error has occurred the device won't be notified of it.
  • icon - this field is mandatory and must contain image file bytes

Response

Topic
device/<device-type>/<device-id>/<token>/icon/<cu-type>/<cu-version>/<ocd-id>/<size>
Payload
{
  "requestId" : <string>,
  "error" : <string>
}
  • "requestId" – this field will be included only if it was present in the request message and its value will match the value sent with the request.

  • "error" – this field will be included only if an error occurred during the fulfilling of the request. Note that if the field is present, the payload will not contain any other fields, except for "requestId".


Initial Configuration

This method for providing Metadata is only available for on-premise deployment.

In order to load required Metadata on RM startup, the following steps must to be completed:

  • First, a configuration xml, containing information about the actual Control Unit Metadata, should be created and placed in the initial_config/mqttcu folder.

Examples

<cu-type>
  <id>bosch.iot.rm.mqtt.generic</id>
  <version>1.0.0</version>
  <metadata-location>mqttdm/cu-mtp</metadata-location>
  <metadata-xml>bosch.iot.rm.mqtt.generic1.0.0.xml</metadata-xml>
  <abstract>true</abstract>
</cu-type>
 
<cu-type>
    <id>weather.station</id>
    <version>1.0.0</version>
    <metadata-location>mqttdm/cu-mtp</metadata-location>
    <metadata-xml>weather.station1.0.0.xml</metadata-xml>
</cu-type>
 
<cu-type>
    <id>thermometer</id>
    <version>1.0.0</version>
    <metadata-location>mqttdm/cu-mtp</metadata-location>
    <metadata-xml>thermometer1.0.0.xml</metadata-xml>
    <component>true</component>
    <device-types>weather.station</device-types> // can contain many types, comma-separated
</cu-type>


The XML schema definition file is located in the initial_config/mqttcu folder.
  • Second, the Control Unit Metadata xml must be placed in the folder, defined in the <metadata-location> element (usually initial_config/mqttcu/mqttdm/cu-mtp).

Example for Metadata

Generic REST call -/rspi/mqtt/{deviceType}/metadata/{cuType}/{version}?isAbstract={boolean}&isDeviceType={boolean}

The {cuType} field should be the same as the <id> field in the Metadata.

Example REST call for the Metadata below:

Since we are importing Metadata for a device the {deviceType} and {cuType} fields should be the same and the isDeviceType should be true.

Rest URL: <Remote Manager URL>:4433
Rest method: POST
Rest Headers:
  'Authorization: <Authorization Key>'
    'Accept: application/json'
    'Content-Type: application/xml'
 
/rspi/mqtt/weather.station/metadata/weather.station/1.0.0?isAbstract=false&isDeviceType=true

Metadata:


<metatype-provider>
  <objectclass>
    <locale>en</locale>
    <name>Weather Station</name>
    <id>weather.station</id>
    <description />
    <attribute modifier="req">
      <name>Super Type</name>
      <id>super</id>
      <description>Super Type</description>
      <type>&string;</type>
      <cardinality>1</cardinality>
      <value>
        <array>
          <scalar>bosch.iot.rm.mqtt.generic</scalar>
        </array>
      </value>
    </attribute>
    <attribute modifier="req">
      <name>Device Display Name</name>
      <id>name</id>
      <description />
      <type>&string;</type>
      <cardinality>0</cardinality>
      <value>
        <scalar>Weather Station</scalar>
      </value>
    </attribute>
    <attribute modifier="req">
      <name>On</name>
      <id>on</id>
      <description />
      <type>&boolean;</type>
      <cardinality>0</cardinality>
      <value>
        <scalar>false</scalar>
      </value>
    </attribute>
    <objectclass>
      <locale>en</locale>
      <name>Create Weather Station</name>
      <id>$create.</id>
      <description />
      <attribute modifier="in">
        <name>Device ID</name>
        <id>mbs.control.id</id>
        <description />
        <type>&string;</type>
        <cardinality>0</cardinality>
      </attribute>
    </objectclass>
    <objectclass>
      <locale>en</locale>
      <name>Delete Weather Station</name>
      <id>$destroy</id>
      <description />
    </objectclass>
    <objectclass>
      <locale>en</locale>
      <name>Turn On</name>
      <id>turn.on</id>
      <description />
    </objectclass>
    <objectclass>
      <locale>en</locale>
      <name>Turn Off</name>
      <id>turn.off</id>
      <description />
    </objectclass>
  </objectclass>
</metatype-provider>