The geo extension.
NervesHub asks with geo:location:request and the device answers with
geo:location:update. There is no GPS here, so the answer comes from a
GeoIP lookup against the Nerves project's whenwhere service — the same
source nerves_hub_link uses by default, and about as accurate as an IP
address ever is.
#{source => <<"geoip">>, latitude => -36.8869, longitude => 174.769}
A failed lookup is reported rather than swallowed, as
#{error_code, error_description}, because a device that answers nothing
and a device that cannot resolve look identical from the platform.
resolve/0 makes a network request and blocks until it finishes, so it must
not run on the agent's process — that process has heartbeats to send. The
agent spawns start_resolve/1, which sends the result back.
| default_url/0 | |
| event/0 | The scoped event a location is sent as. |
| parse_response/1 | Turn a whenwhere response body into the payload NervesHub stores. |
| resolve/0 | Equivalent to resolve(default_url()).
|
| resolve/1 | Ask a whenwhere-shaped service where this device is. |
| start_resolve/1 | Resolve in a separate process, sending {nh_ext_geo, Pid, Location}. |
default_url() -> binary()
event() -> binary()
The scoped event a location is sent as.
parse_response(Body::binary()) -> map()
Turn a whenwhere response body into the payload NervesHub stores.
Coordinates come back as strings and are sent as numbers where they parse: the platform draws them on a map, and a string is not a coordinate. One that will not parse is passed through rather than dropped, so a change at the service shows up as odd data instead of no data.resolve() -> map()
Equivalent to resolve(default_url()).
resolve(Url::binary()) -> map()
Ask a whenwhere-shaped service where this device is.
start_resolve(Owner::pid()) -> pid()
Resolve in a separate process, sending {nh_ext_geo, Pid, Location}.
Generated by EDoc