Topics Overview (MQTT and Google PubSub)

As MQTT clients, devices can publish to a limited set of MQTT topic patterns:

  • /devices/{deviceID}/state

  • /devices/{deviceID}/events/#

  • /devices/+/attach (for special devices called gateways only)

  • /devices/+/detach (for special devices called gateways only)

Devices cannot subscribe to any of the above topic patterns.

Devices can subscribe to a limited set of MQTT topic patterns:

  • /devices/{deviceID}/config

  • /devices/{deviceID}/commands/#

  • /devices/{deviceID}/errors

Devices cannot publish to any of the above topic patterns.

As MQTT clients, devices that wish to send data to ClearBlade IoT Core would publish either to /devices/{deviceID}/events/# or /devices/{deviceID}/state. In order for that data to be forwarded beyond ClearBlade IoT Core (e.g. to trigger Google Cloud Functions), the MQTT topics must be mapped to a different, non-MQTT messaging service called Google PubSub.

The following screenshot shows a registry where Google PubSub topics (not to be confused with MQTT topics) are configured:

image-20241106-175529.png

What this shows us is…

  • If a device in this registry publishes messages to MQTT topic /devices/{deviceID}/events/mySubFolder then the data gets forwarded to Google PubSub topic projects/api-project-320446546234/topics/sub

  • If a device in this registry publishes messages to MQTT topic /devices/{deviceID}/events or /devices/{deviceID}/events/{anything_other_than_the_explicitly_mapped_subfolder} then the data gets forwarded to Google PubSub topic projects/api-project-320446546234/topics/rootevent

  • If a device in this registry publishes messages to MQTT topic /devices/{deviceID}/state then the data gets forwarded to projects/api-project-320446546234/topics/state


Learn about Google PubSub here.
Learn about Google Cloud Run Functions here.


Note: if devices need to communicate via HTTP instead of MQTT, they should use these APIs.