Suomeksi | In English
Aspicore

Mobile software
Forum

Aspicore GSM Tracker

Real-Time GPS Tracking with Series 60 Smartphone

UDP Java Tools

This is a Java solution to reading the data from the Aspicore GSM Tracker. The downloadable ZIP archive below contains java code that acts as a server for the UDP packets that arrive from the GSM Tracker client.

Compatible with MySQL 4.1 and J2SE 5.0. Run in a computer, which should be accessible  from the Internet via a public IP address.

The server is setup to store the data in a MySQL database including the incoming and outgoing cell information. Two mysql text files are included to setup the database that includes a cell table.

The zip file includes project files for use within Eclipse.

We share this code by courtesy of Carlton O'Riley.

Disclaimer

Download

Download Java tools from here.
[GSMTracker.zip, 400 kB, version 30-Mar-2007
Change History:
Implemented a mechanism to reconnect to database if the connection has been lost.
When catching an SQLException in DatabaseHandler.java, instead of printing a stacktrace throw the exception.
Enabled autoReconnect property in MySQL connection string. This operation should prevent from loosing the database connection if no data has been received recently.]

Installation

You will need the JRE 1.5 to run the code. (The general Sun web site for Java is http://java.sun.com/. Look for J2SE 5.0 or JRE 5.0)

Uncompress the GSMTracker.zip into some directory on your hard disk. Note that the Zip file contains subdirectories.

Setup the MySQL database with the .sql file as described in GSM_Tracker_MySQL.txt

Starting the server

Open the OS command prompt. Go to the directory containing GSMTracker.jar.

Issue the following command:

java -cp mysql-connector-java-3.1.6-bin.jar;GSMTracker.jar asp.location.gsmtracker.TrackerServer

Now the server should be running. It shows the arriving UDP packets on the console in real time. It also parses and stored them into the database, if the db connection was successful.

Next development step

Obviously you need to write or purchase some additional program code to do something with the positioning data collected to the database.

Troubleshooting

If you get error
java.sql.SQLException: Access denied for user: 'root@localhost',
check the database connection parameters from TrackerServer.java. Either change the connection parameters from there, or change your root password to 'root' with MySQL command
mysql> SET PASSWORD = PASSWORD('root');

If you get error
java.sql.SQLException: Unknown system variable 'time_zone',
check that you have a correct version of MySQL. In our case an upgrade from mysql-4.0.20b-win.zip to mysql-essential-4.1.9-win32.msi helped. (http://dev.mysql.com/, Windows Essentials Installation Package)

Some additional installation and usage hints you can get from our Perl tools page

Using the test client

Open another OS command prompt from the same computer where TrackerServer is running. Go to the directory containing GSMTracker.jar.

Issue the following command:

java asp.location.gsmtracker.TrackerTestClient

The test client sends an UDP datagram to localhost. The datagram is a simulated message from Aspicore GSM Tracker mobile client.

The following text  should appear into the TrackerServer console window:
Received from /127.0.0.1:
IMEI 123456789012345
$GPRMC,144858.159,A,6009.0358,N,02453.3223,E,0.00,006.40,191104,,*05
OutCell 38091 LAC 30464 Name SAT-C MCC 510 MNC 1
In Cell 34747 LAC 2161 Name SONERA MCC 244 MNC 91
Label Aspicore Ltd
*DE6279AE

Next you can test, whether the simulated message got stored into the database. Open MySQL Command Line Client (mysql.exe) and make some select queries:
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.1.9-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use gsmtrack;
Database changed
mysql> select TIME_RECEIVED, LATITUDE, LONGITUDE FROM GPS;
+---------------------+------------------+-----------+
| TIME_RECEIVED       | LATITUDE         | LONGITUDE |
+---------------------+------------------+-----------+
| 2005-01-21 08:52:32 | 60.1505966666667 | 24.888705 |
+---------------------+------------------+-----------+
1 row in set (0.00 sec)

mysql> select * from cells;
+-----------+-------+-------+--------+------+------+
| CELLRECID | CID   | LAC   | NAME   | MCC  | MNC  |
+-----------+-------+-------+--------+------+------+
|         3 | 34747 |  2161 | SONERA |  244 |   91 |
|         4 | 38091 | 30464 | SAT-C  |  510 |    1 |
+-----------+-------+-------+--------+------+------+
2 rows in set (0.00 sec)

mysql>

If everything seems to be working as expected, you can try sending location data from your phone. Start Aspicore GSM Tracker in your phone and change the setting "GPRS Server IP" to the public IP address of the computer, where TrackerServer is running. Restart Aspicore GSM Tracker in your phone.

If you want to make sure, that your TrackerServer is accessible from the public Internet, as is required unless you have purchased a private GPRS access point from your carrier, you can modify TrackerTestClient.java a little to send test messages to another IP address instead of localhost. Then you can use TrackerTestClient to send test messages from another computer through your firewall to your TrackerServer and see that your firewall passes the UDP packets through.

Feedback

As we are not the author of this code and it is shared free of charge, we cannot give much support on it. However, any comments or suggestions are welcome to support@aspicore.com. (We have not yet had time to fully test the code ourselves, so we are grateful for any feedback or info about how you have managed to make use of it.) You can also use our discussion forum.

If you have written the receiving part for our GSM tracker UDP datagrams with a different language than Perl or Java and allow us to share your code free of charge to the other users, we would appreciate any such source code you can send us by e-mail.

Back to product main page

©