First, you need to create a model of the device.
A model is a representation of an object in the platform. It is most convenient to use the basic MQTT model, and then expand it to suit your needs.
Then you can move on to creating an object.
When creating an object identifier, you need to remember that the system will recognize the object using it in the future, so the identifier must correspond to the ClientId MQTT of the device client.
This identifier can be changed at any time if necessary.
ДThe MQTT protocol uses the following fields for message transfer: topic (message subject) and payload (message payload). RIC platform imposes no additional restrictions on these fields beyond the protocol specification restrictions. All the functionality related to message subscriptions (for example, wildcard topic) also works.
To receive and process data, you need to configure the device model. The list of parameters must be expanded in accordance with the data that will be sent to the MQTT broker.
Read more about the purpose of the model fields in the section Model of the object of control.
Parameters can be of various types, among which there are simple types (number, string, boolean), arrays, object.
The Object type allows you to conveniently handle the payload received in JSON format.
To do this, you need to create a parameter with this data type. For this parameter, in the Source field, you must specify the topic of the message.
To write values from JSON, you need to create parameters in which the Source field is formed according to the following principle:
<id of the object parameter>
.<value key from json>
, where
<id of the object parameter>
– ID of the object parameter, with the Object type,
<value key from json>
- a key to get a value from JSON data
For example, to parse data with topic “room1 / data” and with payload {"temperature": 27, "name": "room1"}
, you need to create the following parameters in the model.
Field name | Identifier | Type | Sourse |
---|---|---|---|
Data | data | Object | room1/data |
Temperature | temperature | Number | data.temperature |
Room | room-name | Line | data.name |
The basic MQTT model has an example of such a parameter – the Position block (JSON). Device coordinates can be passed in this message in JSON.
For details, see the example of MQTT device connections.
The interface of an object is associated with its model.
In the object log, you can see the current state of the parameters specified in the model, view the package history, statistics and command history.
In addition, in the log you can see the graph of changes in parameter values.
For Secure MQTT, an x.509 certificate for TLS connection can be generated in the object interface. To exclude the possibility of spoofing, you can specify a username and password for the MQTT client.
You can also send a message to a specific device from the “Commands” tab. The fields “Topic” and “Payload” indicate the corresponding message parameters. In addition, in the “Reply_topic” field, you can specify a topic, the message on which the system considers as a successful response to the command.
In the device model, in addition to parameters, you can create templates for MQTT messages that will be sent to the device when they are called from the interface.
RIC allows you to develop and test your solutions without connecting real devices. To do this, you can use the built-in Bots tool. It helps to quickly and conveniently emulate the operation of the device, send data to the system directly from the object interface. Using “Bots” saves time when testing devices and ensuring their interaction with other entities of the platform.
You can enable this option for an object using the switch in the “Use as a bot” field. At the same time, the object has corresponding tools in the interface. You can read more about this in the documentation.
You can use the Logic tool to define the logic of object behavior. In the platform interface, you can create various scripts that will allow you to monitor the state of the object and perform any actions, for example, organize the sending of commands. It all depends on your ideas and needs!
Post-processing of the received data can be created using the Handlers tool. This allows you to process the data received from the device, filter out incorrect information, and much more. For example, it is convenient if you need to apply some formula to several received parameters to get the resulting value or parse binary data. A handler is a source code written in the JavaScript ES6 programming language that implements its underlying algorithm.
The platform has a number of built-in tools that allow you to work with the geographic coordinates of an object. For this, the model must have the parameters Latitude (parameter identifier lat) and Longitude (identifier parameter lon). The presence of these parameters will allow you to track the position of the object and use the tool for constructing tracks of its movement.
Retain flag is not supported.
The CleanSession flag is not supported.
Message expiration is not supported.
Complicated work with unicode. The interface has no tools for processing and displaying such data. We are working on this problem.
Working with subscription identifiers is not fully implemented.
Extended authorization is not supported (SCRAM-SHA-1, GS2-KRB5, etc.). Now an error is being generated in connack.