-
Fireeagle location updater
Posted on September 2nd, 2008 View CommentsI have been running it for a while now and things look pretty good. The python script which updates my Fireeagle location does a couple of things.
- Watches the cell tower that the phone is connected to, queries Google cell mapping webservices (using the script detailed in previous post)and caches the location information of the cell tower in a local db on the phone
- Optionally uses GPS to get the current location
- If current location, determined by above positioning methods with preference to GPS, is more than a configurable distance away from my last updated location, update Fireeagle
- Optionally when doing a cell tower lookup also looks up geonames.org for the nearest neighborhood to give a meaningful place name to the cell location
- Oh yeah of course does a mobile auth with Fireeagle first time and stores the authorization key for future access.
Why one more updater? Navizon does a good job but i wanted it to do the distance based update, if i am within a certain radius, say 1 Km, of my location i really am not bothered about it getting reflected on Fireeagle. Making it configurable tunes it to the users taste. Also in an urban area cell towers keep hopping even though i have not moved. Dont bother updating in those cases. Not sure if Navizon caches the cell lookup information locally, but i feel its one piece that should be really cached. Why waste my mobile bandwidth doing the same cell lookup calls. Persisting this in a DB is really efficient. And last I would really like to have my location to be at one place.
The J2ME updater is a perfectly simple GPS updater but GPS is too power hungry and useless indoors. I really dont want to always keep my phone such that GPS signals are available (you know the belt pouch). This one too a distance based decision to update Fireeagle or not would be great in addition to time based.
So yeah i wanted a mix of the two mentioned above and with Python on S60 what better way to get it done that writing my own. The pain point to get this working was to port the existing oAuth and fireeagle libraries to python 2.2. The fireeagle libraries i just switched it to talk json and used the python-json module. Doing XML DOM parsing was really useless. The oAuth libraries needed some tinkering but manageable. The dependencies were the problem most of them were resolve by installing the mobile web server for s60 which has a bunch of python libraries like the cgi stuff.
After all this rambling where is the stuff? Well I have not bothered to package it into a standalone sis. If anyone is interested let me know i will put the bunch of scripts out with hopefully some sensible instructions to get it running. Download the source here GTower FireEagle Updater
-
Google cell tower mapping with Python on S60
Posted on July 11th, 2008 View CommentsI have had my N95 for some days now. I’ll just say that the device is all I could ask for in a smart phone for, now. iPhone 3G, yeah, lets just say my take on it is clear from my choice of the N95. So the best part of this being the Python for S60 and the location API’s available via Python.
I came across this piece of beauty which uses a hidden Google API for location detection based on cell tower information. Now what better way to start learning Python than getting this piece working on my phone with Python. I’m fed up of writing Hello Worlds to start learning a language. Here is a python version of the poor mans GPS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
from httplib import HTTP import location latitude = 0 longitude = 0 def doLookup(cellId, lac, host = "www.google.com", port = 80): from string import replace from struct import unpack page = "/glm/mmap" http = HTTP(host, port) result = None errorCode = 0 content_type, body = encode_request(cellId, lac) http.putrequest('POST', page) http.putheader('Content-Type', content_type) http.putheader('Content-Length', str(len(body))) http.endheaders() http.send(body) errcode, errmsg, headers = http.getreply() result = http.file.read() # could need some modification to get the answer: here I just need # to get the 5 first characters if (errcode == 200): (a, b,errorCode, latitude, longitude, c, d, e) = unpack(">hBiiiiih",result) latitude = latitude / 1000000.0 longitude = longitude / 1000000.0 return latitude, longitude def encode_request(cellId, lac): from struct import pack content_type = 'application/binary' body = pack('>hqh2sh13sh5sh3sBiiihiiiiii', 21, 0, 2, 'in', 13, "Nokia N95 8Gb", 5,"1.3.1", 3, "Web", 27, 0, 0, 3, 0, cellId, lac, 0, 0, 0, 0) return content_type, body (mcc, mnc, lac, cellId) = location.gsm_location() (latitude, longitude) = doLookup(cellId, lac, "www.google.com", 80) print latitude print longitude
Download
Beware this does not work from all IP’s, from my wifi connection at home this threw an error while on the GPRS connection this worked well.



Recent Comments