MQTT
简介
本节 describes integration with the Gear Studio platform using MQTT. This functionality is designed to allow integration with devices from a variety of manufacturers, as well as custom-built devices with Arduino, nodeMCU, Raspberry Pi, and any other platform that supports MQTT communication with TLS security.
Integration Alternatives
T此处 are two MQTT integration alternatives:
- Flexible data exchange (recommended): Flexible data exchange allows receiving data from devices (uplink) as well as sending data to devices (downlink). It is extremely flexible and can be easily implemented.
- HTTP 桥接 (for device migration): The HTTP bridge allows migrating devices that use the HTTP interface so they use MQTT instead.
重要说明: The HTTP bridge is primarily designed for migrating devices from HTTP to MQTT, but for new devices, it is recommended to use flexible data exchange, which can be found 此处. Flexible data exchange allows representing data with much more flexibility, and generally in a more compact form.
Authentication and 安全
Each Gear Studio instance has its own dedicated MQTT server, usually set up for secure TLS connections on port 8883. The MQTT server connection requires:
- 用户name and password, which can be managed through the "MQTT 配置" option within the "安全" section of the Gear Manager application. The user ID is also used as a suffix for all MQTT topics.
- TLS certificate, used so the device can verify it is connected to the correct server.
Using a Client ID
Some MQTT clients require defining a "Client ID" before connecting, while others allow using a random one. If you need to explicitly define a Client ID, we recommend using a string that contains the username followed by a unique suffix. For example, you can follow a naming convention like this:
{client-secure-id}{generic-value}
E.g.: 16SAD5656S01
W此处:
- 16SAD5656S is the username used in the connection, and
- 01 is the "generic value", which should be different for each connection.
设备集成
简介 本节 explains how to integrate devices into the Gear Studio platform, that is: How to get devices to send data to the platform...
灵活数据交换
简介 Flexible data exchange is the recommended MQTT integration method on the Gear Studio platform. All MQTT devices natively supported by the platform use flexible data exchange, but this method is also recommended for non-natively supported device models.