The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Gateway Device Access Guide

Last updated: 2026-05-09 16:49:43

this document introduces How to develop gateway access to Tencent IoT Explorer based on IoT Explorer C SDK.

C SDK Gateway Features

Gateway and Sub-Device Information Management

The device information management APIs of the HAL layer for gateways and subdevices have differences from those for directly connected devices. Call HAL_GetGwDevInfo to obtain the device information of gateways and subdevices. This API needs to be adapted and implemented. That is, developers need to manage device information according to the target platform and use cases, especially the device information mapping of real subdevices and platform subdevices.

Gateway and Cloud Connection

Gateway Example gateway_sample.c introduces how to use the APIs provided by the C SDK to implement device information acquisition, gateway-cloud connection, proxy sub-device online and offline, proxy sub-device communication, and shows how sub-devices communicate based on data templates.

Proxy Sub-Device Online/Offline

After the gateway is online, perform sub-device management via specific protocols (for example: BLE, Zigbee).
For subdevices that have already established communication, call IOT_Gateway_Subdev_Online to implement the online operation of subdevices in the cloud. For details, see Online Data Request Format.
For a sub-device that has lost communication, call IOT_Gateway_Subdev_Offline to implement the decommissioning of the sub-device in the cloud. For details, see Request Format for Decommissioning Data.

Dynamic Binding and Unbinding Sub-Devices

The gateway can proxy the online and offline status and communication of subdevices, provided that the gateway device and subdevices have established a topological association relationship on the platform.
Product-level correlation, that is, the correlation between the product of the subdevice and the gateway product must be established in the console.
Device-level correlation can be established on the console and can be dynamically bound and unbound. For dynamic binding and unbinding, the gateway needs the subdevice key to implement signature. If the signature is calculated on the gateway side, the gateway needs the key corresponding to the subdevice to be bound. Dynamic Binding and Unbinding Data Request Format.

Proxy Sub-Device Communication

Upon success of the proxy sub-device online, you can call IOT_Gateway_Subscribe for the subscription messages of the proxy sub-device, and call IOT_Gateway_Publish to push messages to the cloud.

Gateway Example

Gateway Example gateway_sample.c introduces how to use the APIs provided by the C SDK to implement device information acquisition, gateway-cloud connection, proxy sub-device online and offline, proxy sub-device communication, and shows how sub-devices communicate based on data templates.

Gateway Development Implementation

The typical development process of gateway products is as follows:
dev_flow


The three steps within the dotted line are implemented by the gateway manufacturer. It is usually recommended as follows:
For gateway devices connected to the internet via Wi-Fi, it is necessary to refer to Wi-Fi Distribution Network Protocol and cooperate with Tencent Lianlian Mini Program to complete the configuration.
For the communication between the gateway and the subdevice, the platform has no restrictions and it is freely defined by the gateway manufacturer and the subdevice. However, for the gateway to implement device information management and legitimacy verification of the subdevice, it needs to map well with the subdevice associated with the cloud. Generally, the unique information (MAC/EUI) of the subdevice is used as the device name of the platform subdevice, and the gateway manages the mapping relationship during the inbound process of the subdevice.
The communication protocol between the gateway and IoT Explorer must be Data Template Protocol. Each product type and data template are different. The communication between the gateway and the subdevice is generally binary. Therefore, the gateway needs to implement two-way conversion from the binary data of the subdevice to the data of the Data Template Protocol based on different types of products. The general practice is to create two message queues: the message queue from the subdevice to the gateway stack_msg_queue and the message queue from the cloud to the gateway cloud_msg_queue. Independently retrieve messages from the message queues in an independent thread, perform corresponding conversions, and then distribute and push the messages.
For Bluetooth scenarios, Tencent has defined LianLian LLSync Protocol. For gateways integrated with Tencent IoT Platform, it is recommend using LianLian LLSync Protocol as the communication protocol between the gateway and sub-devices.