particle-iot/google-maps-device-locator

Name: google-maps-device-locator

Owner: Particle

Description: null

Created: 2017-04-18 12:46:57.0

Updated: 2018-03-06 07:57:26.0

Pushed: 2018-01-03 18:28:56.0

Homepage: null

Size: 10

Language: C++

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Google Maps Device Locator

Library for using the Google Maps Device Locator Integration

This library work with the Google Maps Device Locator Integration to find a location based on Wi-Fi or cellular tower information via the Google Geolocation API.

Firmware Library API
Creating an object

You normally create an locator object as a global variable in your program:

leMapsDeviceLocator locator;
Operating modes

There are three modes of operation:

If you want to only publish the location once when the device starts up, use withLocateOnce from your setup function.

tor.withLocateOnce();

To publish every n seconds while connected to the cloud, use withLocatePeriodic. The value is in seconds.

tor.withLocatePeriodic(120);

To manually connect, specify neither option and call publishLocation when you want to publish the location

tor.publishLocation();
The loop

With periodic and locate once modes, you must call

tor.loop();

from your loop. It doesn't hurt to always call it, even in manual location mode. It gives the library time to process the data.

Customizing the event name

The default event name is deviceLocator. You can change that in setup using:

tor.withEventName("myEventName");

This also must be updated in the integration, since the eventName is what triggers the webhook.

Subscription

You can also have the library tell your firmware code what location was found. Use the withSubscribe option with a callback function.

This goes in setup() for example:

tor.withSubscribe(locationCallback).withLocatePeriodic(120);

The callback function looks like this:

 locationCallback(float lat, float lon, float accuracy)

One possibility is that you could display this information on a small OLED display, for example.

Debugging

The library uses the logging feature of system firmware 0.6.0 or later when building for 0.6.0 or later. Adding this line to the top of your .ino file will enable debugging messages to the serial port.

alLogHandler logHandler;

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.