This page explains how gateways can use the MQTT bridge to communicate with ClearBlade IoT Core and publish telemetry events on behalf of bound devices. Before you begin, read Using the MQTT bridge for information on using the MQTT bridge with ClearBlade IoT Core.
Try an end-to-end demo.
Using gateways with the MQTT bridge
1. After you've created and configured the gateway, connect it to ClearBlade IoT Core over the MQTT bridge.
2. Create devices if you haven't already.
3. Optional: Bind the devices to the gateway.
...
When using the MQTT bridge, you only need to bind the devices if they can't generate their JWTs.
4. Optional: Subscribe to the system error topic to get feedback on whether device operations are successful.
5. Attach the devices to the gateway.
6. Use the gateway to relay telemetry, device state, and configuration messages on its devices' behalf.
Gateway messages
After the gateway connects to ClearBlade IoT Core over the MQTT bridge, it can send or receive three message types:
...
To enable the gateway to proxy device communications with ClearBlade IoT Core, have the gateway publish a QoS 1 /devices/{device_ID_to_attach}/attach
control message over the MQTT bridge.
If you configured the gateway to authenticate devices using the devices' JWTs, the attached message’s payload must include the token in JSON format: { "authorization" : "{JWT_token}" }
. Otherwise, ClearBlade IoT Core authenticates the device by checking its gateway’s association.
...
To be notified when a device encounters an error, subscribe the gateway to the MQTT /devices/{gateway_ID}/errors
topic using QoS level 0.
These code samples illustrate how to subscribe the gateway to the MQTT/devices/{gateway_ID}/errors topic using QoS level 0:
...