Send data to web server from C #, what's the most efficient way?
I am sending gps coordinates from a Windows mobile phone to a web server using a basic program written in C #. The problem is the data plan on the phone only allows 4MB per month. I planned to update the location every 10 seconds.
Currently I just make a web request every 10 seconds to a php page on the server and the coordinates are passed in the url, the php page stores them in the database.
This generates about 1000 data per request, at this rate I will remove my data limit in less than a day.
Is there a more efficient way to do this?
Update:
I need to explain this in a little more detail. I work at a university and we got the idea to use our shuttle phones to send the shuttle location to the server every 10 seconds. Then you have a website that students can access from their computer or phone and see where the shuttles are.
This will allow them to decide if they want to wait for the shuttle or start walking. So I could go for 20 second updates, but that would be about him. The app won't work 24/7, but I'm using the worst case scenario if the phone is not disconnected.
a source to share
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 server write must be 15 bytes? Does not seem possible.
Even if you've gone to the socket layer (which you probably shouldn't), a simple one ping
sends 84 bytes, so even that will limit you once a minute.
a source to share
You can use SMS (text messages) to send coordinates from phone to server. Unlimited text message is usually much cheaper than the data plan.
You can also save the coordinates on your phone and send them in batches (instead of sending one coordinate every 10 seconds). You can store the GPS coordinate with two floats or 8 bytes. With one coordinate every 10 seconds, this is about 2 MB per month. If you are making batches large enough so that communication overhead is small in relation to the size of the data, you will do so under the 4MB limit.
Web services use SOAP / XML, which is extremely verbose - sending your data as an array of bytes and then unpacking the individual elements on the server is the best way to solve this problem.
a source to share
Where are you in the world, what data plans are available? Surely it would be easier to get a less ridiculous data plan than to try and plug your concept into such a paltry data plan? In the UK where I live, 500MB - 1GB of mobile data is added to an area of £ 5 per month above the normal cost of a phone contract.
a source to share
First of all: I am assuming that you will not be traveling a lot at very high speeds to make a very long distance in a 10 second interval. Therefore, a large interval is a good idea.
You can add logic to the client that could calculate the distance to the last locations. Only if it exceeds a certain threshold do you send an update. If you are in one place (for example, at home, sleeping, several hours a day), you can send "here", the position is still (almost) the same as the last "- a message that is very short in data for everything X minutes, while X is an incremental value that depends on how long the last change in position has passed. Like 5 minutes, 15 minutes, 30 minutes, 1 hour, etc. This will also save a lot of traffic and if the position will change again, you can update the full gps coordinate at once.
a source to share