{"id":241,"date":"2008-03-12T02:17:03","date_gmt":"2008-03-12T02:17:03","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=241"},"modified":"2008-03-12T14:40:42","modified_gmt":"2008-03-12T14:40:42","slug":"programmatically-getting-the-cellid-from-your-windows-mobile-phone","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=241","title":{"rendered":"Programmatically getting the CellID from your Windows Mobile phone"},"content":{"rendered":"<p>I&#8217;m still on paternity leave at the moment, so time near a computer is limited to 20 or 30 minute periods in the rare occasions while <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=239\">Faith<\/a> is asleep!<\/p>\n<p>But in the last few days, I&#8217;ve still been <a target=\"_blank\" href=\"http:\/\/twitter.com\/dalelane\/statuses\/767457472\">playing with a few new geeky things<\/a>. One of these is <a target=\"_blank\" href=\"http:\/\/electricpocket.com\/findme\/\">FindMe<\/a> &#8211; a Windows Mobile application from <a target=\"_blank\" href=\"http:\/\/electricpocket.com\/\">Electric Pocket<\/a>. <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/080312-findme.gif\" alt=\"screenshot of FindMe\" align=\"left\" hspace=\"10\" vspace=\"5\" style=\" border: thin black solid\"\/>The basic idea is:<\/p>\n<ul>\n<li>it gets the CellID of the GSM transmitter that your mobile phone is currently talking to<\/li>\n<li>if it hasn&#8217;t seen this CellID before, it displays &#8220;You are in a new place&#8221; and prompts you to type in a name for where you are<\/li>\n<li>if it has seen this CellID before, it uses the name you last entered for it<\/li>\n<\/ul>\n<p>Then it uploads your name for the CellID (your description for where you are) to your <a target=\"_blank\" href=\"http:\/\/www.facebook.com\/profile.php?id=904330607\">Facebook profile<\/a>.<\/p>\n<p>Hey presto &#8211; location tracking without the need for GPS.<\/p>\n<p>It works quite well. <\/p>\n<p>I&#8217;ve played with <a target=\"_blank\" href=\"http:\/\/dalelane.co.uk\/blog\/?p=173\">location based stuff on my phone before<\/a> but never tried to use GSM cell id before. I did consider it, but after failing to find a free database that could transform the cell id string into a location I could plot on a map, I didn&#8217;t really pursue it any further. <\/p>\n<p>Playing with FindMe encouraged me to give it a try. <\/p>\n<p><!--more-->I don&#8217;t know how the FindMe app is implemented, but after a little bit of playing tonight, it seems fairly easy to grab something similar to the &#8220;Cell&#8221; string they are using from the <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa923065.aspx\">RIL_GetCellTowerInfo<\/a> function in the <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa920475.aspx\">Radio Interface Layer<\/a> (RIL) API. <\/p>\n<ol>\n<li>Call <code><a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa919106.aspx\">RIL_Initialize<\/a><\/code> to get a RIL handle<\/li>\n<li>Call <code><a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa923065.aspx\">RIL_GetCellTowerInfo<\/a><\/code> to get the <a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa921533.aspx\">information about the cell tower<\/a> the phone is connected to\n<p>The &#8220;Cell&#8221; string that FindMe displays seems to be a combination of the <code>dwCellID<\/code>, <code>dwLocationAreaCode<\/code> and <code>dwMobileCountryCode<\/code> fields<\/li>\n<li>Call <code><a target=\"_blank\" href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa919624.aspx\">RIL_Deinitialize<\/a><\/code> to release the RIL handle<\/li>\n<\/ol>\n<p>It seems to work okay.<\/p>\n<p>Well&#8230; 150 or so lines of C# hacked together while Faith naps, generates the same strings that FindMe displays for the two cells my phone can bounce between in my house. Not exactly conclusive testing \ud83d\ude42  <\/p>\n<p>I&#8217;ve <strong><a target=\"_blank\" href=\"http:\/\/dalelane.co.uk\/blog\/post-images\/080312-rilcode.cs.txt\">put my code here<\/a><\/strong> in case it is useful to anyone. Usual disclaimers and provisos apply (i.e. it may be gibberish).<\/p>\n<p>I&#8217;m not sure what I&#8217;m going to do with it. The biggest problem is still the lack of a database to be able to translate the cell tower info you get into an actual geographical location. But if &#8211; as with FindMe &#8211; you&#8217;re willing to invest the time to &#8220;train&#8221; an app and build up your own cell id database of locations, then there is some potential for interesting apps. <\/p>\n<p>I might try writing a <strong>location based reminder app<\/strong> &#8211; could be interesting to extend the Outlook Tasks db to have something that reminds you of a task when you&#8217;re in a specific location. For example, it&#8217;d be good if your phone prompted you with things you want to remember to buy when you&#8217;re at the shops. The Tesco garage on my drive home from work is far enough away from anything else I go to that it&#8217;d probably have a cell ID that I wouldn&#8217;t otherwise be in. Likewise, once I work out the cell ids for <a target=\"_blank\" href=\"http:\/\/www.ibm.com\/uk\/hursley\">Hursley<\/a>, I could have something that can remind me of something when I get to work.<\/p>\n<p>Or, I could use this as an excuse to play with <a target=\"_blank\" href=\"http:\/\/fireeagle.yahoo.net\/\">Fire Eagle<\/a>. I&#8217;ve had the invite for that for a while and still haven&#8217;t got around to giving it a try. It could be cool to write something that lets you <strong>update your Fire Eagle location using Cell ID<\/strong> info.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m still on paternity leave at the moment, so time near a computer is limited to 20 or 30 minute periods in the rare occasions while Faith is asleep! But in the last few days, I&#8217;ve still been playing with a few new geeky things. One of these is FindMe &#8211; a Windows Mobile application [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[20,33,36,136,571,21,139,140,142,143,138,141,137,135,22,19],"class_list":["post-241","post","type-post","status-publish","format-standard","hentry","category-code","tag-net","tag-netcf","tag-c","tag-cellid","tag-code","tag-dotnet","tag-facebook","tag-findme","tag-fire-eagle","tag-fireeagle","tag-gps","tag-lbs","tag-location","tag-ril","tag-visual-studio","tag-windows-mobile"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=241"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/241\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}