Reputation: 11
I am trying to listen to the MQTT commands topic. I am publishing messages to the MQTT commands topic through the Google IoT Core function sendCommandToDevice. Is there a way to use a Google cloud function to listen to the MQTT commands topic?
Here is the link to the documentation for the sendCommandToDevice function https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries.devices/sendCommandToDevice
Upvotes: 1
Views: 1071
Reputation: 12053
You can trigger a Cloud Function from a message published to the IoT Core MQTT bridge.
Cloud Functions can be triggered via Google Cloud Pub/Sub Triggers. The IoT Core MQTT bridge actually forwards messages to Cloud Pub/Sub. By default, it forwards messages to the default telemetry topic specified when creating a device registry. Note: it is possible to configure multiple topics as well.
Putting this together, when you create a Cloud Function, you will then configure a the Cloud Pub/Sub trigger using the Pub/Sub topic associated with your device registry as described above.
Upvotes: 1