2

I am trying Google IOT and Google PubSub. I am sending MQTT messages from device to a pubsub queue on which I have subribed (with something I will call "the server"). From the google cloud console, I update device setting and I get the setting message in device.

Everything in google tutorial work fine but I wonder if it is possible to set up a messaging it the other way : i.e. "the server" sending message to a pubsub queue subscribed by the device using MQTT.

The schema at the end of this page make me think that only the "config" mqtt queue (/devices/XXXX/config) can be used that way.

What I need is a 1to1 communication from "the server" to "the device" and I'm afraid that the only way is using the config

Nicolas N
  • 21
  • 2

2 Answers2

2

I am not an expert on Google IoT, but few days ago I got the same doubts about it. Apparently, although we can publish to /events, /config and /state topics, using MQTT protocol, only topic /config and, maybe, /state can work through subscriptions with the same protocol.

The conclusion I got, after reading many times the documentation, that is not so clear, and asking some questions here at stackoverflow is: you can not use MQTT to subscribe to any topic in order to receive those data sent to /events topic.

To accomplish this, you have to create a Pub/Sub topic associating it to your device:

  1. On Google Cloud IoT Core Console, click on your registry ID;
  2. Create a standard telemetry topic;
  3. After topic created, click on the topic to see its details;
  4. Its details will open on Google Cloud Pub/Sub panel;
  5. In this panel, you can create a subscription to the created topic, by clicking on the "create subscription button".

Now that you have a "google cloud pub/sub topic" linked to "google cloud iot core /events telemetry MQTT topic" and a respective subscription, you can use the google pub/sub library to receive notifications through created subscription when data are sent to /events topic.

Maybe the following link can also help: https://cloud.google.com/iot/docs/how-tos/devices#creating_a_device_registry_with_multiple_pubsub_topics

I hope this can help you. If I made any mistake in my answer, may someone edit it with some improvement or correction.

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
0

Today I got same issues. Seems you cannot get data by subscribe with MQTT. You need to create a pub/sub topic in Goolge iot pub.sub