Requirements
nerves_hub_link2.6.0 or later.- NervesHub 2.3.0 or later.
- To draw the location on a map, the instance needs a Mapbox access token. Without one, the device page has no Location card. See Feature prerequisites.
Enable it
1
Keep Geo in your firmware
NervesHubLink.Extensions.Geo is in the default extension_modules list. If you set extension_modules yourself, that list replaces the default, so name Geo in it:2
Turn it on for the product
In Product settings, on the General tab, switch on Geo in the Device extensions card. A product created in the web UI starts with every extension on. A product created through the API or
nh starts with every extension off.3
Check the device setting
On the device’s Settings tab, Geo in the Extensions card is on by default.
Check that it works
Reconnect the device if it was connected before you turned Geo on. Open the device’s Details tab and look at the Location card. It shows the map and where the location came from, for example Approximate, from GeoIP. If the resolver returned an error, the card shows the error code and description in place of the map.The default resolver
NervesHubLink.Extensions.Geo.DefaultResolver asks the Nerves project’s whenwhere service for a rough location based on the device’s public IP address. It reports the result with source: "geoip".
The Nerves team provides no availability guarantee for that service.
Use your own resolver
Implement theNervesHubLink.Extensions.Geo.Resolver behaviour. It has one callback, resolve_location/0:
latitude, longitude and source, and optionally accuracy. NervesHub labels the sources geoip, gps and manual. Any other source is shown as From followed by the source name.
Return errors as
{:error, code, description}. That is the shape the extension in nerves_hub_link 2.14.0 matches on and the shape the default resolver returns.When the location is sent
NervesHub asks for the location once, each time the extension attaches. That is the default: the repeat interval is an instance setting (FEATURES_GEO_INTERVAL_MINUTES) and is 0, which means no repeat.

