Question

I have a GPS tracker with TK06a Chipset, and I have my own tcp listener, everything is working fine, I have received the data from the device with this format :

#355488020131775##1#0000#AUT#01#52500100232a47#10341.175280,E,121.322800,N,0.28,0.00#111113#171607.000##

I think i figured out what are these, (for example the first one is the IMEI), but I didn't know how to convert (10341.175280,E) and (121.322800,N) to something that google maps can understand.

beside the device has a poor user manual and no documentation for the protocol.

the real location should be in here (1.355269,103.686426) maybe this can lead you to solve this mystery :)

Thanks in advance.

Edit:

I Found this on the web, maybe some will find it useful :

The decode of the line above.

  1. the IMEI number cannot be empty, if the SIM card number regarded as device series number, then the data of IMEI part should be filled in SIM cad number.
  2. SIM card number: this part can be empty , or also can be same as 1st point , fill in SIM card number.
  3. 0 or 1 , reserve (original meaning is ACC status )
  4. Device password ( 0-9 numbers, digit cannot over 6 digits, generally is in 4 digits )
  5. Reserved word AUT, cannot be changed .
  6. Numbers of data, 00-99 , in 2 digits.

The format of Each data as below:

#base station number#Longitude, East and West identification, latitude,North and South identification,speed(nm), direction angle(0-360)#date#time
  1. Base station number can be empty.
  2. Longitude, format : dddff.ffff, the degree part must be in 3 integer, the minute part must be in 2 integer, the decimal part is in 4 digits, there is no separator between degree and minute.
  3. East and West identification, only one character , E/W.
  4. Latitude, format : ddff.ffff, same as Longitude , only the degree part is in 2 integer.
  5. North and South identification, only one character , N/S.
  6. Speed: can be 0.
  7. Direction : can be 0.
  8. Date, format : ddmmyy.
  9. Time, format: hhnnss.mmm, the part before decimal point should be hour, minute and second in turn, each is in 2 digits, the part after decimal point should be milliseconds, it can be 000.
Was it helpful?

Solution

This format is DM like in NMEA RMC message, but with a missing leading 0:

given longitude: 10341.175280 E

The first 3 digits are degrees: 103
Then the rest is minutes: 41.175280
This now is fomrat "DM" Degrees and decimal minutes.
Google uses "DEG" (Decimal degrees)
convert: 103 + 41.175280 / 60.0 = 103.686254 (DEG = degrees + minutes / 60.0)
wich fits perfectly to your location

Now it is a bit strange:
It should read "0121.322800" not "121.322800"
But then similar to above but since latitude is limited to two digits:
The first 2 digits are always degrees: 01
Then the rest is minutes: 21.322800
same formala as above: lat= 1 + 21.322800 / 60.0 = 1,35538

finally: if W or S, multiply the deg value with -1 (In your case it is N and E, so it stays as it is - positive)

This format looks partly like the NMEA RMC sentence

OTHER TIPS

I think you want to make this work with OpenGTS.

So here what i done to work:(Note i dont need the tk10x devices so i overwrited the files, you can create another class if you want)

go to $GTS_HOME/src/org/opengts/servers/tk10x

and change the TrackServer.java with this code

I writed a new parseInsertFunction

package org.opengts.servers.tk10x;

import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.*;

import org.opengts.util.*;
import org.opengts.db.*;
import org.opengts.db.tables.*;

