FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

4167 questions

4739 answers

3460 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
3,580 views
in Vehicle tracking by
Hello,

My tracker works fine with SMS commands, now I want to use GPRS mode,

I created my own program that listens on the network using TCP sockets, I configured in FBM001 server IP and Port and TCP mode,

When I start my program I receive in the socket canal only empty messages evry 30 seconds +/- ? How it works please  for GPRS ?

So how can I send GPRS commands ? I tried to write on the socket channel some commands : "getgps" or "ggps" or "user pass getgps" but nothing,

What is the syntax exactly for GPS, the same as SMS with username and password ? or I send only command using GPRS without username and password ?

Why I receive evry 30 or 40 seconds empty message ? maybe to write in socket my command when I receive empty message ?

Otherwise how can establish communication with my program and my device using TCP sockets please ?

Thank you,

3 Answers

0 votes
by anonymous
Hello.

It would be best if you provided what packets you receive. They cannot be empty.

They most likely are 17 bytes information. Because our FMB devices on connect to server send 17 bytes. first 2 bytes are sort of "imei length". And are like this:

000F333532303934303833393730353438

i.e. 000F - 15. and rest 15 bytes are device imei in ASCII sort of.

My assumption is - that when device connects to your program server - your program server does not send ACK to this imei packet. And thus device after 30 seconds closes  link. (due to no ACK).

So first of all - you have to send 0x01 byte to this "imei packet".

After you do this - device will be sending record packets to server if it has any. Records acknowledgement (if sent via TCP) is 4 bytes. Example:

2018.11.02 14:50:18.925000 >> Packet len: 47, data: 0000000000000023080100000166D478F9B000000000000000000000000000000000000101EF000000000100008D7D
2018.11.02 14:50:18.925000 >> this is correct single packet, CRC OK
2018.11.02 14:50:18.925000 >> Sending NOD: 00000001

How to know how many records device sent you?

Records packet structure is like this:

if codec 8 is used: https://wiki.teltonika.lt/view/Codec_8

Those number of data fields - are exactly this NOD (number of data "packets").

So anyway - once you accept device imei packet- device will not close the data link, but if device sends a record packet to server - server has according to "response timeout parameter" - this much time to answer to this records packet. If server does not answer - device will close data link again. (due to server no answer).

GPRS codec 12 commands for FMB devices:

https://wiki.teltonika.lt/view/FMB120_SMS/GPRS_command_list

How codec12 packets (gprs packets) are created:
https://wiki.teltonika.lt/view/Codec_12
https://community.teltonika-gps.com/1166/any-gprs-command-list - in this case ive provided a program for creating codec12 packets. You can use it as example for comparing with your program.

Regards
by anonymous

So how can I send GPRS commands ? I tried to write on the socket channel some commands : "getgps" or "ggps" or "user pass getgps" but nothing,

000000000000000e0c010500000006676574677073010000ccd7 - getgps gprs codec12 packet.

000000000000000c0c01050000000467677073010000efca - ggps


What is the syntax exactly for GPS, the same as SMS with username and password ? or I send only command using GPRS without username and password ?

[AA] GPRS codec 12 commands formation - https://wiki.teltonika.lt/view/Codec_12

Why I receive evry 30 or 40 seconds empty message ? maybe to write in socket my command when I receive empty message ?

[AA] Define empty, i very much doubt it is empty. Provide packet please. Best would be if its printed in hex string.

Otherwise how can establish communication with my program and my device using TCP sockets please ?

[AA] working program example - is provided in https://community.teltonika-gps.com/1166/any-gprs-command-list.

You can use that program. If you were to type .getgps to command window, when FMB device will be connected to that server_main program. The program will pack this [getgps] into codec12 packet and send to server. Program also automatically accepts device imei packets and automatically answers to received records.

0 votes
by

Hello,

Thank you for answers,

I followed your help : https://wiki.teltonika.lt/view/Codec_12

With Hercules tools I try to comunicate with my device using these steps : 

Step 1 => I received correctly IMEI number,

