Saturday, September 5, 2009

Getting your location using iPhone with no GPS

One of the main big features in iPhone 3G that was not shipped with its ancestor iPhone 2G is GPS support. You can determine your location using GPS satellites.
It is known that although very accurate, GPS has some drawbacks. It needs a lot of time to connect to the satellites, in the order of tens of seconds. It won't work indoors as well. Moreover, it is banned in Egypt, Syria and North Korea!
Update: It is not banned anymore in Egypt.

So can one determine his location without the aid of GPS technology? The answer is Yes. This can be done by identifying nearby GSM cell towers and query a database that stores their location. So lets divide the rest of this post into 2 parts:


Identifying nearby GSM cell towers

Doing this on the iPhone was a bit tricky. Actually it was a challenge for us at eSpace to get such information. I will list here the challenges we met and how we managed to solve them:
  1. There is no official SDK for iPhone OS 1.x. This was the easiest challenge to solve. Everybody uses iphone-dev for building the iPhone toolchain. Most of the header files in the toolchain are generated by class-dump! This is a tool that takes a binary framework (library) as an input and emits some Objective-C code in a header file that represents symbols in the library. Its idea is as simple as using nm to query symbol names and some extra code to wrap this info in Objective-C syntax.
  2. Even in the non-official toolchain, there is not a word on how to deal with telephony features like calls and text messaging. Thanks to CellStumbler, we used it to get cell information. It is a tool that exploits CoreTelephony framework functionality. CoreTelephony.h is also generated with class-dump.
  3. CellStumbler is very fragile, if you do simple edits in it, it may crash! The guys say it is toolchain bugs! Just keep this in mind if you need to modify it. Be aware that server connection callback never get called, so keep on retrieving cell information until you get something useful.
  4. Because CellStumbler is that fragile, we left the code untouched in its major parts, we just changed the part that outputs results. We then called the binary from a shell and parsed its output to get useful nearby cell information.

Querying a database for cell location

Google used to have a secret API for this. It is called My Location. This is the API it uses in Maps. Unfortunately, at the time of our development, the API was secret, we had to sniff upon packets to/from Google Maps to know what happens under the hood and replays it. Now this API is open to developers, thanks Google.


Read more...

Tuesday, June 2, 2009

Fortunately, another reason why I use Ubuntu

Since I installed Ubuntu 9.04 on my work machine (and replaced Micro$oft Outlook with Evolution), I always wondered why my download speed became surprisingly a lot faster! My surprises approached a relief today when I came across a local speed test service. I tested the speed on Windows (with no firewalls or anything coming in the middle) and Ubuntu.

The result was Ubuntu achieving DOUBLE speed than Windows! Yes you read it right, DOUBLE speed on the same machine!
I will leave you with the screenshots to witness it yourself.

Windows download speed:


Ubu download speed:

The only explanation I can tell is that the TCP/IP stack default parameters on Windows are not optimally configured, while the defaults in Linux are!
Any other suggestions?


Read more...

Sunday, May 17, 2009

Dr Mohamed Slim Alouini farewell at TAMUQ

Today we gathered for the farewell of Dr Alouini at TAMUQ. It has only been one week since I am here at TAMUQ, but Dr Alouini did have an effect on my career! Last October when I came here for an interview, Dr Slim (and Dr Shehab Ahmed) urged me to finish my Masters so that they can apply for my VISA.

After I came back to Egypt, I took an unpaid vacation from my work at eSpace and started the campus of studying! Thanks to Allah, I got the Masters certificate last February. I was always remembering Dr Alouini's words about pushing my career onwards and finishing the Masters as quickly as possible.



From right: Hossam Hammady (me), Dr Wessam Mesbah, Dr Alouini, Dr Ahmed Masoud, Majid Farouqi.

So although we didn't meet much, but thanks Dr. Alouini for pushing me onwards.


Read more...

Thursday, May 14, 2009

My new job at Texas A&M University at Qatar

It has been so long since I posted anything here. I am always lazy writing blogs :( Today I thought I should write something. From now on, my blogs should be short so that I don't get lazy writing them!

So, I am writing this to let you know that I have joined Texas A&M University at Qatar as a Teaching Associate. The hiring process took too long since I had to finish my Masters first before I apply for the VISA. Thanks Allah, I finished my Masters last February, but this is another story, I will write about it soon insha2Allah :)

I am now in Doha with my little family, my wife and my little 1-year-old kid, Abdullah. My job here includes both teaching tasks and support in IT-related issues for the faculty.

A lot of paper work to do here to finish my residency permit and settle in my new house. I didn't take any task yet, just all about orientation and settlement. I hope work would be fun here as I have always enjoyed my job :)


Read more...