public class TrackServer
{

// ------------------------------------------------------------------------
// initialize runtime configuration

public static void configInit()
{
    DCServerConfig dcs = Main.getServerConfig();
    if (dcs != null) {
        TrackServer.setTcpIdleTimeout(   dcs.getTcpIdleTimeoutMS(      Constants.TIMEOUT_TCP_IDLE   ));
        TrackServer.setTcpPacketTimeout( dcs.getTcpPacketTimeoutMS( Constants.TIMEOUT_TCP_PACKET ));
        TrackServer.setTcpSessionTimeout(dcs.getTcpSessionTimeoutMS(Constants.TIMEOUT_TCP_SESSION));
        TrackServer.setUdpIdleTimeout(   dcs.getUdpIdleTimeoutMS(   Constants.TIMEOUT_UDP_IDLE   ));
        TrackServer.setUdpPacketTimeout( dcs.getUdpPacketTimeoutMS( Constants.TIMEOUT_UDP_PACKET ));
        TrackServer.setUdpSessionTimeout(dcs.getUdpSessionTimeoutMS(Constants.TIMEOUT_UDP_SESSION));
    }
}

// ------------------------------------------------------------------------
// Start TrackServer (TrackServer is a singleton)

private static TrackServer trackServerInstance = null;

/* start TrackServer on array of ports */
public static TrackServer startTrackServer(int tcpPorts[], int udpPorts[], int commandPort)
    throws Throwable
{
    if (trackServerInstance == null) {
        trackServerInstance = new TrackServer(tcpPorts, udpPorts, commandPort);
    } else {
        //Print.logError("TrackServer already initialized!");
    }
    return trackServerInstance;
}

public static TrackServer getTrackServer()
{
    return trackServerInstance;
}

// ------------------------------------------------------------------------
// TCP Session timeouts

/* idle timeout */
private static long tcpTimeout_idle     = Constants.TIMEOUT_TCP_IDLE;
public static void setTcpIdleTimeout(long timeout)
{
    TrackServer.tcpTimeout_idle = timeout;
}
public static long getTcpIdleTimeout()
{
    return TrackServer.tcpTimeout_idle;
}

/* inter-packet timeout */
private static long tcpTimeout_packet   = Constants.TIMEOUT_TCP_PACKET;
public static void setTcpPacketTimeout(long timeout)
{
    TrackServer.tcpTimeout_packet = timeout;
}
public static long getTcpPacketTimeout()
{
    return TrackServer.tcpTimeout_packet;
}

/* total session timeout */
private static long tcpTimeout_session  = Constants.TIMEOUT_TCP_SESSION;
public static void setTcpSessionTimeout(long timeout)
{
    TrackServer.tcpTimeout_session = timeout;
}
public static long getTcpSessionTimeout()
{
    return TrackServer.tcpTimeout_session;
}

// ------------------------------------------------------------------------
// UDP Session timeouts

/* idle timeout */
private static long udpTimeout_idle     = Constants.TIMEOUT_UDP_IDLE;
public static void setUdpIdleTimeout(long timeout)
{
    TrackServer.udpTimeout_idle = timeout;
}
public static long getUdpIdleTimeout()
{
    return TrackServer.udpTimeout_idle;
}

/* inter-packet timeout */
private static long udpTimeout_packet   = Constants.TIMEOUT_UDP_PACKET;
public static void setUdpPacketTimeout(long timeout)
{
    TrackServer.udpTimeout_packet = timeout;
}
public static long getUdpPacketTimeout()
{
    return TrackServer.udpTimeout_packet;
}

/* total session timeout */
private static long udpTimeout_session  = Constants.TIMEOUT_UDP_SESSION;
public static void setUdpSessionTimeout(long timeout)
{
    TrackServer.udpTimeout_session = timeout;
}
public static long getUdpSessionTimeout()
{
    return TrackServer.udpTimeout_session;
}

// ------------------------------------------------------------------------
// ------------------------------------------------------------------------

// TCP port listener threads
private java.util.List<ServerSocketThread> tcpThread = new Vector<ServerSocketThread>();

// UDP port listener threads
private java.util.List<ServerSocketThread> udpThread = new Vector<ServerSocketThread>();

// Command port listener thread
private ServerSocketThread cmdThread = null;
private DatagramSocket     udpSocket = null;

// ------------------------------------------------------------------------

/* private constructor */
private TrackServer(int tcpPorts[], int udpPorts[], int commandPort)
    throws Throwable
{
    int listeners = 0;

    // Start TCP listeners
    if (!ListTools.isEmpty(tcpPorts)) {
        for (int i = 0; i < tcpPorts.length; i++) {
            int port = tcpPorts[i];
            if (ServerSocketThread.isValidPort(port)) {
                try {
                    this._startTCP(port);
                    listeners++;
                } catch (java.net.BindException be) {
                    Print.logError("TCP: Error binding to port: %d", port);
                }
            } else {
                throw new Exception("TCP: Invalid port number: " + port);
            }
        }
    }

    // Start UDP listeners
    if (!ListTools.isEmpty(udpPorts)) {
        for (int i = 0; i < udpPorts.length; i++) {
            int port = udpPorts[i];
            if (ServerSocketThread.isValidPort(port)) {
                try {
                    ServerSocketThread sst = this._startUDP(port);
                    if (this.udpSocket == null) {
                        this.udpSocket = sst.getDatagramSocket();
                    }
                    listeners++;
                } catch (java.net.BindException be) {
                    Print.logError("UDP: Error binding to port: %d", port);
                }
            } else {
                throw new Exception("UDP: Invalid port number: " + port);
            }
        }
    }

    /* do we have any active listeners? */
    if (listeners <= 0) {
        Print.logWarn("No active device communication listeners!");
    }

}

// ------------------------------------------------------------------------

/* start TCP listener */
private void _startTCP(int port)
    throws Throwable
{
    ServerSocketThread sst = null;

    /* create server socket */
    try {
        sst = new ServerSocketThread(port);
    } catch (Throwable t) { // trap any server exception
        Print.logException("ServerSocket error", t);
        throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.tcpTimeout_idle);         // time between packets
    sst.setPacketTimeout(TrackServer.tcpTimeout_packet);     // time from start of packet to packet completion
    sst.setSessionTimeout(TrackServer.tcpTimeout_session);   // time for entire session
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);
    sst.setLingerTimeoutSec(Constants.LINGER_ON_CLOSE_SEC);

    /* start thread */
    Print.logInfo("Starting TCP listener thread on port " + port + " [timeout=" + sst.getSessionTimeout() + "ms] ...");
    sst.start();
    this.tcpThread.add(sst);

}

// ------------------------------------------------------------------------

/* start UDP listener */
private ServerSocketThread _startUDP(int port)
    throws Throwable
{
    ServerSocketThread sst = null;

    /* create server socket */
    try {
        sst = new ServerSocketThread(ServerSocketThread.createDatagramSocket(port));
    } catch (Throwable t) { // trap any server exception
        Print.logException("ServerSocket error", t);
        throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.udpTimeout_idle);
    sst.setPacketTimeout(TrackServer.udpTimeout_packet);
    sst.setSessionTimeout(TrackServer.udpTimeout_session);
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);

    /* start thread */
    Print.logInfo("Starting UDP listener thread on port " + port + " [timeout=" + sst.getSessionTimeout() + "ms] ...");
    sst.start();
    this.udpThread.add(sst);
    return sst;

}

public DatagramSocket getUdpDatagramSocket()
{
    return this.udpSocket;
}

// ------------------------------------------------------------------------

}`

and in Constant.java find 'ASCII_LINE_TERMINATOR[] ' constant declaration and add '000' to with

public static final int     ASCII_LINE_TERMINATOR[]     = new int[] { 
    // this list has been construction by observation of various data packets
    0x00, 0xFF, 0xCE, '\0', '\n', '\r', ')', ';',000
};

after this cd $GTS_HOME ant tk10x bin/runserver.sh -s tk10x

This should do the trick

And here is a link to the package i created

https://anonfiles.com/file/0aae22ccb3822618fb693cd667283b18

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top