Connecting MQTT Devices
Overview
A device can access ROMA Connect by integrating with the MQTT.fx client. After a device is connected to ROMA Connect, it can report data to ROMA Connect. You can also use ROMA Connect to deliver control commands to the device.
ROMA Connect does not directly store data reported by devices. You must configure data forwarding rules to forward device data to other services for storage.
When MQTT devices are used, only QoS0 and QoS1 in MQTT are supported.
Prerequisites
Devices can communicate with a ROMA Connect instance over the public network. Ensure that the instance has been bound with an EIP.
Connecting a Device
A device can access ROMA Connect using the open-source Eclipse Paho MQTT client. You can also use the MQTT X client to debug device access.
- Obtain the MQTT client.
Obtain the Eclipse Paho MQTT client based on your programming language.
- Obtain device access information.
- Log in to the ROMA Connect console. On the Instances page, click View Console of an instance.
- In the navigation pane on the left, choose LINK > Device Management.
- Obtain device connection information.
- MQTT/MQTTS connection address: Obtain the access address of the device from the upper part of the Device Management page and then download the SSL certificate. If MQTT is used for access, obtain the MQTT connection address. If MQTTS is used for access, obtain the MQTTS connection address.
- Client ID/Username/Password: Locate the corresponding device on the Devices tab page and obtain the client ID, username, and password of the device.
- Obtain topic information of the device.
Click the device name to go to the device details page. On the Topics tab page, obtain the topic information about the messages reported (published) and received (subscribed) by the device.
After the device is created, the system generates five basic topics. For details about the topics, see Table 1. For details about how to use the topics, see MQTT Topic Specifications.
Table 1 Basic topic description Topic Name
Topic Class
Description
{Product ID}/out/{Device ID}
Publish
Used by devices to publish messages. Messages are processed based on the rule engine configuration.
{Product ID}/in/{Device ID}
Subscribe
Used by devices to subscribe to messages. Messages are processed based on the rule engine configuration.
/v1/devices/{Device ID}/datas
Publish
Used by devices to report messages complying with the MQTT-based communication protocol for IoT in power distribution. Messages are filtered based on the protocol and then processed based on the rule engine configuration. When the device shadow function is enabled, the data reported by this topic will be recorded in the shadow.
/v1/devices/{Device ID}/command
Subscribe
Used by devices to subscribe to commands delivered by the IoT platform. Commands delivered by the IoT platform are published to this topic by default.
/v1/devices/{Device ID}/commandResponse
Publish
Used by devices to publish responses. After a device receives a command from the IoT platform, it responds to the command through this topic.
- Integrate the device with the MQTT client.
Develop and integrate the device with Eclipse Paho MQTT client, and write the device access information during the integration. For details, see Configuring Device Integration.
- Connect the device to ROMA Connect.
After the integration development is complete, power on the device to take it online and connect it to ROMA Connect.
Debugging a Device
- Reporting data to ROMA Connect
By default, ROMA Connect has subscribed to topics of the publish type. After a device sends a message to such a topic, the topic can report data to ROMA Connect.
- Receiving commands from ROMA Connect
After ROMA Connect sends a control command to the command delivery topic, the topic delivers the command to the device for device control.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot