Google Maps Geolocation not responding with webhook

Hi,

We integrated Google Maps into our product…

  • we have the Google API setup
  • added to Particle Console
  • added firmware library to our devices
  • devices send location data (wifi, cell base stations)
  • google receives and replies with HTTP 200 OK, including long-lat-acc data

but… neither the ‘hook-sent/deviceLocator’ nor ‘hook-’ response come back to the Particle Console, as described in the documentation

Can anyone help? I’m ultimately trying to get locator.withSubscribe(locationCallback) working so I can have longitude-latitude in my local Photon.

Thank you!

Are you monitoring the Events log for your device, or the top-level Events log for your account?

The hook- events only appear in the top-level one, not the one under your device, because they’re not technically coming from the device.

I updated the documentation to reflect that, as the device-specific Events log didn’t previously exist.

I am looking at top-level Events… no hook- response

I also created a new Google Maps API and set up a new Integration with different name, still nothing.

I just retested it in my account with both an old Google Maps integration and a newly created one and it’s working for me. Could you DM me your Particle account email address or have Javier submit it in the support request you have open and I’ll take a look at your integration from the server side and see if anything looks abnormal.

I think I figured out what’s happening. Your Google Maps integration is at the product level. This makes things a little confusing because the hook-sent and hook-response events don’t appear in the product event log, because they’re not technically product events. In other words, when you go into your product then select Events, they won’t show up there.

If you’ve claimed the device to a developer account, you can see the hook-response events in the owner’s Events tab at the top level (not in the product).

However, the events really are there, even if you can’t see them.

One thing I noticed, however, is that if you use a custom event name, you must subscribe after you set the event name. The order is important, otherwise it subscribes to the default event name instead of your custom event name and it won’t work.

#include "Particle.h"
#include "google-maps-device-locator.h"

void locationCallback(float lat, float lon, float accuracy);

SerialLogHandler logHandler;
GoogleMapsDeviceLocator locator;

SYSTEM_THREAD(ENABLED);


void setup() {
        Serial.begin(9600);
        locator.withLocatePeriodic(120).withEventName("3deviceLocator").withSubscribe(locationCallback);
}


void loop() {
        locator.loop();
}

void locationCallback(float lat, float lon, float accuracy) {
        Serial.printlnf("lat=%f lon=%f accuracy=%f", lat, lon, accuracy);
}

I tested this with an Electron added to an Electron product and it appeared to work properly in my account with the integration in a product. Also not in a product, earlier.

2 Likes

Hi Rick,

Thank you for the explanation, that makes some more sense now. I DO see the hook-response now in my top-top level Events (not Products).

However, I still can’t seem to get the response back to my Photon. I am using the code you provided, just changing the event name.

hook-response/GeoLocate/320030------------/0 is in the console, but nothing on the Photon side:

The Photon is under the Product… but unowned and marked as development, don’t know if that makes a difference.

It looks like the Photon is not receiving .withSubscribe(locationCallback) Any suggestions? Thanks again :smiley:

Update: I found that when the device has an ‘owner’, the Photon receives the hook-response! So that’s solved!!

And got the withSubscribe() function with publishLocation() for one-time location readings :slight_smile:

Thanks Rick!!

1 Like