tags:

views:

213

answers:

5

I am sending gps coordinates from a windows mobile phone to a webserver using a basic program I wrote in C#. The problem is the data plan on the phone only allows 4 MB per month. I was planning on updating the location every 10 seconds.

Currently I am just creating a webrequest every 10 seconds to a php page on the server and the coordinates are passed over in the url, the php page saves them to the database.

This generates about 1K of data per request, at this rate I will hit my data limit in less than a day.

Is there a more efficient way to do this?

Update:

I need to explain the application of this a little more. I work at a university and we had the idea of using the phones on our shuttles to send the location of the shuttles to the server every 10 seconds. Then have a website that the students could access from their computer or phone and see where the shuttles are.

This would allow them to decide if they want to wait for the shuttle or start walking. So I could maybe go to 20 second updates, but that would be about it. The application won't run 24/7 but I'm using worst case scenario in case the phone isn't shut off.

+4  A: 

1 req every 10 seconds = 6 req/min = 360 req/hr = 8640 req/day = ~260k req/month

4MB/260k ~= 15

So to stay under your limit, the average post to the server will have to be 15 bytes? Doesn't seem possible.

Even if you went down to the socket level (which you probably should anyway), a simple ping sends 84 bytes, so even that would restrict you to once per minute.

egrunin
I didn't think about it that way. Just passing over 2 doubles (latitude,longitude) would be 16 bytes not counting the overhead of the initial connection.
Brian
not quite true. You can reduce the size of your transmissions by doing sending diffs rather than full co-ords. 16 bytes for the initial location, then maybe 2-4 bytes for the offset
burnt_hand
@burn_hand: but the TCP/IP overhead will remain constant
egrunin
oh, and i worked in a car tracking company. 10 secs is too fine.30 seconds to 1 minute is really as much as you need. Anything finer is rendered useless by traffic movement and server <-> client communication
burnt_hand
@egrunin - I agree. Usually this approach is only important when sending multiple locations at once. was more of a FYI
burnt_hand
@burnt_hand - I could see how 10 seconds would be too often if you were tracking over a large distance. But it is less than a mile across our university's campus so wouldn't the shorter route of the shuttle create a need for more frequent updates?
Brian
@Brian - Not really. If you know where something is now, then you can make a fair guess as to where it will be in 20 seconds. Especially if you have its speed in the data, which you often do (either supplied by the GPS itself or calculated by the software on the device)
burnt_hand
+2  A: 

You could use SMS (text messages) to send coordinates from phone to server. Unlimited texting is usually a lot cheaper than a data plan.

You could also save coordinates on your phone and send them in batches (instead of sending one coordinate every 10 seconds). You can store a GPS coordinate with two floats or 8 bytes. At one coordinate every 10 seconds, that comes to about 2MB per month. If you make the batches large enough so that the communication overhead is small relative to the size of the data, you'll make it under your 4MB limit.

Web services use SOAP/XML which is extremely verbose - sending your data as a byte array and then unpacking the individual elements on the server is the best way around this problem.

MusiGenesis
+7  A: 

How about only sending updates when the user has moved a certain distance from the previous value?

There's not point repeatedly sending the same coordinates every 10secs during the night while the phone is sat by the side of the bed for example.

Paolo
This is an excellent point, but there has to be a heartbeat (say once every 10 minutes) so the server knows the phone isn't turned off or underground.
egrunin
Good point, although then the server wouldn't be able to distinguish between someone who wasn't moving and someone who wasn't even connected to the network any more.
MusiGenesis
A: 

First of all: I assume that you won't travel a lot with very high speed to make a very large distance in a 10-second time interval. So a larger interval is a good idea.

You could add some logic to the client that could calculate the distance to the last locations. Only if its over a certain threshold you send an update. If you are at the same location (like at home, sleeping, several hours a day) you could send a 'here, position is still (nearly) the same as last one' - message that is very short in data all X minutes. While X is an increasing value that depends on how long the last change in position was. Like 5 minutes, 15 minutes, 30 minutes, 1 hour etc. That will save a lot of traffic too and if the position changes again you can update at once a full gps coordinate.

Sebastian P.R. Gingter
+1  A: 

Where abouts in the world are you, what kind of data plans are available? Surely it would be easier to get a less ridiculous data plan than try and fit your concept into such a measly data plan? In the UK where i live 500mb - 1gb mobile data add ons are in the region of £5 a month on top of your normal phone contract cost.

Ben Robinson
I'm in the U.S., the phones just have a data plan no voice and no text. I just found out about this small data limit yesterday, I assumed it was several hundred meg. It is costing us $10 per month for 4MB, seems like a ripoff to me.
Brian
@Brian: Verizon's lowest-end data package is $10 for 25 MB. You're being ripped off, but not quite by an order of magnitude. 10 for 4 may also be a normal cost when it's not an add-on to an existing voice plan. We (the US) are so far behind the rest of the world in everything except catastrophic ecological disasters now.
MusiGenesis