We would like to announce that Teltonika Telematics and Teltonika Mobility have joined forces!

As a result of the merge, from 2022-12-01 this forum will be left only as an archive for already existing Mobility related topics and questions.

We kindly ask all new and existing users to create and address your questions related to Mobility products on the Teltonika Telematics crowd support forum

We will meet you there!

Ask a question

334 questions

422 answers

324 comments

7594 members

Ask a question
0 votes
2,234 views
in Smart Autonomous Solutions by
Hello !

I have created my own system of sending commands to a Teltonika device. Of course, I use the Codec 12.

My program is able to send data, and recieve device response.
For example, I send "getinfo" to my TMT250 device and then, I get the decoded message.

So...All is fine ? No.

After the response of the device to the server, the device cut the connexion with my server.
Thus I can't resend a new command directly and I have to wait to get a new connection (sending of IMEI) established by the device.

Thus, I would like to know if the situation here above is normal ?
Else, which problem it could be ?

Thanks for your help,

Sincerely.
by

One year later, I would like to add informations on "How I have solved the problem".

Here is a diagram I have made for my studies...because I am just a student.

You can see that there is 2 red signs. It's the moment where your server and your tracker are communicating. In the exemple, the tracker send simple data every 30 seconds. There is a first communication (T) and a second 30 seconds later (T+30).

I have created an area (red hashed rectangle) in which I forbid my server to send a new command. Because when the trackers send a lot of informations to your server or when you just have "no chance" and then you send a command to the tracker, the command will often fail. And the connection will be closed until the next communication (IMEI sending).

So, my method is to send a command (for exemple) 5 seconds before T+30 or 5 seconds after T+30. You can modify the "5" number to an other higher number if it doesn't not work properly.
Thus, the command will be sent in the green area. Which will works in almost all cases.

There is two more things to do in my trick :

  • Create a queue of message when they haven't been sent.
  • Deduce when the next frame will be sent from the tracker.

I hope this trick will help some people.
Sincerely.

1 Answer

0 votes
by
Hello.

Describe the workflow of your server.

1. device connects to server

2. device sends imei packet to server.

3. server does not respond to imei -> but instead sends codec12 command to device?

If so - this is a problem - you should first accept device connection by sending response to imei packet -> 0x01. And then you can send / receive C12 commands.

Regards
by
Hello !

I am not a dev of Teltonika. I expect I can help you on this problem.

If your server use the TCP protocol, the first time the handshake is made between the server and the tracker, you must have a variable like "isConnected = false".

The first time, when you recieve the IMEI, you try to send a response to the tracker (0x01).

If all is good, you recieve no alert of a connection cut from your programming language. I think your programming language can alert you when you are sending a message to an unvailable connection.
The variable "isConnected" has switched to "true". (Even if it's not 100% reliable in my case).
And over all, you should recieve your data !

When I make my tests of data receiving, I simply put a low number (like 30 seconds) on the "send period" parameter of my tracker. So, if all is good, 30 seconds later, I should recieve a frame. I think it's the best solution to know if your tracker has received the 0x01 response. Else, it will continue to send its IMEI.

Also, I suggest you to have a look to the Teltonika server (created with C#). It was the best help to create my first server. Have a look at TcpClientService.cs. You have access to it when you are a Teltonika customer.

PS : If you want better response, you should create a new topic. But, I can continue to help you.

Sincerely.
by
Thanks for your valuable response. I checked the logs of device through terminal log and it shows me that device didn't receive my response 0x01 from server so the record sending event is cancelled.
by

I'm glad I could help you.
Thanks.

Maybe you should verify your code. I had take time to understand how to send data to a device.
I use the Java language, but I have learned thanks to the C# exemple of Teltonika. Maybe this class could be helpful : TcpClientService.cs.

In Java, it is something like :
byte[] response = new byte[] { 01 };
//Sending response
dataOutputStream.write(response);
dataOutputStream.flush();

Which programming language do you use ?

by
Hi! Thanks alot for giving the idea. It will be really helpful as I am also using JAVA language. Hopefully I will fix the issue now.

Thanks & Regards
by
Hello !

No problem.
Don't hesitate to ask me questions.

Sincerely.