Online monitoring of transport with his own hands
Always liked the idea of online monitoring of anything on the map. And here's the opportunity to do something similar.
The process and the result of the development I want to share with the community.
a Little background
the fact that the guys with our project gathered in a rally in the major cities of Russia, in this regard, I came up with the idea: it would be great if on the website you can always see the current location of the expedition.The search began on the topic, analysis of existing solutions.
I came to the following scheme: you need a device that will be after a certain period of time to send information about the current location via GPRS somewhere in the Internet, and in the future on our website will be shown on the map line (track) of all points.
device Selection
Began the search for suitable devices. The range is quite wide: from small personal tracking devices to devices that are installed directly into the vehicle. Basically, all devices from China, but there were even Patriotic sometimes :)Ultimately decided on the model Astron GT-102 - compact, the cheapest, has all the necessary functions.
I will say a few words about the purchase. I found a site where they sold this model for 3999 rubles, immediately called and tried to order.
However, here I was in for trouble: the seller said that their presence there, and the current batch is waiting for customs clearance at the border.
In the end, I whole have waited a week, calling every day, waiting for the customs clearance.
In the meantime found the same model on many famous DealExtreme, and the price is $79.96 (~2400 rubles). I wanted to order, but the risk is not wanted, as time was running out, and the premise can go a week, and can go a month and a half (had the experience of ordering in the store).
Picking and packing goods in the Chinese online store and from our
By the way, a little about the configuration. She surprised nice Goodies: a second battery, extra back cover (with magnets for attaching to body), protective sheath. The only thing what was missing is a car charger.
Thus, the device is lying on the table, bought a new SIM card with a special "interactive" tariff plan.
configuring tracker
included was a little booklet with the instructions (even in Russian). Tracker, despite the presence of USB, configurable via SMS.The algorithm is simple: send a message with command & password and get back the execution result. And in response you can only get a message of the form
<command> ok
, <command> error
or not to obtain anything (that does not mean that the command is not applied).The tracker has two modes of notification, or sends the information via SMS to a trusted number, or sends via GPRS. Initially, the tracker sends the data by calling SIM card, which he inserted, but there is also the ability to automatically send data after a specified period of time.
In the end, was driven settings for Internet via GPRS (apn, user, pass), address and port of our server.
But how to understand what this mysterious device is sending and in what format?
Obtaining information
When I started this idea, I've been looking for any servers for these devices, which receive signals from the trackers and somehow display them.Nothing was found. No, there is certainly one service that provides free web monitoring vehicles, and you can add your tracker, after adjusting it to their server, but this variant did not approach me.
Opened the port specified in the settings on the server started to listen. After a long settings of the tracker managed to get it to send packets to our server.
As I suspected, the tracker sent information as plain text'.
An example of a package-ping (sent by the tracker every 20 seconds):
##,imei:572776984948029,A;
Generally, the IMEI is contained in each packet from the tracker, so it is helpful to filter the connection: no IMEI — disconnection.
By calling the tracker, I triggered the sending of the following information:
imei:572776984948029,tracker,1007180132,+7926*******,F,173215.000,A,5453.2762,N,05850.6135,E,51.16,;
Interesting line, isn't it? But that it is recorded and in what form?
Device sent the information to the server that has pleased :)
Then came the process of understanding what this line contains and in what format.
Of course in the attached instructions or words about it.
There was some kind of instruction for Chinese TK-102 (our device has a lot of synonyms :), which was interesting for me information.
Apparently, there is some kind of abbreviation GPRMC. Google helped me to find information what is it.
In the end, there is the option of parsing the string that pulls the coordinates, time and speed (by the way did not realize that it is specified in the nodes).
An example of a parsed string:
raw: imei:572776984948029,tracker,1007180132,+7926*******,F,173215.000,A,5453.2762,N,05850.6135,E,51.16,;
gps raw date: 17:32:15.0
gps unix date: 17.07.2010 17:32
degree: 54°53.2762'N 058°50.6135'E
decimal: 54.887937 58.843558
speed: 94.74832
The server has acquired connection filtering (on the IMEI), the logging messages from the tracker, by discarding unnecessary points and something else, but the main thing was to reach the goal: the tracker sends coordinates every 20 seconds and they are saved on our server.
Display information
the hardest part is passed, it remains to show route users.To display points and connect them in the line was entrusted to Yandex.Cards. Their API is well documented, so I will not give any code or comments, better to show skrinshotik (clickable).
The last 50 points on the map are marked by triangles that show the direction of movement, and click-through information about the speed at this point and commit time.
Disadvantages
the resulting system still has flaws, in my opinion solely hardware: tracker after a reboot (battery change) "forgets" that it needs to send information to the server every N seconds, it hangs (cannot turn off without removing batteries).Probably affects what is the cheapest tracker I found on sale in Moscow.
what I forgot to mention
— this tracker has a monitoring function: you can call on him and hear what is happening around the device.— charge one battery lasts about 20 hours;
in use, consumes very little traffic;
— in the search process example of an implementation of display tracks on the map found almost the only article, which studies in some detail the task for example Google Maps;
system went very budget: 4000 rubles per device + 300-400 for a new SIM card with the desired rate;
Комментарии
Отправить комментарий