Feature request: device.getipaddress()

An agent clearly already knows the IP address of it’s related Imp.

However this information is not exposed via the API.

It would be nice to have e.g. device.getipaddress().

My particular use-case is as follows…

In order to make it easier to distinguish each new Imp as it comes online I’d like an initial automatic approximation of its location.

I could use a geolocation service but for this I need to know the Imp’s IP address or to be more accurate the address the agent has for the Imp (most Imps presumably connect to world via an access point using NAT and so themselves just see a private network address).

I know there are lots of issues with geolocation services but they’re better than nothing. At the moment I’m using Xively and there one can associate a location with a feed, I’d very much like to automatically fill in an initial location for each Imp (with obviously the possibility to improve or correct this information manually later).

We are not going to provide the IP address, but will be providing geolocation lookup as part of the agent services.

It probably only works in urban areas, but you could try using the results of imp.scanwifinetworks (BSSID and RSSI) for geolocation. When we tried it, it was good enough for the imp to know not just that it was in Cambridge, but which house it was in and even which room.

Obviously there are important privacy issues here. You should probably get your end-users’ explicit consent before collecting such information.

Peter

@peter - thanks for that suggestion - that actually works great for me. I’d looked at what details the Imp could determine about its surrounding and seen it could do a wifi scan but I didn’t think the resulting information would be useful for geolocation.

How wrong I was! It’s kind of cool but also a bit disturbing how accurate the results are :slight_smile:

For anyone who’s interested I’ve put a tiny project on GitHub that demonstrates using imp.scanwifinetworks() and the Google location service to determine the Imp’s location (the agent outputs a Google maps URL that shows the location):

@Hugo - why are you uninclined to reveal the publicly visible IP address that an agent has for an Imp? For anyone who is using NAT or such like this will not reveal any internal details of their network. Pretty much every internet enabled service knows and reveals the address of incoming requests so I don’t see that there’s e.g. a privacy factor here that’s unusual to the Imp.

@ghawkins,
works great!
Thanks.

Great stuff!

@Hugo, if you are adding to the API, how about allowing the agent or imp get hold of the local time as well as the UTC? I am finding we need to use scanwifinetworks or get the IP address indirectly in order just to ask Google API the timezone offset. This has been a great learning curve but clumsy just to get the local time which the server already knows.

I would like the imp ip too, when people wants to use my sensor platform they get a list of devices that report from the same ip as they are, which for the imp obviously dont match.

so instead I would send the imp ip in the datastream to override the agent ip, but alas its not possible :confused:

I would like it too… IP address and timezone that is!

IP address would be nice. One of our apps is connected to a barcode label printer and, on power-up it prints off a label with all of the relevant status information. IP address would be nice to add to it.

The server doesn’t know the timezone the imp is in; it knows the IP address and will provide the agent with lat/long. When we can be sure that the lat/long -> timezone lookup is as good as third parties then we’ll expose the timezone to the agent too.

So if my server logs show my local time at home (where I, my laptop and my imp live) then that is only because I happen to have a local server in the same timezone? The location of my server is of course somewhere in the Cloud of Unknowing, I had rather assumed a data centre in California, hence I was very impressed by the round trip from imp to agent and back of 200 msec.

No, this is done in the browser. The server provides UTC times for logs to the browser, which converts them to your local timezone :slight_smile:

Yes, the development servers are indeed in california.

Hi,

Was trying out the google api code posted by @ghawkins and get the wrong location on the imp log but if I copy and past the url on my browser I get the correct location.

Location got on the Log:
http://maps.google.com/maps?q=loc:45.8399,-119.701

Location got on the browser:
{ "accuracy" : 956, "location" : { "lat" : 19.4809094, "lng" : -69.90479649999999 }, "status" : "OK" }

I had problems with the old Google maps code a little while back, so came up with a new class that uses a slightly different API. The Google Maps API is deprecated and will probably be removed (though Google said that ages ago, and it’s still there). However, I stopped getting correct results on my imps, @jcmv007, which is why I wrote the new class.

You can find it here. It has to be instantiated on both the device and the agent.