Raghava
Raghava

Reputation: 19

How to handle data from a Teltonika GPS device using sockets in Java

I'm getting data from a Teltonika GPS device and storing it in my application. The first time I connect I get the data, however the device requires some kind of acknowledgment and it's waiting for that.

Can anyone explain how to handle data from a GPS device through java socket programming?

Upvotes: 0

Views: 6135

Answers (3)

Shiko
Shiko

Reputation: 2624

You have to configure your tracker first using below steps as in figure:

To initiate configuration process, configuration server sends binary initiation SMS (“Push” SMS) containing server host(ip address) and tcp port device should connect to and waits for TCP connection.

Upon reception of “push” SMS, device tries to establish TCP connection to configuration server using GPRS. If TCP connection attempt succeeds, server sends out configuration data to device over established connection, device confirms configuration reception and configures itself.

If device doesn‘t connect to server in TcpWaitTimeout time, server stops waiting for TCP connection, sends out configuration data using binary SMS, and waits for confirmation SMS from device. If confirmation SMS doesn‘t arrive in specified time, server assumes that configuration process failed.

enter image description here

Reference file: https://sourceforge.net/p/opengts/discussion/579834/thread/6fd0ffe8/6213/attachment/FMXXXX%20Protocols%20v2.10.pdf

Upvotes: 0

dkasipovic
dkasipovic

Reputation: 6120

Teltonika devices generally wait for acknowledgement after sending the data. Server's response should be number of decoded points (since Teltonika devices pack few points together, and after you decode their format, you need to respond with number of decoded gps points).

Upvotes: 0

Fraser
Fraser

Reputation: 17059

It will depend on the device and the protocol used to communicate with it, but as a general rule you would need to make sure the socket is open and listening.

From the brief out-line of your problem I would think that the issue is that you are either forcibly closing the socket yourself, or you are not listening for a connection properly.

Does you code have a loop around a call to Socket.accept() - something like..

while (true) {
  Socket socket = server.accept();

  // handle the coms...
}

Basically, to keep communicating with something you need to keep accepting or 'listening' for responses, otherwise you will only get one response. The call to accept is a blocking call that basically waits for clients to connect...but if it is not called again, you have effectively stopped accepting or 'listening'

Upvotes: 1

Related Questions