Hello! Once, thinking about the safety of my car, I fumbled a lot of resources with information about car anti-theft systems, including GPS. But everything was either not what was needed, or rather expensive, and I did not like the accompanying services, and there is a paranoia in me to admit. In general, the main scaring reason for me was to share information with someone about their location. As a result, ordinary alarm was bought with auto start and feedback, but now it is a little about something else.
All the same thoughts about the preservation of information about the position of the car I spun in my head, and I just wanted to find something interesting to take at leisure. On these thoughts, I decided to buy the so-called. personal GPS tracker. Especially I didn’t look at the models, everything was about the same, but not many of the candidates that had gone over had a very important feature such as setting up their own server. As a result, my choice fell on the personal GPS tracker of the Chinese company Xexun - Xexun TK102-2. After a few more hours of finding out how everything is set up and heaps of various manuals, I decided that I needed to buy and see what it was. Who is interested in information about the tracker and about writing your own "server" for the tracker, please tackle.
On the forms of different companies that provide GPS monitoring services, they wrote and warned that a lot of fakes were walking and that there was a chance to run into them, that they were supposedly not distinguishable, etc., if you did not prioritize the goods from them, but I went a proven way and I ordered Pribluda on ebay, I really had to wait 4 weeks, but oh well - I came.
')
Briefly about the tracker:
Communication standard: GSM 850, GSM 900, GSM 1800, GSM 1900
GPS chipset: SiRF Star III
Satellite navigation system: GPS
Specifications:
Tracking sensitivity: -159 dBm
Hot start 2 seconds
Cold start 35 seconds
Accuracy 5 meters
Operating temperature from -10 to +65 ° C
Functions
SMS remote control
Speed ​​control, start of movement
Low Battery Signal
Dimensions and weight
64 mm length
Width 46 mm
17 mm thickness
Weight 50 g
Memory
SD card support
GPRS data transfer
Hot keys and display
Panic Button: sending current coordinates, sending SOS signal via SMS
Indication: green LED
Battery
Li-ion battery type
Battery capacity 860 mAh
Normal operation time up to 12 hours
Standby time up to 80 hours
The device came in such a box, which, by the way, was not quite badly done.


The device itself is made of soft-touch rubberized plastic.


Inside view with already installed SIM.

The kit also contained a charger for a replaceable battery and for the tracker itself.

It’s a pity that there was no software in the box to track the tracker to work, but there is a benefit that it’s relatively simple for a simple (I apologize for the tautology) person to register both himself and the device and see how it all works, but it’s not for me wrote at the beginning of the topic.
So, it's time to test. Without hesitation, I went out to the balcony and launched the tracker, after reading the instructions I tried to set it up, but I was given this with variables because the instruction was not very well written, there were many typos, and typos in the commands themselves to be sent to the tracker, so I I found the Russian version and the setting went quickly and without errors.
First of all, I tried to poll the tracker by SMS - I received the coordinates and instantly checked the maps - great, the next step is setting up my server, but since I don’t have my server, and I’ve got a white IP, I quickly wrote a C # console application and decided to see what comes from the tracker, and the following line came from the tracker:
"130402213013, + 79637 ** 3 ***, GPRMC, 173013.000, A, 6146.4979, N, 03421.2399, E, 1.92.21.48.020413 ,,, A * 5B, F ,, imei: ******* ******, 00, -16.4, F: 3.73V, 0.139.49646.250.99, 1478.68A7 \ n \ r "
I wrote the asterisks in the fields with the phone number (2) and in the imei field specifically.
Actually, the description of this line was in the instruction itself, but not completely in its entirety, something had to be dealt with, for example: find out what the GPRMC is, but this is also not difficult because full of information.
One of the main incomprehensible moments for me was that the coordinates do not come exactly a few tens of kilometers to the side, although SMS immediately comes with normal coordinates. This was not a little annoying, because by that time I had already written a small program that parses everything and saves it in an xml file (more on that later). The decision did not lie on the surface, because I simply did not understand how to formulate a request to Google to find the necessary information as a result of several days in a row I read various technical specifications about marine and not only navigation and articles on the operation of GPS receivers. It turned out that all quite simple coordinates came in the WGS-84 format and they needed to be converted to “normal”, that is, those that fit, for example, Yandex Maps. Actually, with the advent of “WGS-84” the circle narrowed and there were immediately formulas and everything counted.
Separately, I want to write about the program, which I worked in the evenings, in order to receive data from the tracker. I chose the c # language as the most convenient for me; at the university, I preferred to do labs on it due to its apparent simplicity, however. However, all that was taught at the university and what I studied myself was not useful in this project. For example, I have never heard about multithreading in the course of C #. Yes Yes. There was no work with the network either. In general, I had to understand and read everything myself.
First things first.
To start, the ServerStart method starts, which makes you listen to the connection entry, starts the method that spawns a new stream that expects "clients" in one place. When the client connects, another stream is generated that receives data from the tracker. Everything is quite simple.
public void ServerStart() { isServerRunning = true; listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
A method that accepts messages. I have heard many times “For endless cycles you need to burn at the stake”, because of my lack of experience or more correctly to say no literacy in this matter, I decided to use it for now, then after reading the necessary literature I will try to write as it would be correct. Although in fact I did not notice that I was beginning to devour the processor, there were moments when one core was fully loaded by the process due to this cycle, but after I debugged and began to use the Recieve method that stops the execution of the thread until the message from the tracker comes, in general, the same logic is used as with listener.Accept ().
public void messageReciever(Socket client) { int i = 0, av = 0; double t = 0; string[] data; string[] messages; char[] spliter = { '\n', '\r' }; string message = ""; while (isServerRunning && client.Connected == true) { try {
I just want to finish this, in general, the only thing I want to add is that I decided to refuse to save the data in the xml file, because I didn’t understand how to synchronize the streams between themselves and often it turned out that the file was opened by one flow, but to him trying to get through is another thread. The problem of locking laid on the database - MySQL. Oh yeah, I think the parsing of data separated by a comma is also not needed in a special view, and connecting C # to MySQL is quite simple and friendly, especially since MySQL provides all the connectors.
At the moment, I plan to expand the functionality of this application and distribute the web face in order to start all the same to visualize the movement. There are also some difficulties with the web muzzle, namely: it was determined which cards to use, well, the actual learning of the maps API. There is no experience with the API of any maps, but I think in an unhurried manner, everything will also be studied in the evenings.
Thanks to those who read, and a special thank you UFO.
application