View Full Version : cellGPS for Windows Mobile? Upload GSM cell-id on periodic basis to HTTP server?
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
19-05-2008, 03:19 PM
wow this would be a great aplication :)
Cavey.co.uk
19-05-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
19-05-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
19-05-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
norelidd
20-05-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
20-05-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
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.
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
20-05-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
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
20-05-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
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
30-05-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
30-05-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
30-05-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
30-05-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
31-05-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
31-05-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
31-05-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
31-05-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!
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
01-06-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
01-06-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
02-06-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
02-06-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
02-06-2008, 04:49 PM
Interesting...
http://developer.garmin.com/mobile/mobile-sdk/xt-wm-sdk/
Esteel
02-06-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.
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
03-06-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.
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... :)
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
03-06-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.
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
06-06-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
08-06-2008, 06:02 PM
which url i must type in?
gai-jin
08-06-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
09-06-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
10-06-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
11-06-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
13-06-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
13-06-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
15-06-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
15-06-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
15-06-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
15-06-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
15-06-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
15-06-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
15-06-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
17-06-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
18-06-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
18-06-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
18-06-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
18-06-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
18-06-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
18-06-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
18-06-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
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
19-06-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
19-06-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
19-06-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
19-06-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
19-06-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
22-06-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
23-06-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
23-06-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
01-07-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
01-07-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
07-07-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
07-07-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
08-07-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
08-07-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
08-07-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
08-07-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
09-07-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
09-07-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
09-07-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
10-07-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
11-07-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
11-07-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
11-07-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
11-07-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
11-07-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
11-07-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
11-07-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
11-07-2008, 05:43 PM
Cool, really appreciate your work on this as I'm sure others do :-)
I'll watch this space!
khaytsus
12-07-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
14-07-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
14-07-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
14-07-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
15-07-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
15-07-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
15-07-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
18-07-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
18-07-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
21-07-2008, 09:10 AM
newb5000, great job!
Thanks for your efforts :)
w000ter
21-07-2008, 11:00 AM
Wow excellent work newb5000! Looking forward to your app! :D
newb5000
21-07-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
21-07-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
21-07-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
21-07-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
21-07-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
21-07-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
21-07-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
21-07-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
22-07-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
22-07-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
22-07-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
22-07-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
22-07-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
22-07-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
22-07-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
23-07-2008, 12:15 AM
Here's that little