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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
You normally create an locator object as a global variable in your program:
leMapsDeviceLocator locator;
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();
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.
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.
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.
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;