Google Cloud Integration - Receiving Events


#1

I know that the particle cloud/console has the google cloud pub/sub integration. I set this up accordingly, and it worked great for sending data, publishing it to a topic.

However, the provided code to receive events sent to the topic doesn’t seem to work, and all the info I find online is about sending data, not receiving.

Is there something more that needs to happen? Do I need to create a subscription with a certain naming convention? To be clear, the integration documentation shows that this code should work (i think):

          

void setup() {
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/<topicname>", myHandler, MY_DEVICES);
}

void myHandler(const char *event, const char *data) {
  // Handle the integration response
}
          

Any and all help and advice is appreciated!


#2

Do you see the response in console at all?


#3

You can’t receive events sent to a topic using the Google cloud pubsub integration. It’s one way from the Particle device to Google Cloud.

That bit of code gets the result from publishing an event from a device. It essentially is the result code from a publish that triggers a Google cloud pubsub integration, not the actual pubsub topic.

You could use a Google Cloud function to subscribe to a pubsub message and then generate a Particle.publish using the particle-api-js.


#4

That makes a ton of sense! Thanks!