PDA

View Full Version : cellGPS for Windows Mobile? Upload GSM cell-id on periodic basis to HTTP server?


jmat
18th May 2008, 02:00 AM
I'm looking for a simple application that will run in the background, and send the current GSM/UTMS cell-id to a web server on a periodic basis (via HTTP GET).

Basically a program like cellGPS (http://www.vikinggames.hu/product.php?id=11) but for Windows Mobile. I don't really care about GPS info, since that just sucks power (and doesn't work indoors).

What I'm trying to do here is enable my home automation system to know where I am, without sucking my phone's battery to death (especially since GPS won't work indoors). GSM/UTMS cell-id is 'close enough' for me.

The application would just hit a webserver on my home machine with the current cell-id (http://webserver.com/receiver.php?cellid=4233-23) on a definable period. My own app on my webserver would record that data into a database. I can then go back and use that data to let my home auto system know "hey, Justin's almost home, turn on the HVAC, lights, etc".

It needs to be able to run in the background, no annoying icons on the screen, and start up on phone reset.

I figure since it's just sending the cell-id (which is always available), it would be rather efficient and not use much battery power (especially since I usually leave Activesync on "instant" so the data connection is usually up anyway).

Other extensions to this would let my server update twitter/facebook/etc with "Justin's at ... home/work/etc now.".

Any ideas?

pklein90
19th May 2008, 03:19 PM
wow this would be a great aplication :)

Cavey.co.uk
19th May 2008, 06:20 PM
Two programs come to mind.... Comm Mgr Pro (http://forum.xda-developers.com/showthread.php?t=299070) and rk-Location Switch (http://forum.xda-developers.com/showthread.php?t=328114).

I have not really played with these two programs much, but they do Cell tower based switching and might include some of the other features you require (but I do have to admit that they do not have all the features you want).

newb5000
19th May 2008, 07:08 PM
Dale Lane posted some c# code (http://dalelane.co.uk/blog/?p=241) to programmatically get the cellID of the current tower.
The rest is pretty simple - a place to enter the url and then periodically issue HTTP GET requests.

I guess I could try to cook up something when I have some time.

newb5000
19th May 2008, 07:46 PM
Well I went and coded a sample app anyway. It just reads the current tower info at the specified interval. Is this the information that you require?

Just extract the zip to the device and run the .exe.

Note: It requires .NET Compact Framework 2.0

hellacopterous
20th May 2008, 05:04 AM
this sounds pretty cool. remember that cellid information is good for triangulating to about 1000 meters. you can get "justin's on his way home, turn on the AC" but probably not "justin's in the shower, begin youtube upload"

jasonchan
20th May 2008, 08:23 PM
Well I went and coded a sample app anyway. It just reads the current tower info at the specified interval. Is this the information that you require?

Just extract the zip to the device and run the .exe.

Note: It requires .NET Compact Framework 2.0

Works great! even though this topic was supposed to be on logging it to a web database, I am not too keen on that since data charges are expensive. I would be more interested in an internal database where I can simply attach a "friendly name", say the location of the site (ie. corner of main and first st.) to some cell sites (or a group of sites) in the internal database. Similar to what nicetrack used to do on previous WM versions. http://forum.xda-developers.com/showthread.php?t=320055

jmat
20th May 2008, 09:17 PM
Well I went and coded a sample app anyway. It just reads the current tower info at the specified interval. Is this the information that you require?

Just extract the zip to the device and run the .exe.

Note: It requires .NET Compact Framework 2.0

I will check as soon as I get my Kaiser back -- I managed to shatter the screen over the weekend. doh. This sounds EXACTLY like what I'm looking for.

Someone else mentioned data charges, which I don't care about, since I'm on unlimited data (AT&T won't even sell the things without the unlimited data plan now).

Actually, I still have my older TyTN somewhere. Let me dig it up and give this a try.

jmat
20th May 2008, 09:20 PM
Works great! even though this topic was supposed to be on logging it to a web database, I am not too keen on that since data charges are expensive. I would be more interested in an internal database where I can simply attach a "friendly name", say the location of the site (ie. corner of main and first st.) to some cell sites (or a group of sites) in the internal database. Similar to what nicetrack used to do on previous WM versions. http://forum.xda-developers.com/showthread.php?t=320055

There's a program that sort of does this now, called Trackme -- but it only does GPS as far as I know. Adding DB code would probably add a whole lot of complexity (and CPU power).

I'm sure it's doable, though, but I would hope it wouldn't be in this app. I have enough crap running in the background eating precious CPU cycles. :)

I wish I had a Windows machine to do development on. I'm Mac/Linux only, and don't have access to Visual Studio anymore.. I wrote an app to do this for the iPhone, but it can't run in the background due to SDK limitations. It's annoying that Microsoft hasn't made the WinMo SDK work on other platforms (although I guess Apple is doing that with the iPhone, so I don't have much room to talk).

The "goal" of this desired application is to be as lightweight as possible and offload all processing to a real computer. My phone doesn't need to do all of the work.

I can't imagine this would use much bandwidth, anyway. Even if you updated every five minutes, that's far less than 50kb per day, assuming a 64 byte URL + all HTTP and TCP headers. It'd add up to around 1.5 megabytes a month. I'd bet it'd be closer to 800-900kb/month. That's nothing compared to email/etc traffic. I would hope EU/etc carriers aren't so bad that 1.5mb a month would put you over a limit...

newb5000
20th May 2008, 09:21 PM
Works great! even though this topic was supposed to be on logging it to a web database, I am not too keen on that since data charges are expensive. I would be more interested in an internal database where I can simply attach a "friendly name", say the location of the site (ie. corner of main and first st.) to some cell sites (or a group of sites) in the internal database. Similar to what nicetrack used to do on previous WM versions. http://forum.xda-developers.com/showthread.php?t=320055

I tested it yesterday when driving home from work. Tower changes were very frequent during my drive home. But lets say that a HTTP GET request (depending on the length of the URL) is on average 100 bytes. Lets say in a day you switch towers 200 times. That would result in just under 20 kilobytes of data usage in a day. I actually calculated this for myself because I also initially thought that one would get a large bill at the end of the month for data usage, but it would seem that this isn't the case.

One could also limit the web requests to only "bookmarked" Cell IDs.

I like the idea of the original poster even though I cannot see how I could use it personally, since I do not have a home automation system.

Regarding more friendly names - I remember that I had set it up on one of my first phones to receive cell broadcast messages from the towers which included the tower friendly name. Haven't tried since, though.

The data that is made available in Windows Mobile is the following:
http://msdn.microsoft.com/en-us/library/aa921533.aspx
Don't see any friendly names of towers though :(

I thought of adding a "bookmark" button so that one can bookmark the current Cell ID (and possibly assign a friendly name) but this would be very awkward while driving (and the frequent tower changes).

Google has a database with Cell IDs (http://rawsocket.org/?p=437) and uses them in Google Maps (http://mobilephonedevelopment.com/archives/500) but good luck getting a copy of their database :D

jmat
20th May 2008, 09:26 PM
this sounds pretty cool. remember that cellid information is good for triangulating to about 1000 meters. you can get "justin's on his way home, turn on the AC" but probably not "justin's in the shower, begin youtube upload"

Hah!

I only need 1000 meter resolution. GPS is definitely more accurate, but it would kill the battery in 6 hours flat.

Maybe when the third generation of GPS sats start going up in a few years, GPS receivers will use less power (since the sats will be much more powerful and supposedly will reach inside most buildings).. but that's 2015 at the earliest. Who knows what HTC/etc will come out with by then.

newb5000
20th May 2008, 09:30 PM
I will check as soon as I get my Kaiser back -- I managed to shatter the screen over the weekend. doh. This sounds EXACTLY like what I'm looking for.

Someone else mentioned data charges, which I don't care about, since I'm on unlimited data (AT&T won't even sell the things without the unlimited data plan now).

Actually, I still have my older TyTN somewhere. Let me dig it up and give this a try.

Only saw your post after I posted mine.
There aren't any web requests yet though, I just wanted to confirm that I was on the right track (through you testing it :) ). I'm willing to give it a bash because I'll learn something through the process.

Some questions arise:

Should the app dial a connection automatically, or just not send out requests if there is no active connection?
Still need to figure out how to get it to run in the background properly
I'm wondering how it should function if the phone is in standby

jmat
20th May 2008, 09:31 PM
I tested it yesterday when driving home from work. Tower changes were very frequent during my drive home. But lets say that a HTTP GET request (depending on the length of the URL) is on average 100 bytes. Lets say in a day you switch towers 200 times. That would result in just under 20 kilobytes of data usage in a day. I actually calculated this for myself because I also initially thought that one would get a large bill at the end of the month for data usage, but it would seem that this isn't the case.

One could also limit the web requests to only "bookmarked" Cell IDs.

I like the idea of the original poster even though I cannot see how I could use it personally, since I do not have a home automation system.

Regarding more friendly names - I remember that I had set it up on one of my first phones to receive cell broadcast messages from the towers which included the tower friendly name. Haven't tried since, though.

The data that is made available in Windows Mobile is the following:
http://msdn.microsoft.com/en-us/library/aa921533.aspx
Don't see any friendly names of towers though :(

I thought of adding a "bookmark" button so that one can bookmark the current Cell ID (and possibly assign a friendly name) but this would be very awkward while driving (and the frequent tower changes).

Google has a database with Cell IDs (http://rawsocket.org/?p=437) and uses them in Google Maps (http://mobilephonedevelopment.com/archives/500) but good luck getting a copy of their database :DTower switching will happen quite fast in big populated areas. That's why I was just going for every few minutes and not "as the tower changes".

It's too bad the towers don't "advertise" their GPS coordinates along with the other tower data. It seems like that would have been really easy to stick in the UMTS standard.

I'm surprised Google hasn't open sourced that database, or at least made an API library for it. Afterall, their users are the ones who discovered it all, not them -- Google Maps just records GPS coordinates + cell IDs and uploads them when you run the Google Maps location. I've seen that app upload several hundred kb during some runs.

Going back to the 'post on switch' thing. That might be a neat option -- to send a GET on every tower switch.. I'm going back and forth in my head on if that's a good idea or not. :) It'd be interesting to see how that hits battery life, though. (Since I have ActiveSync with "always push" enabled, I bet it doesn't make much of a difference).

newb5000
30th May 2008, 03:56 PM
Hi guys,

Apologies for the delay - I've been terribly busy.
I managed to create the app so it's ready for testing.

Attached is the cab file. The app consists of two components - the configuration utility and the service. The service is responsible for making the web requests and is launched at startup. You can use the configuration utility to adjust the settings as well as monitor what the service is doing.

The service will automatically dial your data connection when a web update is necessary, but it can also work via WiFi - although I don't see why you would use it via WiFi. It also supports websites that require Windows Authentication (Kerberos or NTLM should work, but do test it).

I think the app should be pretty self explanatory, but please do post if you have any questions or experience any problems.

FIY - the last error (if there is one) is stored in a log file located in:
Program Files\CellID Updater\cidlog.txt

Hope you like it!

EDIT: An update is available on the next page. I'm leaving this attachment as is just for reference purposes, but you should download the one on the next page.

danielherrero
30th May 2008, 04:14 PM
CommMgrPro is creating a very big database automatically with operatorID-Cell/LAC-GPS coords sent (automatically) by the users (they can track their movements in realtime with googlemaps). Obviously GPS coords are only sent by GPS enabled devices. You can change the URL where the data is posted (HTTP GET) to point your site and I can give you a free license. Currently 3000 cells registed with gps coords and growing as the users moves....
Dani

frouk
30th May 2008, 06:06 PM
Hi guys,

Apologies for the delay - I've been terribly busy.
I managed to create the app so it's ready for testing.

Attached is the cab file. The app consists of two components - the configuration utility and the service. The service is responsible for making the web requests and is launched at startup. You can use the configuration utility to adjust the settings as well as monitor what the service is doing.

The service will automatically dial your data connection when a web update is necessary, but it can also work via WiFi - although I don't see why you would use it via WiFi. It also supports websites that require Windows Authentication (Kerberos or NTLM should work, but do test it).

I think the app should be pretty self explanatory, but please do post if you have any questions or experience any problems.

FIY - the last error (if there is one) is stored in a log file located in:
Program Files\CellID Updater\cidlog.txt

Hope you like it!

Hey all - my first post.

I must say, it's outstandingly honorable that you share your skills with us. So good.. (haven't installed the tool yet, hope it's no virus or tv-on/off-switcher)

One question @jmat: How do you process the cellid once it is http'd to your server? Is there a webservice that maps cell-ids to gps?

Frouk

newb5000
30th May 2008, 06:51 PM
I must say, it's outstandingly honorable that you share your skills with us. So good.. (haven't installed the tool yet, hope it's no virus or tv-on/off-switcher)

Thanks and no, it's not a virus / trojan / <insert something bad here> :D

One thing I forgot to mention is that if the device goes into standby, the service will be "paused". Then, when the device comes out of standby, the service will resume where it left off. I'm not sure whether this is acceptable behaviour for the app, but I considered the alternative - preventing the device from going into standby will drain the battery very quickly. So you would choose when the service should send out updates by taking your device out of standby.

Another thing: you can configure how often the service checks for a new tower and whether it should send out an update if the tower is different or the same since the last check.

I'm still wondering how I can put this app to good use, personally. I don't have a home automation system and I don't need to be tracked by anyone at home. Any ideas on what other uses this app could have? :)

frouk
31st May 2008, 12:51 PM
Thanks and no, it's not a virus / trojan / <insert something bad here> :D

One thing I forgot to mention is that if the device goes into standby, the service will be "paused". Then, when the device comes out of standby, the service will resume where it left off. I'm not sure whether this is acceptable behaviour for the app, but I considered the alternative - preventing the device from going into standby will drain the battery very quickly. So you would choose when the service should send out updates by taking your device out of standby.

Another thing: you can configure how often the service checks for a new tower and whether it should send out an update if the tower is different or the same since the last check.

I'm still wondering how I can put this app to good use, personally. I don't have a home automation system and I don't need to be tracked by anyone at home. Any ideas on what other uses this app could have? :)

The configuration is just perfect - that way one can decide when to update just by letting the device go to sleep or not. Another thing: am I right that this app will never be as accurate as Google maps "my location"? It uses triangular approximation with more than one cell-id, right? I experienced it to be very accurate, even being on the train it exactly locates my position, amazing.

I personally intend to use such kind of app for reality/virtuality games where website visitors can track something or someone on the web and then go outside into the real world and do something or meet someone.

But jmats' idea is also amazing.

rafgerm
31st May 2008, 04:27 PM
Years ago I had Ericsson R320 (BTW great phone). It showed cell name e.g. "city centre" on the screen besides op name. I dug up my eric from the closet and this option still works. It would be great to have this as a today plugin :D Do you know something like that?

mruiz
31st May 2008, 07:55 PM
I'm still wondering how I can put this app to good use, personally. I don't have a home automation system and I don't need to be tracked by anyone at home. Any ideas on what other uses this app could have? :)

Maybe you could mount a web server in your home pc (pretty simple) and track your device if it gets lost or stolen... It would be nice to recover your $700dlls phone right.

NewLifeTrio
31st May 2008, 08:15 PM
Hi guys,

Apologies for the delay - I've been terribly busy.
I managed to create the app so it's ready for testing.

Attached is the cab file. The app consists of two components - the configuration utility and the service. The service is responsible for making the web requests and is launched at startup. You can use the configuration utility to adjust the settings as well as monitor what the service is doing.

The service will automatically dial your data connection when a web update is necessary, but it can also work via WiFi - although I don't see why you would use it via WiFi. It also supports websites that require Windows Authentication (Kerberos or NTLM should work, but do test it).

I think the app should be pretty self explanatory, but please do post if you have any questions or experience any problems.

FIY - the last error (if there is one) is stored in a log file located in:
Program Files\CellID Updater\cidlog.txt

Hope you like it!
Very nice app newb5000. Good work! I've been testing it out this evening and it is working very nicely. A quick question though, how easy is it to add the additional Cell info (LAC/MCC/MNC) to the URL variable list? I'm assuming that if you have access to the CellId value, the other values are also accessible. Is this right? Perhaps you would like to share your source code so that others can extend it?

Thanks for a nice little app!

jmat
31st May 2008, 11:57 PM
The configuration is just perfect - that way one can decide when to update just by letting the device go to sleep or not. Another thing: am I right that this app will never be as accurate as Google maps "my location"? It uses triangular approximation with more than one cell-id, right? I experienced it to be very accurate, even being on the train it exactly locates my position, amazing.

I personally intend to use such kind of app for reality/virtuality games where website visitors can track something or someone on the web and then go outside into the real world and do something or meet someone.

But jmats' idea is also amazing.

Some ways I would/could use this:

- Home automation triggers
- Location based twitter posting
- Update facebook profile with a location (that 'find-me' app that someone else has written sucks)
- Find out where your kids are without running a GPS app that sucks power

Some have mentioned stolen phone tracking -- well, this isn't too helpful for this. Cell spots are way too big to be very useful. Now, if you wanted to find out where you left your cell phone (say at the store), you could at least tell the general location of the phone. There are better things for this though, such as WIMP. Problem, of course, is GPS doesn't work indoors... cell tower ID does.

I suppose it's a pretty limited application thing. I'm a pretty big geek, though, and have things like this: http://xtex.org/locate/ ... it uses the GPS information transmitted by my Jeep's ham radio and plots it on Google Maps.

I haven't had a chance to test this thing out yet, even though I initiated the thread, because I managed to shatter my Kaiser's screen a week or two ago. The replacement screen arrived yesterday, but I haven't had a chance to put it in yet (I need to get to work where I actually have a lab work bench and enough light/tools to get it done).

J

newb5000
1st June 2008, 01:33 PM
...Another thing: am I right that this app will never be as accurate as Google maps "my location"? It uses triangular approximation with more than one cell-id, right? I experienced it to be very accurate, even being on the train it exactly locates my position, amazing.
I could be wrong but I don't think that info from multiple cells can read at the same time in Windows Mobile (or other OSes for that matter), at least not in a device-independent way.
Google maps itself can only guess as to where you are within a cell's coverage zone, as shown in this video (http://www.google.com/support/mobile/bin/answer.py?answer=81869&ctx=sibling&topic=12595).
This page (http://www.google.com/support/mobile/bin/answer.py?answer=81873&topic=12595), however, makes me wonder. They mention adjacent cells. Is it the app which is retrieving adjacent cell info from the device radio, or is it simply the app sending the current cellid to Google's servers and the adjacent cells are determined server side from their database of cellid / gps-coordinates? My guess would be the latter.
Cell switching while on the move can also be used to better determine your location and is probably something that Google uses as well.

The app that I wrote simply broadcasts cellid switches to a web server so there is no "location approximation code".

A quick question though, how easy is it to add the additional Cell info (LAC/MCC/MNC) to the URL variable list? I'm assuming that if you have access to the CellId value, the other values are also accessible. Is this right? Perhaps you would like to share your source code so that others can extend it?
It will be easy, but I will need to release an update. Just to make sure that we are on the same page:

LAC = Location Area Code
MCC = Mobile Country Code
MNC = Mobile Network Code

correct?

There are even more parameters than just the abovementioned ones, obtainable via the Radio Interface Layer - for a full list, check out this page (http://msdn.microsoft.com/en-us/library/aa921533.aspx).

I'll cook the parameters you requested into the next update.

Regarding source code, I will probably make the app open source if I determine that I no longer have time to support it, but for now I'm here so I can implement any (reasonable) ideas / sugestions.

NewLifeTrio
1st June 2008, 05:57 PM
It will be easy, but I will need to release an update. Just to make sure that we are on the same page:

LAC = Location Area Code
MCC = Mobile Country Code
MNC = Mobile Network Code

correct?


That is indeed correct. Very much looking forward to the update. I've been playing around with the app and by borrowing some code from here (http://www.witracks.com.br/gmaps.txt) and a little jiggery pokery, I've been able to derive longitude and latitude from a cell id (thanks Google!). However I've had to hard code the LAC, MCC and MNC which restricts me to a single LAC area. Can't wait for the additional variables! Thanks for your hard work!

newb5000
2nd June 2008, 10:56 AM
An update is available :)
The app is now sitting at version 0.2 - I renamed the cab to reflect this. You can just install this over the old installation - the old version will automatically be uninstalled.

Version 0.2 Changelog

Fixed bug where ampersands in the url would cause problems
Fixed bug where if a web update failed for some reason, the new cell info would not be sent again until a cell switch occurred.
Rephrased some of the text on the Schedule tab.
Fixed some alignment issues when changing to landscape mode.
Added support for Mobile Network Code {mnc}, Mobile Country Code {mcc} and Location Area Code {lac} in the url.

NewLifeTrio
2nd June 2008, 02:19 PM
An update is available :)
The app is now sitting at version 0.2 - I renamed the cab to reflect this. You can just install this over the old installation - the old version will automatically be uninstalled.

Version 0.2 Changelog

Fixed bug where ampersands in the url would cause problems
Fixed bug where if a web update failed for some reason, the new cell info would not be sent again until a cell switch occurred.
Rephrased some of the text on the Schedule tab.
Fixed some alignment issues when changing to landscape mode.
Added support for Mobile Network Code {mnc}, Mobile Country Code {mcc} and Location Area Code {lac} in the url.


Great stuff! This has made my day!

I've been using 0.2 this morning and am happy to say it is working just great.

Thanks for your efforts... looking forward to seeing how this app progresses.

newb5000
2nd June 2008, 04:49 PM
Interesting...
http://developer.garmin.com/mobile/mobile-sdk/xt-wm-sdk/

Esteel
2nd June 2008, 05:43 PM
This sounds pretty interesting. I wonder if it could be used in conjunction with QuickGPS and any GPS application to speed up TTF of the satellites.

For example, the App pulls general location from cell towers, compares it to the ephemeris data in QuickGPS and provides the GPS application more accurate initial satellite information.

jmat
3rd June 2008, 12:50 AM
An update is available :)
The app is now sitting at version 0.2 - I renamed the cab to reflect this. You can just install this over the old installation - the old version will automatically be uninstalled.

This is the coolest thing ever. :-D

It's exactly what I was looking for. Wow.. too awesome... the only thing left on my 'wishlist' is automatic startup.

Even if it stops when the phone suspends -- that's fine for me. I thought about that some last night -- I probably check my phone every 15-20 minutes anyway, so I wake it up all the time.. and when it's in my car, it's plugged in for power (and I have it set to never suspend when plugged in).

Plus I already use Phone Alarm, which wakes the phone up every 5-6 minutes anyway to check location (so it can switch profiles)..

I was playing with the Navizon API on my iPhone SDK toolkit, and was hoping they'd let me use the free API (http://www.navizon.com/fordevelopers.asp) to send web-based queries to their database to get lat/long data, but no dice. They've also encrypted their requests so I can't see how they're doing it ($5 says it's just an https call to a server, with a GET with username/password/cellid). I'm going to drop them an email and see what they say.. :rolleyes: It's just so much more efficient power wise to do as much "heavy lifting" on a real server than have my cellphone doing stuff it doesn't really need to be doing.

I'm kind of amazed at how much my phone flips between towers at my home... no wonder my battery life sucks here. I must be right on the fringe of three or four cells. When I'm at work, it stays on a single cell the entire time.

I've been running this for a few hours, and my battery life isn't any different than normal. I tried doing this with that 'trackme' program that turns on/off GPS every five minutes, and I lasted all of three hours on a full charge.

Now I just have to do a little mapping of the cells to where I am...

NewLifeTrio
3rd June 2008, 01:14 AM
I was playing with the Navizon API on my iPhone SDK toolkit, and was hoping they'd let me use the free API (http://www.navizon.com/fordevelopers.asp) to send web-based queries to their database to get lat/long data, but no dice.

There are ways to the same using the "hidden" API that Google Mobile Maps uses for it's "My Location" function.

See here for a php implementation:-
http://www.witracks.com.br/gmaps.txt

For example:-
http://www.witracks.com.br/gmaps.php?myl={mcc}:{mnc}:{lac}:{cellid} (http://www.witracks.com.br/gmaps.php?myl=234:20:150:763856)

There is also http://www.opencellid.org which is a great idea, and has an open API, but is still lacking the quantity of cell data that Google has.

jmat
3rd June 2008, 01:14 AM
An update is available :)
The app is now sitting at version 0.2 - I renamed the cab to reflect this. You can just install this over the old installation - the old version will automatically be uninstalled.

Version 0.2 Changelog

Fixed bug where ampersands in the url would cause problems
Fixed bug where if a web update failed for some reason, the new cell info would not be sent again until a cell switch occurred.
Rephrased some of the text on the Schedule tab.
Fixed some alignment issues when changing to landscape mode.
Added support for Mobile Network Code {mnc}, Mobile Country Code {mcc} and Location Area Code {lac} in the url.



Playing with Yahoo's free ZoneTag service...

http://developer.yahoo.com/yrb/zonetag/locatecell.html

So far so good... of course, my area isn't mapped very well... Most of them just return "USA", but I've found one that actually returns a ZIP code.. heh. you'd think the middle of Atlanta GA would have decent coverage... :)

jmat
3rd June 2008, 01:20 AM
There are ways to the same using the "hidden" API that Google Mobile Maps uses for it's "My Location" function.

See here for a php implementation:-
http://www.witracks.com.br/gmaps.txt

For example:-
http://www.witracks.com.br/gmaps.php?myl={mcc}:{mnc}:{lac}:{cellid} (http://www.witracks.com.br/gmaps.php?myl=234:20:150:763856)

There is also http://www.opencellid.org which is a great idea, and has an open API, but is still lacking the quantity of cell data that Google has.

wow... okay... that's a lot better than the ZoneTag stuff from Yahoo.

I've already written a short php script that will receive the data from CellID Updater, and log it to a mysql database. If it doesn't have the lat/long information, it will retrieve it from Google.

I definitely need to clean it up and add error checking (it's pretty much a "oh please hack me" script right now), but I will post it here as soon as I'm done, along with table info and such.

newb5000
3rd June 2008, 01:23 PM
This sounds pretty interesting. I wonder if it could be used in conjunction with QuickGPS and any GPS application to speed up TTF of the satellites.

For example, the App pulls general location from cell towers, compares it to the ephemeris data in QuickGPS and provides the GPS application more accurate initial satellite information.
You can only (potentially) get lat / long from a cell id, but not any satellite data. So the information provided by QuickGPS and the information provided by the app (and adding lat/long to it) is very different. What the app could possibly help with is to tell the GPS application (Garmin Mobile XT in my case) approximately where you are, thus (maybe) reducing the TTF because your 'last known location' is very close to where you actually are. I need to research this though - I briefly looked at the Garmin Mobile XT SDK yesterday and didn't find a place to 'set' the current position. Maybe this can be done using the GPS Intermediate Driver.
... the only thing left on my 'wishlist' is automatic startup.
The cab file creates a shortcut to the service in \\Windows\Startup. I tested this on my device and the service does start up when I soft reset. Remember, the configuration utility does not need to be running for web updates to happen - everything is handled by the service. What happens when you soft reset and then run the configuration utility - does the config utility say that the service is started without you having started it? If so, then it is working correctly.
There are ways to the same using the "hidden" API that Google Mobile Maps uses for it's "My Location" function.

See here for a php implementation:-
http://www.witracks.com.br/gmaps.txt

For example:-
http://www.witracks.com.br/gmaps.php?myl={mcc}:{mnc}:{lac}:{cellid} (http://www.witracks.com.br/gmaps.php?myl=234:20:150:763856)

There is also http://www.opencellid.org which is a great idea, and has an open API, but is still lacking the quantity of cell data that Google has.
I had an idea yesterday and already started creating a SQL Server Compact 3.5 database which will store all unique cells that you have visited. Then, I thought we have two options:

Use ADO.NET Synchronization Services for devices (it's currently in CTP1) to sync this database to a desktop application. The desktop application can then be used to call Google's 'hidden' web service for each new cell found and attach lat / longs and then sync back to the device. The lat / longs can be refreshed for all cells since operators can theoretically change cellids or new coordinates for cells could come out. In a java sample that I saw, one had to specify the model of your device, but I don't see that in the code that you posted. If the model is required, maybe we can get a list of supported devices and randomly choose which model is used for each web request so as to not raise suspicion at Google :D

The second option is to not use a desktop application at all, so everything would happen on the phone, but the advantage of the desktop application is to maybe generate a kml file for a cell to view in Google Earth.

What I want to do for myself personally, is (assuming we have a database of cellid to lat / longs), create a Today plugin with a button which says "Show me the map of my approximate location". The plugin would then look up the current cellid in the database, get the approximate coordinates and launch Garmin Mobile XT in map mode focused at that point - no data connection required.

jmat
4th June 2008, 05:13 PM
I'm not going to quote, since this is a slow thread. ;-)

The 0.2 version is working great for me -- it has been reliably posting cell information to my server for the past two days. The receiving script hits the Google Maps interface when it needs to get lat/long information, but I'm finding 50-70% of the cells don't have that information. I'm not really sure how Google's doing it -- but if I had to guess, they're grabbing neighbor cell information from the phone and querying on those as well.

In order to get my own lat/long in there, I've been carrying around my AMOD AGL3080 GPS logger -- it logs lat/long every second. I then upload that data file to my server on occasion, and run a quick script that syncs the cell data to the GPS data based on the time.

It's accurate enough for my needs. :)

I've already written an interface that lets it post to Twitter/Facebook when my location changes by more than 3 miles (okay, it's a crappy shell script, but it works for me).

The best part is my phone's battery doesn't even notice the program running. Even better is it doesn't pop up randomly like the Comm Manager and that stupid "FindMe" facebook program do.

My concern with adding a backend database and all the other stuff is battery life. I'm lucky to get 12-13 hours as is, and I can't afford to burn anymore battery. That's why I'm not using the GPS receiver itself to do this. If you think you can add that stuff without compromising battery life, then I'm all for it. :D

khaytsus
6th June 2008, 08:24 PM
Took me a while to figure out just how to use it, but I put together three scripts for my LAMP server, in case anyone is interested.. Probably duplicated some work, but anywho...

cellloc.cgi: Collects data, logs it in a flat text file with the current time
cellloc.php: Takes mmc/mnc/lac/cellid and redirects to Google Maps
myloc.cgi: Reads the log file, gives the stampstamp and a link to cellloc.php

In case it doesn't make sense, the phone uploads to cellloc.cgi. Someone goes to myloc.cgi and it tells them the last data timestamp and gives 'em a link. When they click the link, it passes the data into cellloc.php and immediately then redirects to google.com with the lat/long.

ie: I have no idea how to use the Google API so I hacked stuff together, but for a 45m trial and test period, not bad. It works. :)

Thanks for the program and the links to the PHP code folks. And I'll probably improve on the stuff, but let me know if anyone is interested.

seelion
8th June 2008, 06:02 PM
which url i must type in?

gai-jin
8th June 2008, 11:23 PM
It looks like you're well on your way, but I thought I'd point out another option. I run Navizon for the points collection/rewards, but I was playing with their website a couple of nights ago and found, in the buddies section of the page, that it gives you a way to publish your location out to a url at any given time. It has links to google maps and such, but also offers a very simple xml file with your longitude and latitude in it. Perhaps grabbing the lat/long from that file would be sufficient?

khaytsus
9th June 2008, 04:42 AM
It looks like you're well on your way, but I thought I'd point out another option. I run Navizon for the points collection/rewards, but I was playing with their website a couple of nights ago and found, in the buddies section of the page, that it gives you a way to publish your location out to a url at any given time. It has links to google maps and such, but also offers a very simple xml file with your longitude and latitude in it. Perhaps grabbing the lat/long from that file would be sufficient?

Sounds interesting, but the cool thing about this program is that it pushes the data out every time your CID changes, not just when prompted, and it does it completely in the background, and as far as I can tell, uses very little battery and creates zero disruption.

I haven't tried Navizon, so not claiming it uses lots of battery, disruptive, etc.

I've worked on my scripts a little more, I can limit the shown occurrences, days shown, as well as limit to a date range of data shown. Has basic use of the Google API to draw a fairly clean map right on the page of the most current location or any of the shown occurrences if someone clicks the links, etc, with some basic html forms using a mix of php and perl.

I've *considered* making it able to use anonymous registration and get a unique ID which anyone can use to send and view their data, assuming they maintain their unique ID. If anyone is interested in that let me know and I could probably do it pretty easy.

gai-jin
10th June 2008, 11:24 PM
Sounds interesting, but the cool thing about this program is that it pushes the data out every time your CID changes, not just when prompted, and it does it completely in the background, and as far as I can tell, uses very little battery and creates zero disruption.

I haven't tried Navizon, so not claiming it uses lots of battery, disruptive, etc.


I only use navizon with the GPS and Wifi on, so as to collect points, so I'm not sure how battery life is when used only the cell phone. Obviously, with all the radios running, the battery runs out pretty quickly.

khaytsus
11th June 2008, 02:55 AM
I only use navizon with the GPS and Wifi on, so as to collect points, so I'm not sure how battery life is when used only the cell phone. Obviously, with all the radios running, the battery runs out pretty quickly.

I imagine it does.. I've measured the GPS alone at 50-100mAh, not sure why it varies so much. So when I'm outdoors with GPS I have it running, screen at high, and probably running some intensive program (PathAway, etc), which results in 300-350mA draw. Yikes.

I was doing this in the back yard one day with online email, IM, GPS, PathAway, on HSDPA and it was dropping 2-3% a minute and was VERY warm.

Termiter
13th June 2008, 10:00 AM
Thanks to newb5000 for this aplication!

I did small Locate Server based on PHP and MySQL for my friends. We are posting cellid to SQL and we can see where are we (and where are was) on our personal page via Google Maps API.

Very small data traffic, none battery drain... :c)

freekquency
13th June 2008, 11:30 AM
Yea your going to get lots of redudent tower ids, lots of time your call is going on on two cell towers at once. (if everything is working correctly)

Then when your signal is stronger on one it switches you <

I have access to overlays for new england. With about every cell location on them. ( you cant see the map thru the tags- theres that many).




Anything anyone could use?

acedish
15th June 2008, 04:02 AM
I installed the Cab file with no errors on WM6 but when I run the program from the start menu I receive an error in the cidconfig.exe? should it work on WM6?

newb5000
15th June 2008, 04:10 AM
Yes, it should work on Windows Mobile 5 or 6 as long as you have the .NET Compact Framework 2.0 or later installed. What is the error message that you are getting?

acedish
15th June 2008, 04:28 AM
Hmm I think I have Compact Framework 2.0 installed, Is there a way I can verify? i did uninstall and reinstall wit the same errors.


I receive the error message:
An unexpected error has occurred in cidconfig.exe. Select Quit and then restart blah blah blah...


If I select details

NotSupportedException

at Microsoft.AGL.Common,MISC.HandleAr() at System.Windows.Forms.InitInstance()

and it goes on......

newb5000
15th June 2008, 04:51 AM
Well the .NET Compact Framework 2.0 should come preinstalled with all WM6 ROMs and even custom ROMs (the chefs should bake in either 2.0 or 3.5).

You can maybe check if it is installed if you examine the following registry keys (http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_thread/thread/7437aea39cd9af00/96e9c275da1375af?#96e9c275da1375af), but I do not think that you need to go through this process since the exception being thrown is a framework exception.

If you click on details, the error message can be quite large (it's the stack trace that is large, which is the sum of all of the lines beginning with 'at '). It will be useful to see the full stack trace if you're willing to type it out here. I'm interested in what is not supported (indicated by NotSupportedException).

I thought that it has something to do with the RIL layer, but cidconfig.exe does not make any RIL calls.

Only thing I can suggest at the moment is to try to soft reset, but I might be able to help if you can show the full error message.

Have you tried to run the app on the first page? That was just a test app to read the current cellid, so it is not useful, but I'm interested if you get a similar error.

newb5000
15th June 2008, 05:26 AM
Another question: Are you using Windows Mobile 6 Professional? If you are using Windows Mobile 6 Standard, that may very well be the cause of this error, from the research that I just conducted.

Without the stack trace, this is a shot in the dark, but it appears that Windows Mobile 6 Standard, which is installed on SmartPhones does not support buttons, which the app uses. Windows Mobile 6 Professional is installed on Pocket PCs. I'm assuming that you're not using a TyTN II / Tilt. Does your phone come with a touch screen / stylus?

acedish
15th June 2008, 02:58 PM
I tried the first app and received the same error, I am using a Samsung BlackJack 2, no touchscreen or stylus.

newb5000
15th June 2008, 03:46 PM
Right, so you are running Windows Mobile 6 Standard.

I'm going to have to see what can be done to make this work on Standard. I'm thinking two different versions of the configuration utility - one for Standard and one for Professional. The service has no user interface, so that should work on both as is. It's not much work - the configuration utility is small, but the user interface will need to be different.

I'll be testing out the app on a Windows Mobile 6 Standard emulator and will get back to you.

newb5000
17th June 2008, 07:47 PM
It was more work than I thought, but I got there, eventually :)

This version is functionally identical to the version on the 3rd page (cellidupdater_0.2.cab), except that the user interface is designed to work on Windows Mobile Standard (i.e. Smart Phones).
It will work on Windows Mobile Professional (i.e. Pocket PCs) as well, but there is no need to download this version if you are already using the one on the 3rd page.

There are two issues with this cab (acedish or any other Smart Phone users, please will you provide feedback).

Firstly, it is not digitally signed. Edit: I actually typed out a lengthy post on why this can be a problem, depending on device configuration, but decided to omit this since it may not be a major problem after all. This article (http://msdn.microsoft.com/en-us/library/ms839681.aspx) provides a lot of detail - very good read, I must say.

Edit: Second issue Fixed. Pressing the 1 dialpad character continuously will now cycle through the appropriate characters. Additionally, I found out that if you press and hold the # key, you are offered a choice of even more symbols (which doesn't seem to work on the emulator). So typing in the url on a Smart Phone should be no problem at all.

I decided to include some screenshots this time round, so here they are (the Smart Phone / Windows Mobile Standard version):

dzalbo
18th June 2008, 09:54 AM
It was more work than I thought, but I got there, eventually :)

This version is functionally identical to the version on the 3rd page (cellidupdater_0.2.cab), except that the user interface is designed to work on Windows Mobile Standard (i.e. Smart Phones).
It will work on Windows Mobile Professional (i.e. Pocket PCs) as well, but there is no need to download this version if you are already using the one on the 3rd page.

There are two issues with this cab (acedish or any other Smart Phone users, please will you provide feedback).

Firstly, it is not digitally signed. Edit: I actually typed out a lengthy post on why this can be a problem, depending on device configuration, but decided to omit this since it may not be a major problem after all. This article (http://msdn.microsoft.com/en-us/library/ms839681.aspx) provides a lot of detail - very good read, I must say.

Edit: Second issue Fixed. Pressing the 1 dialpad character continuously will now cycle through the appropriate characters. Additionally, I found out that if you press and hold the # key, you are offered a choice of even more symbols (which doesn't seem to work on the emulator). So typing in the url on a Smart Phone should be no problem at all.

I decided to include some screenshots this time round, so here they are (the Smart Phone / Windows Mobile Standard version):

THANKS A LOT

Could you also share the source code?

dzalbo
18th June 2008, 11:48 AM
Hi everybody,

Just a quick question.. I was trying to make my own application based on RIL to get CellID and LAC..

What happens is that I keep getting 10-digits number value for dwLocationAreaCode, which does not seem to be true..

Any idead why that could be happening?

dzalbo
18th June 2008, 02:29 PM
Well, I have tried the application and seems that I've finally run into some problems..

I cannot explain that, but my mobile is returning a different CellID every second.. I mean, it never repeats.. I can't probably beliebe that it is switching from one tower to another every second.

Besides, I am getting the same LAC as in the application i tried to do myself.. (10 digits, while it supposed to be up to 7 digits)

In addiition I am getting wrong MCC and MNC...

Anybody experienced something similar?

I am using Samsung-i320.

Do you think it might be a phone or Mobile operator problem?

newb5000
18th June 2008, 03:14 PM
THANKS A LOT

Could you also share the source code?

Dale Lane's posted source code (http://dalelane.co.uk/blog/post-images/080312-rilcode.cs.txt). That's pretty much all you need to use the RIL layer, which is what I'm using.

Well, I have tried the application and seems that I've finally run into some problems..

I cannot explain that, but my mobile is returning a different CellID every second.. I mean, it never repeats.. I can't probably beliebe that it is switching from one tower to another every second.

Besides, I am getting the same LAC as in the application i tried to do myself.. (10 digits, while it supposed to be up to 7 digits)

Anybody experienced something similar?

I am using Samsung-i320.

Do you think it might be a phone or Mobile operator problem?

That's interesting. My lac is 5 digits, cellid is 5 digits, mnc is 2 digits and mcc is 3 digits.

It could be a phone / operator problem, but I would look elsewhere first:

Since you've got it running, what is your value of dwParams that you get back? (It's the second member of the RILCELLTOWERINFO structure).
dwParams, according to the documentation, should be one of or a combination of RILCELLTOWERINFO parameter constants (http://msdn.microsoft.com/en-us/library/aa919918.aspx). It could be that you're getting an invalid LAC back.

dzalbo
18th June 2008, 03:51 PM
Since you've got it running, what is your value of dwParams that you get back? (It's the second member of the RILCELLTOWERINFO structure).
dwParams, according to the documentation, should be one of or a combination of RILCELLTOWERINFO parameter constants (http://msdn.microsoft.com/en-us/library/aa919918.aspx). It could be that you're getting an invalid LAC back.

dwParams = 28

newb5000
18th June 2008, 04:08 PM
I think you just hit the nail on the head. This could explain why jmat (and possibly others) have been receiving "extra" cellids.

for dwParams == 28
(dwParams & RIL_PARAM_CTI_CELLID) != 0 true
(dwParams & RIL_PARAM_CTI_LOCATIONAREACODE) != 0 true
(dwParams & RIL_PARAM_CTI_MOBILECOUNTRYCODE) != 0 false
(dwParams & RIL_PARAM_CTI_MOBILENETWORKCODE) != 0 false

which means that your CELLID and LAC are valid, whereas your MCC & MNC are invalid. This is only a very initial guess though. I need to investigate this further.

The values seem to be:
const uint RIL_PARAM_CTI_MOBILECOUNTRYCODE = 0x00000001;
const uint RIL_PARAM_CTI_MOBILENETWORKCODE = 0x00000002;
const uint RIL_PARAM_CTI_LOCATIONAREACODE = 0x00000004;
const uint RIL_PARAM_CTI_CELLID = 0x00000008;
const uint RIL_PARAM_CTI_BASESTATIONID = 0x00000010;
const uint RIL_PARAM_CTI_BROADCASTCONTROLCHANNEL = 0x00000020;
const uint RIL_PARAM_CTI_RXLEVEL = 0x00000040;
const uint RIL_PARAM_CTI_RXLEVELFULL = 0x00000080;
const uint RIL_PARAM_CTI_RXLEVELSUB = 0x00000100;
const uint RIL_PARAM_CTI_RXQUALITY = 0x00000200;
const uint RIL_PARAM_CTI_RXQUALITYFULL = 0x00000400;
const uint RIL_PARAM_CTI_RXQUALITYSUB = 0x00000800;
const uint RIL_PARAM_CTI_IDLETIMESLOT = 0x00001000;
const uint RIL_PARAM_CTI_TIMINGADVANCE = 0x00002000;
const uint RIL_PARAM_CTI_GPRSCELLID = 0x00004000;
const uint RIL_PARAM_CTI_GPRSBASESTATIONID = 0x00008000;
const uint RIL_PARAM_CTI_NUMBCCH = 0x00010000;
const uint RIL_PARAM_CTI_NMR = 0x00020000;
const uint RIL_PARAM_CTI_BCCH = 0x00040000;
const uint RIL_PARAM_CTI_ALL = 0x0007ffff;

This is going to complicate things...

Edit:
I just tested this on my phone by modifying the tester app on the first page (it now works on Smart Phones as well, plus it will indicate whether each parameter is valid - the device is polled every 5 seconds). As before, this one is a .zip, not a .cab, since this is just a test app.

All four of the parameters which I receive are valid, but I presume yours won't be.
The question is, whether your MCC & MNC are always invalid, or just some times. And what causes them to be invalid?

This will affect the main app in that the web request should only be made if all four parameters are valid.

dzalbo
18th June 2008, 06:09 PM
Edit:
I just tested this on my phone by modifying the tester app on the first page (it now works on Smart Phones as well, plus it will indicate whether each parameter is valid - the device is polled every 5 seconds). As before, this one is a .zip, not a .cab, since this is just a test app.

All four of the parameters which I receive are valid, but I presume yours won't be.
The question is, whether your MCC & MNC are always invalid, or just some times. And what causes them to be invalid?

This will affect the main app in that the web request should only be made if all four parameters are valid.


Just tried it and the results are still the same.
My LAC is constant and valid
My CellID is constantly changing (even if I move my phone just 5 cms hehehe)

MCC & MNC are constant and invalid...

I assume that my provider could change something as I was using a Navizon application previosly and it was working perfect at my current location, while today it stopped locating with my phone as well..

I am heading home from the office and will try to see if RIL works ok at other locations on my way and a bit later with check it with other operator sim card. Hope, we'll get it work!

Thanks

jmat
19th June 2008, 07:37 AM
cell id program uploads cell tower/etc data to web server
webserver looks it up in mysql database, if i already have this one recorded, it just adds an entry to a tracking table and exits; if not.. continues.
using the mnc, mcc, lac, and cid, it queries google to get the latitude/longitude of the tower; if google comes back with valid data... continue.
using the free API at www.ibegin.com (free for less than 100 queries a day) server sends latitude/longitude into the reverse geodecoder, getting the closest intersection; saves all of this data into the database lookup table


ibegin.com's geocoder is rather accurate. In fact, it found the cell tower near my home to the EXACT address posted on the sign out front. :)

Another script runs every few minutes and looks at the location, if it's changed (zipcode), it updates my Twitter location (http://twitter.com/xtex) automatically using the Twitter API (update_location attribute). Mostly pointless, but it's just a geek toy.

I have a lot of other things I use it for, but I'm not posting 'em here. :)

dzalbo
19th June 2008, 10:29 AM
Just tried it and the results are still the same.

I am heading home from the office and will try to see if RIL works ok at other locations on my way and a bit later with check it with other operator sim card. Hope, we'll get it work!

Thanks

Ok, looks totally insane.. but the problem keeps to be the same..

dwSize = 2147500037
dwParams = 28
dwMobileCountryCode = 29
dwMobileNetworkCode = 41
dwLocationAreaCode = 4026596920
dwCellID = 739638680
dwBaseStationID = 2496201084
dwBroadcastControlChannel = 23
dwRxLevelFull = 277728
dwRxLevelSub = 67877472
dwRxQuality = 4294953108
dwRxQualityFull = 1
dwRxQualitySub = 2496202248
dwIdleTimeSlot = 33524352
dwTimingAdvance = 277728
dwGPRSCellID = 67877472
dwGPRSBaseStationID = 1
dwNumBCCH = 33524352


you can see that it is total rubish...
if you look attentively some of the variables turn out to have the same value (dwRxLevelFull & dwTimingAdvance; dwRxLevelSub & dwGPRSCellID ; dwRxQualityFull & dwGPRSBaseStationID; dwIdleTimeSlot & dwNumBCCH ) which makes me think there's something totally wrong with RILCELLTOWERINFO structure in my version of ril.dll...

Strangely after severl reboots I made Navizon application work on my mobile and it gives proper coordinates in the result.. Unfortunately, they give no way to see the CellID and LAC information (as it is being encrypted before 'querying the navizon API). But at least that means there's a way to overcome this problem...

any ideas on that?

newb5000
19th June 2008, 11:54 AM
jmat: Glad you're finding the app useful. I've got the logging to local DB complete (no synchronization yet, though). I'm just testing it out myself before I release. Shouldn't sacrifice any battery life since the cells are logged at the interval as your web updates, and it's just an extra disk read / write.

dzalbo: Are you using Dale Lane's code or your own?
The first thing that worries me about the structure you posted is the dwSize - it's actually supposed to be cbSize. There is no way that the structure size is 2147500037. My cbSize is 140. An incorrect structure would definitely mess up all the other information.

According to the docs (http://msdn.microsoft.com/en-us/library/aa921533.aspx) the structure looks like this in Windows Mobile 6 (in C++):
typedef struct {
DWORD cbSize;
DWORD dwParams;
DWORD dwMobileCountryCode;
DWORD dwMobileNetworkCode;
DWORD dwLocationAreaCode;
DWORD dwCellID;
DWORD dwBaseStationID;
DWORD dwBroadcastControlChannel;
DWORD dwRxLevel;
DWORD dwRxLevelFull;
DWORD dwRxLevelSub;
DWORD dwRxQuality;
DWORD dwRxQualityFull;
DWORD dwRxQualitySub;
DWORD dwIdleTimeSlot;
DWORD dwTimingAdvance;
DWORD dwGPRSCellID;
DWORD dwGPRSBaseStationID;
DWORD dwNumBCCH;
BYTE rgbBCCH[MAXLENGTH_BCCH];
BYTE rgbNMR[MAXLENGTH_NMR];
} RILCELLTOWERINFO;

However, the one that I'm using for the app is (in C#):
public class RILCELLTOWERINFO
{
public uint cbSize;
public uint dwParams;
public uint dwMobileCountryCode;
public uint dwMobileNetworkCode;
public uint dwLocationAreaCode;
public uint dwCellID;
public uint dwBaseStationID;
public uint dwBroadcastControlChannel;
public uint dwRxLevel;
public uint dwRxLevelFull;
public uint dwRxLevelSub;
public uint dwRxQuality;
public uint dwRxQualityFull;
public uint dwRxQualitySub;
public uint dwIdleTimeSlot;
public uint dwTimingAdvance;
public uint dwGPRSCellID;
public uint dwGPRSBaseStationID;
public uint dwNumBCCH;
}

rgbBCCH and rgbNMR are missing, but it still works just fine. The RIL layer probably detects the structure size that you send in and populates the relevant information into your structure. This is a long shot, but maybe you should try add rgbBCCH and rgbNMR, and see what happens? Edit: Removed another suggestion because it wouldn't have helped.

My result looks like this (with valid numbers instead of xxxxx :) ):
cbSize 140
dwBaseStationID 0
dwBroadcastControlChannel 0
dwCellID xxxxx
dwGPRSBaseStationID 0
dwGPRSCellID 0
dwIdleTimeSlot 0
dwLocationAreaCode xxxxx
dwMobileCountryCode xxx
dwMobileNetworkCode xx
dwNumBCCH 0
dwParams 15
dwRxLevel 0
dwRxLevelFull 0
dwRxLevelSub 0
dwRxQuality 0
dwRxQualityFull 0
dwRxQualitySub 0
dwTimingAdvance 0


One last thing you can maybe post is the values of the RILRESULTCALLBACK parameters.
Mine are:
dwCode 1
hrCmdID will always be different since it's a pointer
lpData will always be different since it's a pointer
cbData 140
dwParam 0

dzalbo
19th June 2008, 05:14 PM
One last thing you can maybe post is the values of the RILRESULTCALLBACK parameters.
Mine are:


dwCode 3
hrCmdID will always be different since it's a pointer
lpData will always be different since it's a pointer
cbData 4
dwParam 0

and yeah, I am using Dale Lane's code

newb5000
19th June 2008, 06:25 PM
We've almost solved this.

dwCode == 3 means that an error is occurring during the API call.
cbData == 4 means that the size of lpData is 4 bytes, i.e. an int. So trying to marshal 4 byte data into RILCELLTOWERINFO would obviously produce incorrect results.
lpData should contain the error code.
I need to figure out how to map the error codes, but while that's happening,
what is the value of:
Marshal.ReadIntPtr(lpData).ToInt32()

If I had to guess, it might have something to do with the app not being signed and it not having permissions to get the cell tower info.

I cannot reproduce this on my device - even if I put my phone in flight mode, I get dwCode == 1 (success), with the cell data prior to the flight mode switch, which is why I need your input.

Edit:
This might help as well:

Marshal.ThrowExceptionForHR(Marshal.ReadIntPtr(lpD ata).ToInt32())

dzalbo
19th June 2008, 07:13 PM
newb5000, thanks for the idea..

I will play with it application signing tomorrow and I will post an update here...

So far, I think that it you must be right with your guess as I was already having some bugs and problems with application signing on my device...

acedish
22nd June 2008, 02:25 PM
Thanks Newb, Just installed it last night on a Samsung Blackjack WM6 Standard and have it logging to a MS SQL database. I do have 2 questions,

Is it posibble to see all the towers the phone sees or just the one its connected to?
Is the signal strength of the tower (RSSI) available?


Thanks Again,
ACE

newb5000
23rd June 2008, 12:24 AM
Hi acedish. Glad it's working. I did some searching last week regarding reading multiple cells at the same time.

It would be ideal to read more than two cells at once and use the signal quality from each tower to get a much more precise location estimate.

It seems the people that did get this right only got it working on their specific handsets.
I came accross the following methods (I haven't tried these, but did read the comments from different users in the postings):

Sending AT commands through the correct COM port.
Sending device specific commands using RIL_DevSpecific.
Apparently there is a specific chunk of memory on the device which contains info about multiple cells. Not only is this device specific but it can change when you upgrade your radio version, so this method is completely out.


I did not save the links, but in short, the method which the app uses seems to be the most device independent way of obtaining cell tower info - the shortfall is that you can only get information about one cell.
In order to read multiple cells at once, the code for doing this would potentially have to different for each device. The method of obtaining multiple cells from a device may or may not be freely available on the internet.
We'll probably need to go this route eventually as the app progresses.

I will do some more searching regarding this issue (and I encourage any other developers to do the same).

Regarding signal strength - I was surprised that RIL_GetCellToweInfo did not give me my signal strength for the current cell, as indicated in one of my previous posts (it was just 0). There definitely must be another way using TAPI or another RIL function though - I'll need to experiment. The thing that worries me about signal strength is that if we are to use it for approximating the current location, we must assume that a cell's coverage zone is circular, that the GPS co-ordinates of the cell are in the center of this circle, and that your phone has perfect line of sight to the cell. If we do make these assumptions, then it should not be that hard to map signal strength to distance from cell, but remember, Person A might be standing close to a tower and may get a weaker signal than a Person B standing further away from the same tower.

Edit: Yes, here it is (http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.status.systemproperty.aspx ): PhoneSignalStrength

dzalbo: Any luck with RIL_GetCellTowerInfo?

dzalbo
23rd June 2008, 09:14 AM
newb5000, yeah, thanks a lot!

I have managed to deal with the applicationg signing and now it seems to be working good!

I am planning to use this data in combination with Google cells data.. even though it's not quite official... Hope, they won't shut it down :)

dzalbo
1st July 2008, 11:37 AM
that's me again over here..

i actually made the how RIL routine work on my HP Windows CE device..

But still have all the stupid messed data on Samsung WM5


I was quite sure that the problem is in signing. So, I signed the application with Sample Privileged Developer certificate (from the SDK)..

but the data is still the same it used to be.. looks like signing is not the actual problem.. what do you think?

newb5000
1st July 2008, 04:45 PM
We need to see the error code that you get in lpData when dwCode == 3. Edit: lpData, not cbData.
What is the value of:
Marshal.ReadIntPtr(lpData).ToInt32()
and what happens when, for dwCode == 3, when you execute the following line?
Marshal.ThrowExceptionForHR(Marshal.ReadIntPtr(lpD ata).ToInt32())

Regarding you having signed your test app, it depends on what certificates are installed on your device.

Your device has a Privileged Certificate Store, and a Normal (or Unprivileged) Certificate Store.

If the certificate that you signed the app with is not present in either of these two stores, then it's almost like not having it signed (depending on device configuration, of course).

Mobile2Market is Microsoft's solution to allowing your apps to run on most, if not all, devices, since most devices have the Privileged Mobile2Market certificate in their Privileged Certificate Store, and all devices should have the Unprivileged Mobile2Market certificate in their Unprivileged Certificate Store. Just Google it and you'll see what it's about. I did actually email them asking what the process is on obtaining a Mobile2Market Unprivileged Certificate, but they referred me to VeriSign or Geotrust. On VeriSign's site I saw a figure of $350, with annual fees, which is what discouraged me from pursuing this further, since this app is free software.

The above is the ideal way to go, but there are other ways, like for example, adding the certificate that you signed the app with to one of the stores on your device. I haven't tried this myself and don't have any links, but the procedure is available via Google. This, however, is not what I would want users to go through in order to use the app, because it doesn't make for a good user experience. But for testing purposes I'd recommend it.

Also, from what I read, most WM5 Standard devices are set to two-tier mode, whereas the Pocket PCs are set to one tier.
In one tier mode, you can basically run anything (and you may be prompted when trying to run an unsigned app). Two tier mode is more restrictive.
There are probably ways to change this, but again, more configuration required from the user.

Did you know that OEMs and / or operators have the choice to completely lock down your device so that THEY need to sign any apps that you might want to install? :D I don't think any OEM would want to do this, but it's still interesting.

Most of what I typed here is from this page (http://msdn.microsoft.com/en-us/library/ms839681.aspx).

edwardfrench
7th July 2008, 04:47 PM
I'm interested in using the utility to log cellid then post-process, what I don't think I have access to is a server that can collect all those http get requests and log them for me nicely (I'm sure this is trivial for lots of people!). I thought I had a perfect solution for me- google spreadsheets has a handy "form" tool which converts simple lists on spreadsheets into web forms. However this only seems to accept HTTP post requests. Any ideas how I could fix this gap?

iso|ated
7th July 2008, 05:23 PM
Hi there,
has anybody managed to get a list of cells with strength?
If yes any ideas pm(saulius@myeweb.com) or here.

Another question, if a device provides such info (some kind of program), is there a way i could read the same data?

AJenbo
8th July 2008, 01:18 PM
Hi, for some reason i can't get the normal builds of this app to work, they just get the spinning wheel going in to infinity.

cellidupdater_0.2_smartphones.CAB
did load but last update is Never :(

I'm using wm6.1 CF3.5 on HTC Universal and get the same result on 3G and GSM networks.

newb5000
8th July 2008, 01:31 PM
@edwardfrench: Do you need to do post-processing on the cell info in real-time? If not, then the next update to the app will be that it keeps a copy of all unique cells visited on the phone and then this data can be synchronized with another desktop app. I can easily add an "Export to Excel" feature on the desktop app. I was supposed to release the next version some time back, but the synchronization part was much more difficult than I anticipated (plus there were other factors prohibiting me from working on the app).

@iso|lated: what do you mean by strength of the cells? if you mean accuracy radius, then this data is available via the (unofficial) Google API - typically it's 5000 meters. I added code to query the Google API to the desktop portion of the app, but I'm still wondering if it's a good idea because if many users start querying the API, Google might change / remove it. I'm going to leave it in for now.

Without making a firm commitment, I can say that the update should be ready by Sunday this week.

newb5000
8th July 2008, 01:43 PM
@AJenbo: When you launch the app, you see a spinning wheel before the main screen opens, then this spinning wheel disappears when the app is loaded. Then, the Updater Status should read "Not Started". Once you configure the app and press Start, you should see another spinning wheel for a second, afterwhich the Updater Status should read "Started" and the spinning wheel should disappear.
I presume the spinning wheel that you see is after you press Start and it never goes away? What does the Updater Status say after you press Start and wait for a second?

One thing you can check is in \\Program Files\CellID Updater or \\Storage Card\Program Files\CellID Updater (depending on where you installed the app), there is a file called cidlog.txt. If it does not exist, then the service has not logged any errors, but if it does, the contents can give us a clue to what went wrong.

astromex
8th July 2008, 02:15 PM
@iso|lated: what do you mean by strength of the cells? if you mean accuracy radius, then this data is available via the (unofficial) Google API - typically it's 5000 meters. I added code to query the Google API to the desktop portion of the app, but I'm still wondering if it's a good idea because if many users start querying the API, Google might change / remove it. I'm going to leave it in for now.

I wouldnt worry its hardly a big secret. Google have blogged it themselves even.

http://googlemobile.blogspot.com/2008/06/google-enables-location-aware.html

LPChris
9th July 2008, 09:38 AM
My only question to newb, if you won't give out the source, can you at least outline how you got it running as a service? I've never developed anything serious for WM before and i'm not sure if it's a simple task or not.

dzalbo
9th July 2008, 10:03 AM
My only question to newb, if you won't give out the source, can you at least outline how you got it running as a service? I've never developed anything serious for WM before and i'm not sure if it's a simple task or not.

http://msdn.microsoft.com/en-us/netframework/bb693461.aspx

http://msdn.microsoft.com/en-us/library/ms913956.aspx

newb5000
9th July 2008, 01:29 PM
I don't use CeRunAppAtTime or CeRunAppAtEvent, although I've been considering CeRunAppAtTime for some time to wake the device to send out web requests (have it as a configurable option).

To write a proper service for Windows Mobile (I researched this extensively), you need to write it in Native Code. You cannot write a service using the .NET Compact Framework. Then, you need to sign the service and add some registry values - I don't have a code signing certificate either. So that option was out - I wanted to use .NET CF.

Writing it as a normal console application was also not an option, because you would lose the messaging functionality that Windows Forms apps provide - i.e. there is no WndProc. I wanted to send windows messages to and from the service / configuration utility to receive Last Update Time & Last Error from the service, indicate to the service that configuration has changed, and so on. There are other ways for inter-process communication, like WCF (which requires .NET CF 3.5), but I wanted to stick to .NET CF 2.0 since most users have this installed.

Lastly, proper services get loaded by services.dll (I forget if this was the exact dll), which is not subject to the memory management of Windows Mobile. The service for the app had to be able to survive the memory management of Windows Mobile, but could not get loaded as a service since it was not a native dll. Don't have any links on hand about this, but if you do a quick Google search, you'll see that there are certain threshold values where Windows Mobile starts gracefully closing or killing apps (but not services or drivers) when the device starts to run out of memory.

The solution? Pavel Bansky wrote an excellent article (http://bansky.net/blog/2008/04/services-for-windows-mobile-in-managed-code/) on these issues. I used his code as the basis. Only problem for me was that his code only had one way communication from the configuration utility to the service, but not visa-versa. See this post (http://blogs.msdn.com/netcfteam/archive/2005/05/23/421143.aspx) (and related links) on how to hook window messages, which is what I used to enable service to config utility communication.

All you need after that is to ensure that a shortcut to the service gets created in \Windows\Startup when the CAB is installed.

So to summarize, it might seem like a daunting task at first, but after you start to understand the concepts, it's not hard.

newb5000
10th July 2008, 10:29 PM
Guys, I've been losing sleep over a new feature that I've been working during the past few days. All I'm going to say is that I'm really amazed, as a developer, that this can be achieved.

I'm not going to give away what it is yet, but all I can say is WOW. This new API that I'm playing with is simply amazing. Still need to add to it to make it useful, but I'm very happy with what I've achieved so far :D


Edit: Ok, I couldn't resist. I blurred out all sensitive information, but left the pushpins unblurred.

khaytsus
11th July 2008, 04:31 AM
Guys, I've been losing sleep over a new feature that I've been working during the past few days. All I'm going to say is that I'm really amazed, as a developer, that this can be achieved.

I'm not going to give away what it is yet, but all I can say is WOW. This new API that I'm playing with is simply amazing. Still need to add to it to make it useful, but I'm very happy with what I've achieved so far :D


Edit: Ok, I couldn't resist. I blurred out all sensitive information, but left the pushpins unblurred.

:o

More accurate positioning? :D

LPChris
11th July 2008, 07:25 AM
Hey newb, I've set up my solution like the guy in the blog post you sent did, however when I deploy the app and hit the button to start the service it throws a general exception on the proc.Start(). Did you run into this at all?

newb5000
11th July 2008, 12:39 PM
@khaytsus: Not yet, no. I will be revisiting triangulation after I finish off what I'm working on and try to overcome the limitation that only one cell can be read at a time.

What I've achieved so far is synching the logged cells from device to desktop and looking up their co-ordinates via the Google web service using a desktop app that I wrote. This app then plots all cells as pushpins in Microsoft Virtual Earth.

Then, the idea with Areas is that one can create a rectangle which encapsulates a few cells, for example, one can create an area called "Work", which consists of four cells, and another called "Home" with three cells.

The idea with Events is that when the device detects that you are in the "Work" area, one or more actions can be performed, like switching your phone to silent. When the device detects that you are "Home", it can possibly switch on your Bluetooth connection, sync with your desktop, then switch off the connection. That is the goal, but it's far from complete.

@LPChris: It worked first time for me. Just make sure that the service executable and config executable are in the same folder and that you use Path.Combine(Path.GetDirectoryName(Assembly.GetExe cutingAssembly().GetName().CodeBase), "ServiceExe.exe") as the file path when you start the process.

andyb2000
11th July 2008, 04:38 PM
Hi folks,
Firstly, thanks for this handy little app, I'm gonna use this to talk to my home automation (at present I use bluetooth which is less than accurate).
But, is it setup to not operate when the device goes into standby, and can this be changed?

At present it happily sends location information up to my server when its on, but as soon as I put it into standby, or it times out and goes into standby itself, the app stops.

Can anyone advise?

newb5000
11th July 2008, 05:12 PM
It's not setup to stop when the device goes into standby, rather the OS stops the app and the OS resumes the app when the phone goes out of standby.

Apart from preventing the phone from going into standby, there is another option: CeRunAppAtTime, which will schedule an app to run at a certain time.

One must be aware of what the consequences of this are:

Your device will constantly wake up every X seconds or minutes to send out an update (it will drain battery quicker)
There is a way to instruct the OS to not turn on the screen when this happens (to be confirmed)
I hope that there is a way to tell the OS to go back to sleep once the web update is done. If not, that means that if the update interval for the web updates is more frequent than the timeout value of your device to go to sleep, then your device will never go to sleep.


What have you got the update interval for web updates set to, out of curiosity?

I'll implement it and it will be configurable, of course, so those who prefer to send out updates only when their device is on and not automatically wake the device, can chose to do so.

It will be interesting to see how much this affects battery.

andyb2000
11th July 2008, 05:26 PM
Ahh, I see.
I didn't realise it was a function of the OS that couldn't be prevented.
Interestingly I've got the timer on default of 30 second uploads, and the device does indeed still go back into standby, so it doesn't look like the application keeps the device on which should help some people out.

I'm interested if the device can be woken up without the screen, since this should keep the consumption pretty low. I'm trying to think what other apps I use that may have this sort of behaviour, one that I thought about was kaisernotify which is constantly running as its setting the LEDs to do what I want them to, I'm wondering how that keeps polling/updating the LEDs depending on the device state.

Not the ideal solution I was after unfortunately, as I'd like to not have the device waking up (wake-up without screen would be a compromise that would be ok).
All in all a nice little app this, which makes me wish I'd stuck to VB/.net/coding just to knock together little things like this.

newb5000
11th July 2008, 05:40 PM
CeRunAppAtEvent also exists, so the app that you mention might use this, or some other method.

CeRunAppAtEvent - launch an app when some event occurs, eg. the phone rings. Edit: Appologies, that is not quite true about the phone ringing part. I mixed up Microsoft.WindowsMobile.Status with CeRunAppAtEvent
CeRunAppAtTime - launch an app at a specified time. the app can then schedule itself to run again at the next interval.

There is one more alternative that I came across, but I need to dig up the link again. Apparently (I have not tested this), the device can also notify an app when the current cell changes, but only as of Windows Mobile 6. That function only returns Cellid / Lac though, not Mnc / Mcc, although that shouldn't be a problem.

In any case, I'll get back to you over the weekend once I've researched and tried the various approaches :)

andyb2000
11th July 2008, 05:43 PM
Cool, really appreciate your work on this as I'm sure others do :-)

I'll watch this space!

khaytsus
12th July 2008, 03:38 AM
@khaytsus: Not yet, no. I will be revisiting triangulation after I finish off what I'm working on and try to overcome the limitation that only one cell can be read at a time.

What I've achieved so far is synching the logged cells from device to desktop and looking up their co-ordinates via the Google web service using a desktop app that I wrote. This app then plots all cells as pushpins in Microsoft Virtual Earth.

Then, the idea with Areas is that one can create a rectangle which encapsulates a few cells, for example, one can create an area called "Work", which consists of four cells, and another called "Home" with three cells.

The idea with Events is that when the device detects that you are in the "Work" area, one or more actions can be performed, like switching your phone to silent. When the device detects that you are "Home", it can possibly switch on your Bluetooth connection, sync with your desktop, then switch off the connection. That is the goal, but it's far from complete.


Aha, gotcha.. phoneAlarm does this, one of the first things I purchased coming from a Treo and being spoiled by ProfileCare there, automatic profile switching based on time, meetings, etc... phoneAlarm will also switch profiles based on location or "leaving location", as you're talking about above. However, phoneAlarm is about $30 so I can see this being very useful for some folks. :)

AJenbo
14th July 2008, 02:00 PM
@AJenbo: When you launch the app, you see a spinning wheel before the main screen opens, then this spinning wheel disappears when the app is loaded. Then, the Updater Status should read "Not Started". Once you configure the app and press Start, you should see another spinning wheel for a second, afterwhich the Updater Status should read "Started" and the spinning wheel should disappear.
I presume the spinning wheel that you see is after you press Start and it never goes away? What does the Updater Status say after you press Start and wait for a second?

One thing you can check is in \\Program Files\CellID Updater or \\Storage Card\Program Files\CellID Updater (depending on where you installed the app), there is a file called cidlog.txt. If it does not exist, then the service has not logged any errors, but if it does, the contents can give us a clue to what went wrong.

I aited for 45 minuts and never got to the main screen part, i didnt install it, i just manualy extracted the files and i don't see a cidlog.txt :(

newb5000
14th July 2008, 04:33 PM
I aited for 45 minuts and never got to the main screen part, i didnt install it, i just manualy extracted the files and i don't see a cidlog.txt :(

You really should install it via the CAB file. In the next update, there are going to be registry settings which are created by the CAB file. It will be a really tedious process for you if you try to extract the files and do everything manually.

Have you tried installing it via the CAB file? Did you encounter the same problem?




@andyb2000: I have some good news and bad news.

I managed to get the test app running even when the device is suspended (I manually suspended my device, and checked whether a certain counter was incremented while the device was asleep). The test app doesn't use a data connection, so I didn't test whether the data connection worked when the cell tower info was retrieved (I didn't have enough time to test it). The screen did not turn on while the test app was running - which is good (it's a more complicated process, which I'll explain in detail in another post).

The problem is that the device never goes to sleep using the new method. Only if you manually suspend your device does it go to sleep, but no automatic sleep - big problem.

The method I used (for any developers out there) is CeSetUserNotificationEx with named events, since CeRunAppAtTime and CeRunAppAtEvent are obsolete.

Maybe it's possible using a hybrid timer, i.e. use a regular timer when the device is awake, and use CeSetUserNotificationEx when the device is asleep. I'll carry on researching this, but it will take some time...

newb5000
14th July 2008, 08:29 PM
I decided to share the code of the Timer that I was creating based on CeSetUserNotificationEx and named events. It is by no means complete, since the timer interval cannot be changed after the object is constructed, plus the device does not go to sleep with this timer (probably because the system idle timeout value is greater than the timer interval).

I'll work on it some more this week.

dzalbo
15th July 2008, 09:39 AM
I decided to share the code of the Timer that I was creating based on CeSetUserNotificationEx and named events. It is by no means complete, since the timer interval cannot be changed after the object is constructed, plus the device does not go to sleep with this timer (probably because the system idle timeout value is greater than the timer interval).

I'll work on it some more this week.

thanks for that!

That's definitely a great help!

topTwat
15th July 2008, 04:50 PM
Hi

This site provides some useful info on java to do this. Maybe of interest to some people:

http://forum.openhandsetdevelopers.com/google-maps-with-my-location-my-location-t19.html

Brgds

topTwat
15th July 2008, 08:52 PM
Has anyone founda php4 compatible version of http://www.witracks.com.br/gmaps.txt

im having problems with this, and have tried replacing file_get_contents with the below code, with no luck. Any Ideas?

===============================================

$host = "www.google.com";
$path = "/glm/mmap";

$fp = fsockopen($host, 80);
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/binary\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);

while (!feof($fp)) {
$str .= fread($fp,128);
}
fclose($fp);

newb5000
18th July 2008, 06:36 PM
@andyb2000: I finally managed to get the app to run even with the screen off. Took a totally different approach. The downside is that your device will not go into sleep mode when the app is running (which is pretty much always :)), but will rather go into "Unattended" mode (WM5 and later).
It's the same method that push email uses, so if you have push email enabled, you shouldn't see a notable difference in battery life. If you do not have any apps which request that your device go into Unattended mode instead of Standby mode, then you will see a difference in battery life. How much, I don't know - we'll have to see through testing.

I need to clean up the code a bit first and allow Unattended mode to be enabled/disabled dynamically (depending on the configuration). I'll post the code for the developers on how to do this, plus an update to the app as soon as I'm done.

The desktop portion is almost complete as well.

I'll probably need to start a new thread so that all updates can be in the first post.

andyb2000
18th July 2008, 09:07 PM
wow!
You have been busy, I'm really impressed with how you've been working and learning on this project, and that sounds like you've hit upon exactly the solution I was hoping for.

My device must already be in this unattended mode, so that sounds fine, and yep happy to test and report back for power usage, etc, sounds good!

I'll look forward to more updates, if you want it tested before posting or anything else just drop me a note. I'll also PM you as want to see if there is anything I can help you out with after all your efforts :-)

dzalbo
21st July 2008, 09:10 AM
newb5000, great job!

Thanks for your efforts :)

w000ter
21st July 2008, 11:00 AM
Wow excellent work newb5000! Looking forward to your app! :D

newb5000
21st July 2008, 12:09 PM
The code for unattended mode. So far it's working just fine, and it can be dynamically enabled / disabled. Remember, this is only for PocketPC - Smartphones do not have a "suspended" mode. Let me know if you find any problems.

Some more info on unattended mode:

Power to the System (http://blogs.msdn.com/windowsmobile/archive/2005/08/10/450186.aspx)
Power to the PocketPC (http://blogs.msdn.com/windowsmobile/archive/2006/08/16/702833.aspx)
Power to the People (http://blogs.msdn.com/windowsmobile/archive/2005/08/01/446240.aspx)
Power to the Developers part 1 (http://blogs.msdn.com/windowsmobile/archive/2005/08/03/447404.aspx)
Power to the Developers part 2 (http://blogs.msdn.com/windowsmobile/archive/2005/08/11/450591.aspx)

The code is attached.

newb5000
21st July 2008, 02:38 PM
Aarg. I have unattended mode complete, but I ran into a problem when syncing the device database and desktop database - if you delete the database on the device, you cannot upload all the data from the desktop again. Problem. This will affect the database structure.

So, to not waste any more time, I'm attaching an update which includes "unattended" mode, plus a number of fixes, but logging to a local database will be disabled for now, until I sort this out.

So, changelog for 0.4:

Added unattended mode for PocketPC
Fixed "apply" or "save" button not refreshing the service settings when clicked for the first time.
Made changes to the service consume a bit less battery life.
Added error message in PocketPC version preventing it from being run on SmartPhone.
Added error checking when retrieving cell info - the Last Update field in the app will now say RILApiException if it cannot successfully get the cell info (see previous discussions with dzalbo).
Added support for logging unique cells to local database + syncing, but it is disabled for now.


Edit: PocketPC version withdrawn. Please get it from the next page.

newb5000
21st July 2008, 03:33 PM
Hi guys,

Just wanted to tell you what the expected behavior should be when unattended mode is enabled.

As previously mentioned, this only applies to Pocket PCs, since Smartphones don't go into suspended mode.

So, on your Pocket PC, if you have enabled unattended mode in the app, the following should happen:

When your device times out because of inactivity (and the screen switches off), it will go into unattended mode instead of suspended mode, allowing the app to keep running, as well as your data connection to be kept alive.
The same should be observed if you hit the power button on the device, which usually suspends it (if unattended mode is enabled, hitting the power button will make it go into unattended mode, rather than suspend mode).
While in unattended mode, the app periodically resets the system idle timer so that the device does not go into suspended mode, from unattended mode. Without resetting the idle timer, the device does indeed transition from unattended to suspend mode.
The system idle timer is not reset if the device is not in unattended mode, otherwise your screen would never turn off due to inactivity.


Please let me know if you find any problems.

andyb2000
21st July 2008, 04:08 PM
Nice work.

I've installed and got the app setup to run using unattended, so will report back in a day or so with the results on battery life (I'm sure mine already uses this mode so I'll probably not see any change there) and to confirm that it continues to upload, etc on change of cell, etc.

Cheers!

khaytsus
21st July 2008, 05:58 PM
Could you quickly explain the impact of Unattended vs Suspend in terms of battery life (any anything else... any latency concerns, or interaction with other software such as S2U2, FlexMail, IM+, stuff like that?)

I've read your posts on it, but I'm not sure what conclusion to draw for the 'bottom line' for the end user. :)

EDIT: Aha, I see your note in the application itself, mentioning it might use more battery. But if you're already using background apps (IM+, Flexmail with IMAPD Idle, etc), there is probably no difference? Does it matter if CellID itself is in unattended mode with these types of apps?

I'm running it regardless, just thinking of questions that I have and others might be curious about too. :)

newb5000
21st July 2008, 07:07 PM
In one of Mike Calligaro's posts, he talked about Suspended vs Unattended, since SmartPhones don't have a Suspended state, i.e. they are always on, whereas PocketPCs do have a Suspended state.

SmartPhones have smaller screen sizes and thus can afford to be "always on". PocketPCs have larger, touch screens, with large backlights, so Suspended is the way that they save battery.

There are advantages and disadvantages. For instance, when resuming a PocketPC which was in the Suspended state, you notice a lag until everything redraws and powers up (2 or 3 seconds for me). Waking the device from Suspended mode is actually a lot of work since a lot needs to be resumed. If the device was in the Unattended state, there is no need to wake up since the device is already awake. No drivers need to be resumed, no running processes need to be resumed. Thus (and I did notice the difference), when pressing the power button to turn the screen on from Unattended mode, it's pretty much instant. So resuming from Unattended uses less battery than resuming from Suspended.

You must remember, that in unattended mode, most things keeps running. All it takes is one app to say to the OS that "I need unattended mode", then the OS will override the behavior of the power button and what happens when the system idle timeout is reached. So if you already had Push Email or Windows Live Messenger running all the time, then they have already instructed the OS to go into unattended mode instead of suspended mode. In that case, you should not see a difference in battery life.
The difference in battery life is when CellID Updater is the only app that requests unattended mode, i.e. you did not have any other apps requesting unattended mode before you enabled that option in the app.

That difference is going to be very user and device dependent. The reason for this is since most things keep running in unattended mode, even CPU intensive apps keep running. It will definitely depend on which apps you have installed, how many CPU cycles each app uses and how much the ODM optimized drivers for the PocketPC. In general, if an app "polls", i.e. it checks for something every x amount of seconds (or milliseconds), that burns battery. If an app displays an animation, that burns battery. If the app continues to display the animation even though the screen is off, that will still burn battery life. So as an example, CellID Updater might request to run in unattended mode and not display any animations, but other apps might continue to display animations, which is bad.

I've tried to make the app more "battery friendly" since the last update and will continue to do so, but the battery life really depends on which apps you have installed, the current ROM, radio, etc.

My only advice (besides you experimenting with the option enabled / disabled) is that if you already have Push Email or the messenger app running continuously, then go ahead and enable this option. You shouldn't see a difference in battery life. Otherwise, you should determine if sending web updates about your current location is more important to you than battery life. I for example carry my usb cable with me in my laptop carry bag to work so that I can charge at work. I have a car charger in the car and a mains charger at home, so I can pretty much charge my device everywhere.

The nice thing is that unattended mode is configurable in the app, so if you know that you won't be able to charge over the weekend, for example, it might be better to disable that option (maybe temporarily).

khaytsus
21st July 2008, 07:35 PM
Excellent information, thanks for typing all of that out! This whole thread is great insight into how WM works. I had no idea how different 'Smartphone' is vs 'Professional' until several weeks into owning my Kaiser/Tilt, and I'm sure I still know very little currently. :)

Sounds like given my usage of FlexMail already puts the phone in Unattended mode, so I'm going to run with it in that mode for now to help see if there are any bugs associated with it.

I, too, tend to charge mid-way because of using online imap and IM, but I'm generally okay as long as I'm on EDGE. HSPA is a much different story (charge 3x a day? Bleh..)

So if I need to really extend battery life, I'll turn off the Unattended mode (after exiting my online apps, etc). My current 'idle' power usage is about 22ma, so that's about 60h with the previous version. Honestly I don't know if it was already in Unattended or not, is there any way to check that? Would be interesting to see. I have a bunch of random stuff installed, but only a handful I think run periodically that could put it into that mode.

Cheers!

newb5000
21st July 2008, 07:50 PM
I think the only way to check (from the user perspective) is to observe the time it takes for "everything to return to normal" when you turn on the device display. If it is a bit sluggish, your device was suspended. If it's instant, then it was unattended. I'll write a little app that logs the power state transitions so one can see exactly what is going on. This is interesting.

Unfortunately I found a bug in the latest update :(

The system idle timer stops resetting if certain other power notifications are communicated to the app in unattended mode, so the device ends up going into suspended mode after a while.

I'll edit this post shortly with an update to the PocketPC version and the code.


Edit: Ok, it has been running for 11 mins now without the device being suspended and the screen is off. Letting it run a little longer.

Edit2: Right, 25 mins of testing and it's working as expected.

Changelog (from 0.4 to 0.4_fix)

Device was going into suspended mode after a while, even if unattended mode was enabled. Fixed.


For the developers, just change the ProcessPowerBroadcast method to the following:
private void ProcessPowerBroadcast(POWER_BROADCAST pbr)
{
bool? isUnattended = null;
switch (pbr.Message)
{
case PowerEventType.PBT_RESUME:
isUnattended = false;
break;
case PowerEventType.PBT_TRANSITION:
if ((pbr.Flags & PowerState.Unattended) == PowerState.Unattended || pbr.SystemPowerState.ToLower() == "unattended")
isUnattended = true;
else
isUnattended = false;
break;
}
if (isUnattended.HasValue)
{
if (isUnattended.Value && !unattended)
{
unattended = true;
timer.Change(5000, IdleResetInterval);
}
else if (unattended && !isUnattended.Value)
{
timer.Change(Timeout.Infinite, IdleResetInterval);
unattended = false;
}
}
}

andyb2000
22nd July 2008, 10:13 AM
Righto,
Reporting back in as had the app (latest) installed and running. At first it appeared to be working fine, I had it on my desk and uploading cell information (my cell switches about every 15 mins, I'm guessing I sit between two cells)

I got home, and it was still uploading, etc, so all looked fine, but overnight/this morning I notice there haven't been consistant uploads. I'll show you what I mean:


149.254.xx.xx - - [21/Jul/2008:20:30:51 +0100] "GET /g
149.254.xx.xx - - [21/Jul/2008:20:39:45 +0100] "GET /g
149.254.xx.xx - - [21/Jul/2008:21:00:37 +0100] "GET /g
195.x.xx.xx - - [21/Jul/2008:21:15:32 +0100] "GET /g
195.x.xx.xx - - [21/Jul/2008:21:20:03 +0100] "GET /g
195.x.xx.xx - - [21/Jul/2008:21:21:04 +0100] "GET /g
195.x.xx.xx - - [21/Jul/2008:21:52:07 +0100] "GET /g
149.x.xx.xx - - [21/Jul/2008:22:00:44 +0100] "GET /g
149.x.xx.xx - - [21/Jul/2008:23:23:04 +0100] "GET /g
149.x.xx.xx - - [21/Jul/2008:23:24:06 +0100] "GET /g
149.x..xx.xx - - [22/Jul/2008:04:41:21 +0100] "GET /g
149.x.xx.xx - - [22/Jul/2008:07:35:22 +0100] "GET /g
149.x.xx.xx - - [22/Jul/2008:07:43:24 +0100] "GET /g
149.x.xx.xx - - [22/Jul/2008:08:13:21 +0100] "GET /g


So the overnight ones I can understand as I've got the 'dont send if cell is the same' checked, so that'll be why I don't get many of them, but this morning I was sitting in the office at 8:50 and noticed no uploads. I then pressed power on the phone and immediately saw an upload. So perhaps it's not quite keeping awake when the phone is off or something?

Any way I can put on any debug or anything that can help diagnose??

I'll also post up my php scripts that I'm using shortly, that plots the cells onto google maps using a mysql database backend for logging, etc.

newb5000
22nd July 2008, 11:21 AM
Hi andyb2000,

The update that I published in the previous post should fix that. Can you retest with 0.4_fixed?

andyb2000
22nd July 2008, 11:25 AM
Sorry, should have mentioned I updated to the fixed version before going to sleep last night so it is running the fixed version

(also, could you perhaps display the current running version in the settings screen for easy reference?)

newb5000
22nd July 2008, 12:03 PM
Ah I see. Good idea about the version number in the settings screen.

I can send you the debug build that I use - it generates quite a lot of log messages and saves them to a trace file.

Will PM you shortly.

EDIT: I never knew that one cannot send attachments with a PM. Anyway, I'm attaching the debug version here.
Make sure you stop the service.
Replace cidservice.exe with the one contained in the .zip file. The executable is located either in "Program Files\CellID Updater" or "Storage Card\Program Files\CellID Updater" depending on where you chose to install it.
Then start the service.
Now, a file called trace.txt will be created in the same folder as cidservice.exe. It will keep getting larger and larger, unless you stop and start the service - then the trace file is recreated from scratch. If you can, let the service run overnight and do not stop it. Then in the morning, please send me the trace file (you can edit out the urls for privacy reasons if you want, but I need the rest of the information).

Another note - please don't open trace.txt on the phone - Word Mobile locks the file and the service will be unable to append to it.

Thanks for helping out!

andyb2000
22nd July 2008, 01:45 PM
lol, i didn't realise that either tbh!
Thats installed and running now so I'll post it over to you tomorrow after its had a chance to run/test things out.

Thanks!

khaytsus
22nd July 2008, 07:14 PM
I'm pretty confident I can confirm this as well, using Fixed with Unattended checked (but as we discussed, I was probably always in Unattended mode anyway).

I typically have a post hourly or more at my house, as there seem to be four towers in a circle around me, about 40% of the time I'm on Tower 1 or 2, about 10% of the time I'm on tower 3 or 4. So from my house, I routinely see one of four towers, and I tend to bounce around a lot. In fact I've even 'had' to write in some heuristics into my CGI to ignore a datapoint if it was one of the last two datapoints to reduce the redundant data from this.

And overnight, I only saw a handful of posts. I compared it to the last three nights, of which I see 10-11 overnight each night.

So not concrete evidence, but fits with what's already been observed.

newb5000
22nd July 2008, 11:14 PM
Thanks khaytsus.

So you're saying that you're seeing less updates with Unattended mode enabled, than with it disabled? That's really strange.

The trace file that gets generated from the debug version will show us if the app stops working at a certain time (every log entry is timestamped) and what the state of the app is when there is a power transition (for example, from On to Backlight off to Unattended), so we should be able to see why this is occurring.

You're welcome to try it as well if you like, using the instructions from the previous post. The more data the beter.

Personally, the way I tested the app today is that I set it to send out updates through my wifi connection "even if the cell is the same". I just use a server on the local network at work :D. After several hours, the app was still sending out updates. The trace file was around 300kb. I should note that I did power my phone on a number of times though (because of normal usage) so my tests would not be as accurate as an "overnight test".

newb5000
23rd July 2008, 12:15 AM
Here's that little app that I promised that will show you some of the power notifications that the OS sends out.

This app is not linked in any way to the cellid app. It will not request unattended mode, it just shows the transitions and battery notifications.

Enabling / disabling unattended mode in the main app should yield different results in this app (taking into account my previous posts).

What you'll be interested is if your device goes into the "suspended" state.

The app should work on WM5 / 6 PocketPCs and SmartPhones.

newb5000
24th July 2008, 08:50 AM
Hi guys,

I tested the app again last night.

What I did is, I started the service in one room, the phone went into unattended mode, I moved it to another room where I left it charging all night. I set the app to send out updates only if a new cell is encountered.
I was using WiFi to send out updates to one of my PCs.

[The reason I was using WiFi is that it's quite a job to set up DyDNS and get the correct routing in place so that I can expose my PC to the internet - I'm running a script on my router which routes traffic through multiple PPPoE connections. I will eventually set it up though.]

Anyway, so my phone was charging all night, sending out updates through WiFi.

According to the attached trace file (which has the URLs edited out), the app did not stop running at all, until I stopped it this morning. It did not send out many any updates though, but this could be due to the fact that the phone was in one position all night.

So what the trace file shows is that the phone did not go into suspend mode with unattended mode enabled and it kept checking for new cells all night.
I'll run it again tonight with the app set to send out updates even if the cell is the same.

I did find a small issue though - you may have noticed that you get a ThreadAbortedException when you stop the service - that's because if the service is busy with a web update and you press Stop, the thread responsible for the update is almost immediately stopped. I'll fix this in an upcoming update.

@andyb2000: Did you manage to generate a trace file?

PizzaRoll
24th July 2008, 10:25 AM
I am new to the world of the Kaiser and C# development on WM but when I was reading the above, I remembered seeing this function a few weeks ago. The function sets an event with windows and will wake the system from suspend. It might be valuable for those us who don't need to always be in unattended mode.

BOOL CeRunAppAtTime(
TCHAR* pwszAppName,
SYSTEMTIME* lpTime
);

http://msdn.microsoft.com/en-us/library/ms908103.aspx
http://www.codeproject.com/KB/mobile/WiMoAutostart.aspx

Any thoughts?
Is this a good idea and can it easily be integrated?

newb5000
24th July 2008, 11:25 AM
CeRunAppAtTime is obsolete and has been replaced with SetUserNotificationEx.

See one of my previous posts for an implementation using CeSetUserNotificationEx. I used named events instead of launching an app, which makes things much easier.

The first issue I had with this is that every device has a Real Time Clock Accuracy that it reports to the OS. If the device doesn't report it, then a value of 10 seconds is assumed (but it can be between 1 and 60 seconds). If you specify that an app or named event is to be run within the RTC Accuracy, then it is scheduled immediately, and not according to the time that you specify.
What this means is that if you're creating a timer based on CeSetUserNotificationEx, your timer interval cannot be less than or equal to the RTC Accuracy. This is not a big issue, but it could mean that your timer interval must be greater than 60 seconds (depending on the device).

The second issue which is more problematic, is that if your timer interval is less than the system idle timeout interval, then the device screen never turns off using this method. In fact, it seems that whenever an app is launched or a named event is set, the system idle timer is reset. That is a problem. This is the main reason why I didn't go with SetUserNotificationEx and instead went with Unattended mode and resetting the system idle timer only if in Unattended mode.

The third issue is that if your device is suspended and the time comes to launch the app or set the named event, the device wakes up for 15 seconds (I think it was 15). If your app (or any other app) does not set the system power state to some other value, the device will go back to suspend after the 15 seconds have elapsed. Now, is 15 seconds enough time? That depends. I've noticed some of the web requests can take up to 8 seconds. Before that, if the data connection is not active, if would take time to activate it. So a reliable method would be to always set the system power state to unattended, which would give you more time. But unattended mode also goes back into suspend mode after a certain time if the system idle timer is not reset. This can be solved programmatically, so it's not a major issue.

Also, remember, resuming the device from suspend mode is much more work for the OS than resuming from unattended mode. So, if your timer interval is in seconds, not minutes, then it's probably better to go with unattended mode, rather than CeSetUserNotificationEx. CeSetUserNotificationEx does make a lot of sense for something which does not occur that often (for example every 5 minutes or more) or something which should happen at a certain time (like an alarm), but for doing something every 30 seconds, my choice was unattended mode.

See this page (http://msdn.microsoft.com/en-us/library/ms908105.aspx) for the method and notes on RTC accuracy.

PizzaRoll
24th July 2008, 12:06 PM
It is clear why you decided against the functions. The only bad thing about the unattended mode is other programs do have a chance to consume cpu cycles and thus heavily effect battery life. I guess I will just have to be careful of what I install on my Kaiser.

Thanks for the info

newb5000
24th July 2008, 12:18 PM
Yes, that is true.

I guess it would be possible to implement a "hybrid" type of timer that, depending on the interval, uses unattended mode if, for example, the interval is less than (as an example) 5 minutes and uses SetUserNotificationEx if the interval is greater - but it will be quite time consuming to create, and testing would be a bit of a pain :D But yeah, something to consider for future updates. We definitely need to test unattended mode more, though.

The big question is: at what point does SetUserNotificationEx become more battery friendly than unattended mode? When the interval is 2 minutes? 5 minutes?

Unattended mode can be disabled in the app currently. Have you seen your battery life being affected when unattended mode is enabled? Is it severely affected?

Edit: Just wanted to add, that it is not difficult to make an app consume less battery life. .NET CF already has OnActivated and OnDeactivate events which can be used to start / stop animations, for example, as described by Mike Calligaro. Also, the code that I posted can also be adapted to notify an app when the power state of the device is "on". Any other power state means that animations should stop (even "backlightoff").
I'm sure that a lot of apps already have power saving features built in.

PizzaRoll
24th July 2008, 11:24 PM
Last night, i played around with the unattended mode and i lost about 25% of my battery in only 3 hours. Something mean is going on my Kaiser and pretty sure its not the program.
Typically, i check two email accounts about every 15 mins and with the program running in normal operation, there is NO impact on battery life. Plus i get the benefit of every time my device will wake up from suspend to do the email routines, your program will activate and update my position :) or at least that is what appears to happening.

I think for today im gonna switch back normal operations until i find out what is killing my battery so quickly. Ill let you know what i find out

adamkimber
25th July 2008, 12:18 AM
Hi Guys,

I've just come across this thread and thought I'd add my comments.

Unattended mode is definitely the right way to go here - I've been doing something similar with GPS rather than CellID for several years. Just in case you haven't, even with unattended mode you need to call SystemIdleTimerReset. The backlight timer is independant of the System Idle timer.

Feel free to have a look at www.wheresadam.co.uk

Not sending updates unless the CellID has changed is good as well to save data.

I'd suggest that knowingthe CellID you've been in and the power - and the CellID you are now in and the power will give you a pretty good idea of heading and a slightly more accurate location.

The next hurdle will be that, running at startup, GPRS can sometimes have problems. You'll need to initate a net connection first before doing anything using OpenNETCF.

Feel free to shout if you want any help or ideas or anything?

Adam

Disclaimer: I produce GPS CF applications commercially and so will help where I can but, as I'm sure you can appreciate, some things will cross over to be a breach of NDA / Conflict of Interest and so I won't be able to comment.

LeeCHeSSS
26th July 2008, 02:52 PM
I have had the program running in Unattended mode, and it seems to work pretty well. However I do have the impression that it stops sending updates to my webserver after roughly a day.

I have attached my trace log, so you can see if there's something wrong (I don't know what exactly it all means, but around 25-7-08 17:49:54 in my log file, the amount of Power Broadcasts seems to have increased a lot compared to the first part of the log).

acedish
27th July 2008, 09:18 AM
Using newb's app (which is very cool!!) I made a site at www.baeeo.com that will geocode users cellid and display it on Google maps. I am working on a facebook api as well so you can share your location with your facebook friends. I also created a simple API to the site to allow developers to build there on app like Newbs for other phones. (I am working on one for a Blackberry now)
I did however run into some glitches on a couple phones, a Blackjack I (upgraded to WM6) and Pantech Duo(WM6). The Duo received a RILException error and on the Blackjack it never displayed an error and would seem to lock up in start mode if I recall, i will check the details and post them here.
Newb if you can email me I would like to give you some credit on the baeeo site and also had a request.

Enjoy.
ACE

LeeCHeSSS
27th July 2008, 11:30 AM
Nice site, except that it doesn't work in Firefox :)

khaytsus
27th July 2008, 05:33 PM
I haven't signed in, but the front page works fine here.. Just jumps around quite a lot, but I get the impression that's intentional.

Looks like a great site for stalking, there's some plain hotties on there ;-)

acedish
27th July 2008, 06:36 PM
I corrected the issue for firefox so it should work now, thanks

newb5000
28th July 2008, 11:47 AM
@adamkimber: Thanks for posting. I'll give you a shout if I have any questions.

@acedish: Nice work! I'm glad that people are putting the app to good use. The possible error messages that one can get are the following:

RILException: This could mean that the device does not support the RIL layer. I get this error on emulators since they do not have a phone component.
RILApiException: The cell tower info could not be retrieved for some reason. This could be due to the fact that the app is not digitally signed and does not have sufficient permissions to perform its tasks (Smart Phones in particular).
WebException: The web update could not be completed. The host is not reachable using the current connection settings. Try access the URL in Pocket IE and see if that works. If it works in PIE, it must work in the app.
TypeLoadException: You shouldn't get this error because logging is disabled, but once it is enabled in a future update, you would get this error if SQL Server Compact 3.5 is not installed.
ThreadAbortedException: This will be fixed with the next update. Happens if you stop the service while a web update is happening.

A more detailed log of the last error is available in "Program Files\CellID Updater\cidlog.txt" or "Storage Card\Program Files\CellID Updater\cidlog.txt" depending on where you chose to install the app.
I'll send you an email shortly.

@LeeCHeSSS: Thanks for the trace file. I looked at it and think that after 25-7-08 17:49:41 the app was not registered for unattended mode any more. No idea why, but I can add some logic to possibly detect this.
Can you remember if your battery was critically low at some point? It could be that the OS does something extra when the battery is critically low (like force the device into suspend mode), but that is just a guess.
Also, it seems like you have another app running which wakes the device every (on average) 10 minutes or so. That could explain the three power transitions every so often after 17:49:41. I'll do some research and post an update which will hopefully fix the problem, but I'll need you to test it again, please :)

newb5000
28th July 2008, 03:26 PM
@LeeCHeSSS (and any others who wish to test unattended mode): Here is a newer build of the debug version. Same procedure applies as previously - ensure the service is stopped, replace cidservice.exe with the attached one and then start the service.
I'll need the trace.txt file after you're done testing.

This time, the urls are not logged, so you do not need to edit the trace file at all. Also added a bit more info in the trace file.

What I changed in this version is if a resume event is encountered, the app registers itself once again for unattended mode (because a resume event should not be encountered if in unattended mode).

Thanks for testing.

newb5000
28th July 2008, 05:04 PM
For any Smart Phone users who get a RILException or RILApiException error, could you try changing a registry value and see if that helps?

HKLM\Security\Policy\APIs\RILGSM\Default
The default should be 2.

Set it first to 1, then see if that helps.

I'm not sure whether a soft reset is required, I'd reset just in case.

If you still get the errors, try setting it to 0.


0 = OEM_CERTIFY_FALSE (Untrusted - No Trust Required)
1 = OEM_CERTIFY_RUN (User Trust Required)
2 = OEM_CERTIFY_TRUST (Kernel Trust Required)


This registry key isn't present on my TyTN II, so I presume it's Smart Phone only?

The necessary disclaimer: Changing registry settings on your device may mess things up :D

Source: http://www.teksoftco.com/forum/viewtopic.php?p=2586

LeeCHeSSS
29th July 2008, 11:38 PM
I'm pretty sure the phone was not low on battery when I ran the service for that trace log. The program that woke my phone is probably push mail, can't think of anything else that might be responsible.

Anyway, I will run your new build tomorrow and post the log after about a day :)

PizzaRoll
30th July 2008, 02:25 PM
newb5000,

Can you bring dwRxLevel in to the URL. I would like to work on some location approximating code. If I get something that is relevant, I will make sure I let you guys know. However developing any algorithm is much easier on a Linux box then on the phone itself.

Your program works very well and I would like to use it together data to analyze and to see if I can get more accurate results.

newb5000
31st July 2008, 12:27 PM
dwRxLevel seems to always return 0 for me.

I'll try using the PhoneSignalStrength (http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.status.systemproperty.aspx ) event

LeeCHeSSS
4th August 2008, 08:11 AM
Here's my latest trace log. Sorry for the delay.

I'm still experiencing the occasional lack of updates (for several hours; even though I travel 50km, so switch cells regularly). Turning on the phone causes an update to take place almost immediatly.

newb5000
6th August 2008, 08:12 PM
Hi guys,

I was out of town for a few days and got back today. Will work on the app as soon as I can.

abat
7th August 2008, 02:19 PM
Thanks for the excellent, very much awaited app. I am wondering if it is easy to add a functionality ro run a program if cell/lac change, passing the cell and lac as params to the program?

PizzaRoll
23rd August 2008, 12:03 AM
I hope a new update is on the way. I am looking forward to see how the program works out while Im in Mexico.

spen2
27th August 2008, 12:23 PM
Hi newb5000,

I've been looking for an app like this for ages, so many others available seem over bloated in my opinion. Thanks for all your hard work. I will use it for tracking our service engineers where i dont need the acuracy of a gps. I have been trying out on a palm 750 wm6 professional and it works perfectly. Active sync is always running on their phones for email anyway so your app has no real impact on the battery life as far as i can see. Thanks again and keep up the good work :)

spen2
29th August 2008, 12:14 PM
Hi, Does anyone know of an application that I could run on my pc that would display cellid data etc from newb5000's application as gps tracks in google maps? It would be great if i could point the cellidupdater to this application using a static ip and port. The app would need to translate into gps cordinates using googles my location to be displayed in google maps in real time. Something like a plug in for the web browser? I have used www.baeeo.com which is great and does exactly what i need, but i'd like to be able to send the cell id info to my own PC and not have to rely on using someones web server. Does anything like this currently exist or would it be possible to do?

xhozt
2nd September 2008, 08:48 AM
got it working but baeeo.com is not receving the info apparantly .. i keep geting the searching page when i check .. using a blackjack 1 here with da_g's 6.1

PizzaRoll
3rd September 2008, 07:13 PM
The app would need to translate into gps coordinates using googles my location to be displayed in google maps in real time. Something like a plug in for the web browser?

There is another program very similar to this but it is not as simple. you might want to look in to it. if you search on the forum for Google maps GPS/Cellid Track me you should be able to find it.

Otherwise as for a program to convert you location in real-time to a KML. I have not heard of one. However, if you have a few hours and know Java/PHP/Perl, pick your poison, you should be able to produce something relatively easily. I don't need to state that is the beauty of this program is that it uses standard HTTP GETs to transfer the data. Thus, it is extremely easy to use the data with any server side scripts.

I currently just have a perl script which resloves the Cellid to Cords, caches the information, and then saves it to a running log. If you are intrested in it when i get back to the U.S., I can send it to you.

spen2
4th September 2008, 10:58 AM
There is another program very similar to this but it is not as simple. you might want to look in to it. if you search on the forum for Google maps GPS/Cellid Track me you should be able to find it.

Yeah, i've tried that. Its very good but has lots of other functionality that i just don't need for my setup.

Otherwise as for a program to convert you location in real-time to a KML. I have not heard of one. However, if you have a few hours and know Java/PHP/Perl, pick your poison, you should be able to produce something relatively easily. I don't need to state that is the beauty of this program is that it uses standard HTTP GETs to transfer the data. Thus, it is extremely easy to use the data with any server side scripts.

The above mentioned track me app offers a demo server that you can download, i have set that up on my own xampp server and it is exactly the sort of thing i'm looking for, but just using cellidupdater instead. I really like the simplicity of cellid updater, you dont even notice the thing running on your device.

I currently just have a perl script which resloves the Cellid to Cords, caches the information, and then saves it to a running log. If you are intrested in it when i get back to the U.S., I can send it to you.

That would be great, i dont have any experience writing scripts so anything that you have done for this purpose would be much appreciated. I take it i could use it on my xampp server?

PizzaRoll
4th September 2008, 05:22 PM
Again when I get back to the US I can post the script or if I get enough free time ill just write a more robust version and post it up. Currently I am in Mexico and my Internet connection/router is having problems so that destroys the possibility of retrieving it :mad:

You would be able to run it on your server. I just have a Standard Debian (Linux) box which runs apache2. The HTTP server executes the script in Perl and dumps the time, cords, and cellid to a text file.

if you want to interface it with your xampp that will require a more in depth knowledge of that program. If anybody knows more about the program let me know and I might be able to make some cross connecting software.

Ultimately I would like to make some software to do this but at the moment just a text log file works for me

-------------------------------------------
Found the HTTP call for the xampp server
"http://luisespinosa.com/trackme/requests.php?action=upload&username=USER&password=PASS&lat=20.2482086166667&long=28.2732949&dateadded=2007-10-30 9:57:10&dateoccurred=2007-10-30 9:57:10&tripname="

Well time to set up a xampp server and start programming.

khaytsus
5th September 2008, 03:04 AM
Again when I get back to the US I can post the script or if I get enough free time ill just write a more robust version and post it up. Currently I am in Mexico and my Internet connection/router is having problems so that destroys the possibility of retrieving it :mad:

You would be able to run it on your server. I just have a Standard Debian (Linux) box which runs apache2. The HTTP server executes the script in Perl and dumps the time, cords, and cellid to a text file.

if you want to interface it with your xampp that will require a more in depth knowledge of that program. If anybody knows more about the program let me know and I might be able to make some cross connecting software.

Ultimately I would like to make some software to do this but at the moment just a text log file works for me

-------------------------------------------
Found the HTTP call for the xampp server
"http://luisespinosa.com/trackme/requests.php?action=upload&username=USER&password=PASS&lat=20.2482086166667&long=28.2732949&dateadded=2007-10-30 9:57:10&dateoccurred=2007-10-30 9:57:10&tripname="

Well time to set up a xampp server and start programming.

XAMPP has a Perl add-on. I am unfortunately tied to using a Windows server at work, but needed to write some CGI's, so XAMPP was the first thing I found and it works.. Have to do a little conversion between my own development environment (Linux) and it, but very little.

spen2
9th September 2008, 02:30 PM
I've modified the php script towards the begining of this thread so that it echo's to gpsgate.com's free online location server. The http call for that if anyone is interested is http://online.gpsgate.com/GpsGate.aspx?longitude=$lon&latitude=$lat&imei=$imei
You just have to sign up to a free account and add the imei of your device to the preference section. Works very well:)

newb5000
9th September 2008, 06:09 PM
Guys,

I really apologise for taking this long. Too many things have happened these past few weeks. That's no excuse, of course, since I did commit to this project from the start. So what I've decided to do is complete what I've been working on for some time, release an update, as well as release the source code in hope that someone with a bit more time will be able to improve on the app.

I will try to respond to every request that I've had either publicly, via PM or via email this week and will release everything this week as well. No use keeping everyone in suspense when I don't have nearly enough time to work on this project as much as I would have liked to, depite the fact that I really enjoy working on this.

So, expect a post from me this week - just cleaning up the code a bit.

This does not mean that I'm giving up on this project completely, but I feel it's time that those who have been following the progress of this app do receive an update.

Again, apologies for the delay.

LeeCHeSSS
9th September 2008, 07:06 PM
I'll just provide the simple script I wrote for those who do not know how to create one of their own. You'll need to edit both files to include your Google Maps API key and your database configuration.

I'm open to suggestions/comments, but don't expect me to reply within a day :)

katwork
9th September 2008, 11:57 PM
I'll just provide the simple script I wrote for those who do not know how to create one of their own. You'll need to edit both files to include your Google Maps API key and your database configuration.

I'm open to suggestions/comments, but don't expect me to reply within a day :)

Do you have a sql script to create the database tables? I came up with this after playing around with the code.
CREATE TABLE `cell` (
`uid` int(10) unsigned NOT NULL auto_increment,
`cellid` int(11) NOT NULL default '0',
`mnc` int(11) NOT NULL default '0',
`mcc` int(11) NOT NULL default '0',
`lac` int(11) NOT NULL default '0',
`longitude` int(11) NOT NULL default '0',
`latitude` int(11) NOT NULL default '0',
PRIMARY KEY (`uid`),
KEY `I_cellid` (`cellid`),
KEY `I_allcellinfo` (`cellid`,`mnc`,`mcc`,`lac`),
KEY `I_latlon` (`longitude`,`latitude`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `log` (
`uid` int(10) unsigned NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`cellid` int(11) NOT NULL default '0',
PRIMARY KEY (`uid`),
KEY `I_timestamp` (`timestamp`),
KEY `I_cellid` (`cellid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

For those with MySQL 4.x the code has some queries that only work with MySql 5.x. I had to change the following in whereami.php to work with 4.x.

Change line 47 from
$strQuery = "SELECT *, TIMESTAMPDIFF(MINUTE, timestamp, NOW()) AS age
to something like:
$strQuery = "SELECT *, TIMEDIFF(NOW(), timestamp) AS age

Note: the above change doesn't give you minutes it gives you the
time difference in h:mm:ss form. If someone knows how to get just
the number of minutes in MySQL 4.x please share.

and change purgeLog() from
$strQuery = "DELETE FROM log
WHERE TIMESTAMPDIFF(DAY, timestamp, NOW()) > 0";
to something like:
$strQuery = "SELECT * FROM log
WHERE DATE_ADD(timestamp, INTERVAL 24 HOUR) < NOW()";

katwork
10th September 2008, 08:08 PM
Is it normal for all cell entries to have the same mnc, mcc, and lac values?

I installed 0.4 fixed yesterday and between home and work I picked up 24 different cellids, but the mnc, mcc, and lac values were the same for all the HTTP requests sent to my web server. Only the cellid was different.

I installed the latest debug service a little while ago and the one tower it has logged so far still has the same mnc, mcc, and lac values as before. I have an AT&T Tilt running the latest stock AT&T WM 6.0 ROM and the program is installed on the SD card.

Edit: I did a little searching and found out what mnc, mcc, and lac mean. The Network Code and Country Code won't change and I'm guessing the Location Area Code is for a large area and that won't change either. So I guess I just need to figure out why all 24 cellids get the same latitude and longitude from Google (using LeeCHeSSS's code) and why the lat and lon is 25+ miles away from me...

spen2
12th September 2008, 11:56 AM
So I guess I just need to figure out why all 24 cellids get the same latitude and longitude from Google (using LeeCHeSSS's code) and why the lat and lon is 25+ miles away from me...

I guess not many people in your area have been using google maps for mobile. Googles database is updated by users of that i believe.

khaytsus
12th September 2008, 04:44 PM
newb5000,

I have one question that's always bugged me, but wasn't quite sure what context to ask it in..

Why does CellID take 3M of ram? It seems like it's a fairly 'simple' program in that there aren't a bazillion options, graphics, etc..

I'm sure there's some reason, so I've held off on asking, but figured I might as well. :)

katwork
12th September 2008, 06:15 PM
I guess not many people in your area have been using google maps for mobile. Googles database is updated by users of that i believe.
Google Maps (mobile) has no problem finding a cell tower close to me when I am not using the GPS. Plus I live in the bay area (about 45 minutes away from Google) so I'm pretty sure the problem is not due to lack of users using it in my area. :) I have 63 cellids in the database now and they all have the same latitude and longitude. I'm pretty sure the problem is with the script getting the values from google or my database. Without a script to create the tables I had to guess the fields and types. I haven't had time to debug the problem yet. I need to double check my google maps key and print out the data coming back from google to see if what is in the database matches what is coming back from google.

katwork
12th September 2008, 06:31 PM
Google Maps (mobile) has no problem finding a cell tower close to me when I am not using the GPS. Plus I live in the bay area (about 45 minutes away from Google) so I'm pretty sure the problem is not due to lack of users using it in my area. :) I have 63 cellids in the database now and they all have the same latitude and longitude. I'm pretty sure the problem is with the script getting the values from google or my database. Without a script to create the tables I had to guess the fields and types. I haven't had time to debug the problem yet. I need to double check my google maps key and print out the data coming back from google to see if what is in the database matches what is coming back from google.
I dumped what google was sending back and it was sending floats back for lat and lon. I had tried doubles for those fields originally and didn't get any data so I changed them to integers and got data (though truncated). I changed those fields to floats in the database and now I get the correct values. So it's working now. The updated script to create the cell table is:
--
-- Table structure for table `cell`
--
CREATE TABLE `cell` (
`uid` int(10) unsigned NOT NULL auto_increment,
`cellid` int(11) NOT NULL default '0',
`mnc` int(11) NOT NULL default '0',
`mcc` int(11) NOT NULL default '0',
`lac` int(11) NOT NULL default '0',
`longitude` float NOT NULL default '0',
`latitude` float NOT NULL default '0',
PRIMARY KEY (`uid`),
KEY `I_cellid` (`cellid`),
KEY `I_allcellinfo` (`cellid`,`mnc`,`mcc`,`lac`),
KEY `I_latlon` (`longitude`,`latitude`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

LeeCHeSSS
14th September 2008, 04:52 PM
Nice work on getting the databasestructure available, I should've thought of that myself :)

For what it's worth, this is my database structure (which is actually flawed because the maximum values for longitude won't fit correctly):
--
-- Database: `DBtst`
--

-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `cell`
--

CREATE TABLE `cell` (
`uid` int(11) NOT NULL auto_increment,
`cellid` int(11) NOT NULL,
`mnc` int(11) NOT NULL,
`mcc` int(11) NOT NULL,
`lac` int(11) NOT NULL,
`latitude` decimal(8,6) NOT NULL,
`longitude` decimal(8,6) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Tabel structuur voor tabel `log`
--

CREATE TABLE `log` (
`uid` int(11) NOT NULL auto_increment,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`cellid` int(10) unsigned NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


I also should have mentioned that you should use the script with the url http://yourdomain/whereami.php?do=log&cid={cellid}&mnc={mnc}&mcc={mcc}&lac={lac}

If you open the script in your browser (http://yourdomain/whereami.php?do=read OR http://yourdomain/whereami.php?do=readall) you'll get a nice map of your "current" cell, or all the cells in your database. I have thought about making the map figure out its' zoomlevel automatically, but was too lazy :P

spen2
18th September 2008, 08:53 PM
Guys,

I really apologise for taking this long. Too many things have happened these past few weeks. That's no excuse, of course, since I did commit to this project from the start. So what I've decided to do is complete what I've been working on for some time, release an update, as well as release the source code in hope that someone with a bit more time will be able to improve on the app.

I will try to respond to every request that I've had either publicly, via PM or via email this week and will release everything this week as well. No use keeping everyone in suspense when I don't have nearly enough time to work on this project as much as I would have liked to, depite the fact that I really enjoy working on this.

So, expect a post from me this week - just cleaning up the code a bit.

This does not mean that I'm giving up on this project completely, but I feel it's time that those who have been following the progress of this app do receive an update.

Again, apologies for the delay.

Hi newb5000,

Any chance you can grab the imei number of the device so it can be added to the url with {imei}? Don't worry if its not possible i can just type it out, thought it could be useful to others as well though. Looking forword to the next update :)

Thanks

spen2
15th October 2008, 11:34 AM
Hi newb5000,

I guess you are very busy at the moment but i dont suppose you know when you will be able to release an update do you? It already works really well when I use the updated cidservice.exe for unattended mode, so would be great if you could release a cab update that uses that version of cidservice.exe. I really appreciate all your work so far on this program and understand that you must have other commitments, but i hope you can finish it of and release the source code so other can continue what you started.

Thanks Again:)

dzalbo
13th November 2008, 09:38 AM
thread is dead? :)

anybody done something similar for Symbian?

spen2
13th November 2008, 11:27 AM
thread is dead? :)

anybody done something similar for Symbian?

Looks like it unfortunately. Check out Viking Informatics locator 2.20 http://www.viking.tm/product.php?id=11

This serves a similar purpose on the symbian platform.

khaytsus
13th November 2008, 03:18 PM
thread is dead? :)

anybody done something similar for Symbian?

What does this thread, or this entire forum, have to do with Symbian??

Anywho, I honestly don't know what else this program could do without expanding its scope.. I still think it uses too much ram, memmaid reports it using 1.4 to sometimes 3m of ram, which seems awfully high. Other than that, it just works and I never even have to think about it.

I leave it running 24/7 to do low accuracy tracking. When I want higher resolution tracking, I fire up TrackMe with my GPS. Eventually I'm going to write a web service that'll take data from Newb's program and put the data into TrackMe's database so the data is all in one place.

Although to be honest, some day in the future, I'd like to be able to run TrackMe as I currently do CellID and when I want higher resolution tracking I just turn on the GPS and things automatically happen. But until that happens, I'll continue to use Newb's program. I never even know it's there in the background quietly doing its job. :)

spen2
13th November 2008, 04:27 PM
Anywho, I honestly don't know what else this program could do without expanding its scope.. I still think it uses too much ram, memmaid reports it using 1.4 to sometimes 3m of ram, which seems awfully high. Other than that, it just works and I never even have to think about it.

I agree, this app does the job it was meant to do, I'd just like to see it finished of with an installer that includes the updated cidservice.exe and like you say, maybe an improvement to the ram usage if possible. But really these are just small issues, apart from them, its spot on :)

acedish
2nd January 2009, 04:42 AM
Hi Newb, An chance of releasing the source code? I think there is alot of interest from others including myself to continue on development on a great app.

ACE

Guys,

I really apologise for taking this long. Too many things have happened these past few weeks. That's no excuse, of course, since I did commit to this project from the start. So what I've decided to do is complete what I've been working on for some time, release an update, as well as release the source code in hope that someone with a bit more time will be able to improve on the app.

I will try to respond to every request that I've had either publicly, via PM or via email this week and will release everything this week as well. No use keeping everyone in suspense when I don't have nearly enough time to work on this project as much as I would have liked to, depite the fact that I really enjoy working on this.

So, expect a post from me this week - just cleaning up the code a bit.

This does not mean that I'm giving up on this project completely, but I feel it's time that those who have been following the progress of this app do receive an update.

Again, apologies for the delay.

spen2
4th February 2009, 05:06 PM
Hi newb5000,

I guess you are very busy at the moment but i dont suppose you know when you will be able to release an update do you? It already works really well when I use the updated cidservice.exe for unattended mode, so would be great if you could release a cab update that uses that version of cidservice.exe. I really appreciate all your work so far on this program and understand that you must have other commitments, but i hope you can finish it of and release the source code so other can continue what you started.

Thanks Again:)

Using WinCE cab manager I have updated the latest .cab in the thread so it installs with the latest cidservice.exe created by newb5000 for unattended mode. cab file attached.

RiverRat812
2nd March 2009, 01:15 AM
First time post from a long time lurker....

It looks like this project has slowed down but I thought I would add some interesting info...

I'm an AT&T subscriber located in the Northeast US and I have just downloaded this to try it out.

The program is giving me a 5 digit CELLID. Even though I am stationary, the CELLID is changing (actually, only the last digit is changing).

So, for those of you seeing multiple CELLID's at the same LAT/LON:

The 1st 4 digits of the CELLID are the same as the AT&T SITE #

The last digit could reference the radio/cabinet you are connected to at that time.

I verified this with data from the Cingular/AT&T Integration project as well as the data from my last UMTS Tracker database.

khaytsus
2nd March 2009, 06:25 PM
First time post from a long time lurker....

It looks like this project has slowed down but I thought I would add some interesting info...

I'm an AT&T subscriber located in the Northeast US and I have just downloaded this to try it out.

The program is giving me a 5 digit CELLID. Even though I am stationary, the CELLID is changing (actually, only the last digit is changing).

So, for those of you seeing multiple CELLID's at the same LAT/LON:

The 1st 4 digits of the CELLID are the same as the AT&T SITE #

The last digit could reference the radio/cabinet you are connected to at that time.

I verified this with data from the Cingular/AT&T Integration project as well as the data from my last UMTS Tracker database.

Now that is interesting news, and explains some things. I've only seen it on a few towers, but there's two near my house and one near work which I am constantly seeing multiple identifications from.

One near work has four CID's on it! Using OpenCellClient (search this forum) it's obvious that they're all coming from the same tower. So that 'splains that.

Thanks for the input! Not sure what exactly to do about it, but at least I know I'm not crazy or getting weird results ;-)

mr.pohoda
2nd March 2009, 10:24 PM
I was also interested in this topic and I'm working on application which would show all cell towers in range. The problem is that this issue is hardware-specific and can differ even with different rom. I still believe that I can make it. If someone has any tips, let me know.

CLShortFuse
3rd March 2009, 07:06 AM
I wrote a GPS application about a month ago. I actually took it one step further by getting the cell tower ID and cross referencing it with Google Maps' database to get the cell tower GPS position. The goal was to use that to help the GPS device get a quicker fix. I wasn't able to get all active cell towers so I couldn't do a signal triangulation.

I haven't worked on it in a while actually, but if you're interested, it's here: http://forum.xda-developers.com/showthread.php?t=474582&page=5

fboutevi
18th March 2009, 03:16 PM
Is it possible to have source code of this small application, it's working great for me :)

fboutevi
18th March 2009, 03:18 PM
Well I went and coded a sample app anyway. It just reads the current tower info at the specified interval. Is this the information that you require?

Just extract the zip to the device and run the .exe.

Note: It requires .NET Compact Framework 2.0
Is it possible to have source code of this small application "GetCellId.exe" ? It's working great for me :)

croisez
25th October 2009, 07:39 PM
Hi,
could you be so kind to send me the source code of your GetCellID.exe binary you sent to xda-dev forum on 19th May 2008, 06:46 PM?
Thank you so much.
:Louis.

Well I went and coded a sample app anyway. It just reads the current tower info at the specified interval. Is this the information that you require?

Just extract the zip to the device and run the .exe.

Note: It requires .NET Compact Framework 2.0

wlanguide
23rd February 2010, 03:35 AM
Using WinCE cab manager I have updated the latest .cab in the thread so it installs with the latest cidservice.exe created by newb5000 for unattended mode. cab file attached.

Hi buddy thanks for sharing this, I would like to check it out first, thanks again.