Step 2 => I sent 01 (for 0x01 hexa),

Step 3 => I received Data array :

Step 4 => How can send Data array ACK ? Your codec wiki says <<The acknowledgement of each data array send from FMXXXX is four bytes integer – number of records received.>> How can I do that ? What I have to send (in hexa) for Data array ACK ? I tried four bytes 01010101 but no thing, I also tried to request "getinfo" command : 00000000000000110C010500000009676574696E666F0D0A010000DA7E  but nothing to :(

Any idea please ?

Thank you,

0 votes
by

Hello,

1st step. I received IMEI number packet :

Hexa Value : 0x00 0x0f 0x33 0x35 0x32 0x30 0x39 0x34 0x30 0x38 0x33 0x39 0x33 0x39 0x38 0x35 0x37 

Decimal value : 352094083939857 (it's correct this my device IMEI).

2nd step. I sent ACK : 0x01

3rd step. I received a big message data (1001 bytes) : 

00 00 00 00 00 00 03 DD 08 11 00 00 01 67 45 B7 . . . . . . . . . . . . . . . . . . . . . . . . . . 00 00 00 11 00 00 94 70

4th step. How can I send Data aray ACK ? look to the following picture please of codec 12 manual (Data array ACK) :

- I tried to send a simple ACK (0x01)

- I tried to send a number of records "989" (in hexa : 0x03 0xDD)

- I tried to send a packet data length "1001" (in hexa : 0x03 0xE9)

then I sent getinfo command : 00000000000000110C010500000009676574696E666F0D0A010000DA7E

But nothing :( the problem is my "Data array ACK" what can I send exactly with my example when I receive :

00 00 00 00 00 00 03 DD 08 11 00 00 01 67 45 B7 . . . . . . . . . . . . . . . . . . . . . . . . . 00 00 00 11 00 00 94 70

Thank you :)

by
Hi Rose,

Did you solve your issue?
If yes - how? Could you describe last step?

Thanks.
by anonymous

Hi Dim,

Yes I resolved my problem,

When you receive your AVL paquet with "Data Array", you should send  "Data Array ACK" (which contains the number of received data).

To find the number of data it depends on your device model and Firmware version (to know which codec to use Codec8 or Codec12...).

For example I bought FMB001 (it uses Codec8) I upgraded my Firmware version to use Codec12). But be careful :

Even if you upgrade your device you will continue to receive AVL packets with your device native, Codec Exemple :

I upgraded my FMB001 Firmware to use Codec12 (but I continue to receive AVL paquets in Codec8 every x time).

Only when I send commands with Codec12 I receive answers with Codec12 but recurrent packets still in Codec8.

I suppose your AVL is Codec8 format (like me) : https://wiki.teltonika.lt/view/Codec_8

AVL data packet structure :

You can check your Codec in 9th (Codec ID) : 0x08 (Codec8) or 0x0C (Codec 12).

And you can find your number of received data in "Number of Data 1" field.

Keep in mind your server must report to device the number of received data (Hexa Value).

So you can easly extract number of data from this field, depends on your programming language :

My Windev Programming Language example :

sHexaMsg is string = GetHexa(_bufMsg) // First I convert received message to Hexa value, each Byte 2 positions (0x01 = one Byte).

sHexaMsg = sHexaMsg[[19 TO 20]] // Extract Number of Data from 10th Byte in 19th and 20th positions (One Byte in Hexa Value).

iNumberOfData is int = Val(sHexaMsg,"x") // Integer Value. Ex : 0x11 (Hexa) = 17 (Integer).

sResult is string = NumToString(iNumberOfData, "08X") // Convert 17 (Integer) to 4 bytes (8 positions) 00 00 00 11.

bufReplay is buffer = HexaToBuffer(sResult) // I put Hexa value the buffer (maybe no, depends on your language).

SocketWrite(sDeviceChannel,bufReplay) // I send answer to device.

I hope my answer will help you :)

Good luck.

by
Yes, it's very helpful! :)
Thank you for your time and detailed response, Rose.