Bootstrap LLM-maintained wiki with TRM architecture knowledge
Initialize CLAUDE.md schema, index, and log; ingest three architecture sources (system overview, Teltonika ingestion design, official Teltonika data-sending protocols) into 7 entity pages, 8 concept pages, and 3 source pages with wikilink cross-references.
This commit is contained in:
@@ -0,0 +1,842 @@
|
||||
---
|
||||
title: "Teltonika Data Sending Protocols - Teltonika Telematics Wiki"
|
||||
source: "https://wiki.teltonika-gps.com/view/Teltonika_Data_Sending_Protocols#Codec_8"
|
||||
author:
|
||||
published:
|
||||
created: 2026-04-30
|
||||
description:
|
||||
tags:
|
||||
- "clippings"
|
||||
---
|
||||
[Main Page](https://wiki.teltonika-gps.com/view/Main_Page) > [General Information](https://wiki.teltonika-gps.com/view/General_Information) > **Teltonika Data Sending Protocols**
|
||||
|
||||
## Introduction
|
||||
|
||||
A codec is a device or computer program for encoding or decoding a digital data stream or signal. Codec is a portmanteau of coder-decoder. A codec encodes a data stream or a signal for transmission and storage, possibly in encrypted form, and the decoder function reverses the encoding for playback or editing.
|
||||
|
||||
Below you will see a table of all Codec types with IDs:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Codec 8</th><th rowspan="1">Codec 8 Extended</th><th rowspan="1">Codec 16</th><th rowspan="1">Codec 12</th><th colspan="1">Codec 13</th><th rowspan="1">Codec 14</th></tr><tr><td>0x08</td><td>0x8E</td><td>0x10</td><td>0x0C</td><td>0x0D</td><td>0x0E</td></tr></tbody></table>
|
||||
|
||||
Also, there are using two data transport protocols: TCP and UDP. But it is not important which one will be used in Codec.
|
||||
|
||||
## Codec for device data sending
|
||||
|
||||
In this chapter, you will find information about every Codec protocol which are used for device data sending and the differences between them.
|
||||
|
||||
## Codec 8
|
||||
|
||||
- **Protocol Overview**
|
||||
|
||||
Codec8 – a main FM device protocol that is used for sending data to the server.
|
||||
|
||||
- **Codec 8 protocol sending over TCP**
|
||||
|
||||
TCP is a connection-oriented protocol that is used for communication between devices. The workings of this type of protocol is described below in the **communication with server** section.
|
||||
|
||||
- **AVL Data Packet**
|
||||
|
||||
The below table represents the AVL Data Packet structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Field Length</th><th rowspan="1">Codec ID</th><th rowspan="1">Number of Data 1</th><th colspan="1">AVL Data</th><th rowspan="1">Number of Data 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** – the packet starts with four zero bytes.
|
||||
**Data Field Length** – size is calculated starting from Codec ID to Number of Data 2.
|
||||
**Codec ID** – in Codec8 it is always `0x08`.
|
||||
**Number of Data 1** – a number that defines how many records are in the packet.
|
||||
**AVL Data** – actual data in the packet (more information below).
|
||||
**Number of Data 2** – a number that defines how many records are in the packet. This number must be the same as “Number of Data 1”.
|
||||
**CRC-16** – calculated from Codec ID to the Second Number of Data. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
**Note:** for [FMB640](https://wiki.teltonika-gps.com/view/FMB640 "FMB640"), [FMB641](https://wiki.teltonika-gps.com/view/FMB641 "FMB641"), [FMC640](https://wiki.teltonika-gps.com/view/FMC640 "FMC640"), and [FMM640](https://wiki.teltonika-gps.com/view/FMM640 "FMM640"), minimum AVL record size is 45 bytes (all IO elements disabled). The maximum AVL record size is 255 bytes. Maximum AVL packet size is 512 bytes. For other devices, the minimum AVL record size is 45 bytes (all IO elements disabled). Maximum AVL packet size is 1280 bytes.
|
||||
|
||||
- AVL Data
|
||||
|
||||
The below table represents the AVL Data structure.
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Timestamp</th><th rowspan="1">Priority</th><th rowspan="1">GPS Element</th><th rowspan="1">IO Element</th></tr><tr><td>8 bytes</td><td>1 byte</td><td>15 bytes</td><td>X bytes</td></tr></tbody></table>
|
||||
|
||||
**Timestamp** – a difference, in milliseconds, between the current time and midnight, January 1970 UTC (UNIX time).
|
||||
**Priority** – a field that defines AVL data priority (more information below).
|
||||
**GPS Element** – location information of the AVL data (more information below).
|
||||
**IO Element** – additional configurable information from the device (more information below).
|
||||
|
||||
- Priority
|
||||
|
||||
The below table represents Priority values. Packet priority depends on device configuration and records sent.
|
||||
|
||||
<table><tbody><tr><th colspan="2">Priority</th></tr><tr><th rowspan="1">0</th><td>Low</td></tr><tr><th rowspan="1">1</th><td>High</td></tr><tr><th rowspan="1">2</th><td>Panic</td></tr></tbody></table>
|
||||
|
||||
- GPS element
|
||||
|
||||
The below table represents the GPS Element structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Longitude</th><th rowspan="1">Latitude</th><th rowspan="1">Altitude</th><th rowspan="1">Angle</th><th rowspan="1">Satellites</th><th rowspan="1">Speed</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>2 bytes</td><td>2 bytes</td><td>1 byte</td><td>2 bytes</td></tr></tbody></table>
|
||||
|
||||
**Longitude** – east-west position.
|
||||
**Latitude** – north-south position.
|
||||
**Altitude** – meters above sea level.
|
||||
**Angle** – degrees from north pole.
|
||||
**Satellites** – number of satellites in use.
|
||||
**Speed** – speed calculated from satellites.
|
||||
|
||||
**Note:** Speed will be `0x0000` if GPS data is invalid.
|
||||
|
||||
Longitude and latitude are integer values built from degrees, minutes, seconds, and milliseconds by the formula:
|
||||

|
||||
Where:
|
||||
d – Degrees; m – Minutes; s – Seconds; ms – Milliseconds; p – Precision (10000000)
|
||||
If the longitude is in the west or latitude in the south, multiply the result by –1.
|
||||
|
||||
Note:
|
||||
To determine if the coordinate is negative, convert it to binary format and check the very first bit. If it is 0, the coordinate is positive. If it is 1, the coordinate is negative.
|
||||
|
||||
Example:
|
||||
Received value: `20 9C CA 80` converted to BIN: `00100000 10011100 11001010 10000000` first bit is 0, which means coordinate is positive converted to DEC: `547146368`. For more information see two‘s complement arithmetic.
|
||||
|
||||
- IO Element
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Event IO ID</th><td>1 byte</td><td rowspan="26"></td><td rowspan="26"><b>Event IO ID</b> – if data is acquired on the event – this field defines which IO property has changed and generated an event. For example, when if the Ignition state changes and it generates an event, the Event IO ID will be <code>0xEF</code> (AVL ID: 239). If it’s not an eventual record – the value is 0.<br><p><b>N</b> – a total number of properties coming with record (N = N1 + N2 + N4 + N8).<br><b>N1</b> – number of properties, which length is 1 byte.<br><b>N2</b> – number of properties, which length is 2 bytes.<br><b>N4</b> – number of properties, which length is 4 bytes.<br><b>N8</b> – number of properties, which length is 8 bytes.<br><b>N’th IO ID</b> - AVL ID.<br><b>N’th IO Value</b> - AVL ID value.</p></td></tr><tr><th rowspan="1">N of Total IO</th><td>1 byte</td></tr><tr><th rowspan="1">N1 of One Byte IO</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO Value</th><td>1 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N1’th IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">N1’th IO Value</th><td>1 byte</td></tr><tr><th rowspan="1">N2 of Two Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO Value</th><td>2 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N2’th IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">N2’th IO Value</th><td>2 bytes</td></tr><tr><th rowspan="1">N4 of Four Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO Value</th><td>4 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N4’th IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">N4’th IO Value</th><td>4 byte</td></tr><tr><th rowspan="1">N8 of Eight Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO Value</th><td>8 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N8’IO ID</th><td>1 byte</td></tr><tr><th rowspan="1">N8’IO Value</th><td>8 bytes</td></tr></tbody></table>
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
First, when the module connects to the server, the module sends its IMEI. First comes a short identifying the number of bytes written and then goes IMEI as text (bytes).
|
||||
For example, IMEI `356307042441013` would be sent as `000F333536333037303432343431303133`.
|
||||
The first two bytes denote IMEI length. In this case `0x000F` means, that IMEI is 15 bytes long.
|
||||
After receiving IMEI, the server should determine if it would accept data from this module. If yes, server will reply to module `01`, if not - `00`. Note that confirmation should be sent as a binary packet. I.e. 1 byte `0x01` or `0x00`.
|
||||
Then the module starts to send the first AVL data packet. After the server receives a packet and parses it, the server must report to the module number of data received as an integer (four bytes).
|
||||
If the sent data number and the reported by the server don’t match module resends the sent data.
|
||||
|
||||
- Example:
|
||||
|
||||
The module connects to the server and sends IMEI:
|
||||
`000F333536333037303432343431303133`
|
||||
The server accepts the module:
|
||||
01
|
||||
The module sends data packet:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">AVL Data Packet Header</th><th rowspan="1">AVL Data Array</th><th rowspan="1">CRC-16</th></tr><tr><td>Four Zero Bytes – 0x00000000,<p>“AVL Data Array” length – 0x000000FE</p></td><td>Codec ID – 0x08,<p>Number of Data – <b>0x02</b><br>(Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>CRC of “AVL Data Array”</td></tr><tr><td>00000000000000FE</td><td>08 <b>02</b>...(data elements)...<b>02</b></td><td>00008612</td></tr></tbody></table>
|
||||
|
||||
Server acknowledges data reception (2 data elements): **`00000002`**
|
||||
|
||||
- **Examples**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in these examples are given in the hexadecimal form. The different fields of packets are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
**1'st example**
|
||||
Receiving one data record with each element property (1 byte, 2 bytes, 4 bytes, and 8 bytes).
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`000000000000003608010000016B40D8EA30010000000000000000000000000000000105021503010101425E0F01F10000601A014E0000000000000000010000C7CF`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="4"></td><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Field Length</td><td>00 00 00 36</td></tr><tr><td>Codec ID</td><td>08</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td rowspan="24">AVL Data</td><td>Timestamp</td><td>00 00 01 6B 40 D8 EA 30 (GMT: Monday, June 10, 2019, 10:04:46 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>01</td></tr><tr><td>N of Total ID</td><td>05</td></tr><tr><td>N1 of One Byte IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>15 (AVL ID: 21, Name: GSM Signal)</td></tr><tr><td>1’st IO Value</td><td>03</td></tr><tr><td>2’nd IO ID</td><td>01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>2’nd IO Value</td><td>01</td></tr><tr><td>N2 of Two Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>1’st IO Value</td><td>5E 0F</td></tr><tr><td>N4 of Four Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>F1 (AVL ID: 241, Name: Active GSM Operator)</td></tr><tr><td>1’st IO Value</td><td>00 00 60 1A</td></tr><tr><td>N8 of Eight Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>4E (AVL ID: 78, Name: iButton)</td></tr><tr><td>1’st IO Value</td><td>00 00 00 00 00 00 00 00</td></tr><tr><td rowspan="2"></td><td>Number of Data 2 (Number of Total Records)</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 C7 CF</td></tr></tbody></table>
|
||||
|
||||
Server response: `00000001`
|
||||
|
||||
**2'nd example**
|
||||
Receiving one data record with one or two different element properties (1 byte, 2 bytes).
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`000000000000002808010000016B40D9AD80010000000000000000000000000000000103021503010101425E100000010000F22A`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="4"></td><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Field Length</td><td>00 00 00 28</td></tr><tr><td>Codec ID</td><td>08</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td rowspan="20">AVL Data</td><td>Timestamp</td><td>00 00 01 6B 40 D9 AD 80 (GMT: Monday, June 10, 2019, 10:05:36 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>01</td></tr><tr><td>N of Total ID</td><td>03</td></tr><tr><td>N1 of One Byte IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>15 (AVL ID: 21, Name: GSM Signal)</td></tr><tr><td>1’st IO Value</td><td>03</td></tr><tr><td>2’nd IO ID</td><td>01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>2’nd IO Value</td><td>01</td></tr><tr><td>N2 of Two Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>1’st IO Value</td><td>5E 0F</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td rowspan="2"></td><td>Number of Data 2 (Number of Total Records)</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 F2 2A</td></tr></tbody></table>
|
||||
|
||||
Server response: `00000001`
|
||||
|
||||
**3'rd example**
|
||||
Receiving two or more data records with one or more different element properties.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`000000000000004308020000016B40D57B480100000000000000000000000000000001010101000000000000016B40D5C198010000000000000000000000000000000 101010101000000020000252C`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="4"></td><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Field Length</td><td>00 00 00 43</td></tr><tr><td>Codec ID</td><td>08</td></tr><tr><td>Number of Data 1 (Records)</td><td>02</td></tr><tr><td rowspan="16">AVL Data<p>(1'st record)</p></td><td>Timestamp</td><td>00 00 01 6B 40 D5 7B 48 (GMT: Monday, June 10, 2019, 10:01:01 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>01</td></tr><tr><td>N of Total ID</td><td>01</td></tr><tr><td>N1 of One Byte IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>00</td></tr><tr><td>N2 of Two Bytes IO</td><td>00</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td rowspan="16">AVL Data<p>(2'nd record)</p></td><td>Timestamp</td><td>00 00 01 6B 40 D5 C1 98 (GMT: Monday, June 10, 2019 10:01:19 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>01</td></tr><tr><td>N of Total ID</td><td>01</td></tr><tr><td>N1 of One Byte IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>01</td></tr><tr><td>N2 of Two Bytes IO</td><td>00</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td rowspan="2"></td><td>Number of Data 2 (Number of Total Records)</td><td>02</td></tr><tr><td>CRC-16</td><td>00 00 25 2C</td></tr></tbody></table>
|
||||
|
||||
Server response: `00000002`
|
||||
|
||||
- **Codec8 protocol sending over UDP**
|
||||
|
||||
Codec8 protocol \[over UDP\] is a transport layer protocol above UDP/IP to add reliability to plain UDP/IP using acknowledgment packets.
|
||||
|
||||
- **AVL Data Packet**
|
||||
|
||||
The packet structure is as follows:
|
||||
|
||||
<table><tbody><tr><th colspan="2">UDP Datagram</th></tr><tr><td>Example</td><td>2 bytes</td></tr><tr><td>Packet ID</td><td>2 bytes</td></tr><tr><td>Not Usable Byte</td><td>1 byte</td></tr><tr><td>Packet Payload</td><td>Variable</td></tr></tbody></table>
|
||||
|
||||
**Example** – packet length (excluding this field) in big ending byte order.
|
||||
**Packet ID** – packet ID unique for this channel.
|
||||
**Not Usable Byte** – not usable byte.
|
||||
**Packet payload** – data payload.
|
||||
|
||||
- Acknowledgment packet
|
||||
|
||||
The acknowledgment packet should have the same Packet ID as an acknowledged data packet and empty Data Payload. Acknowledgment should be sent in binary format.
|
||||
|
||||
<table><tbody><tr><th colspan="3">Acknowledgment Packet</th></tr><tr><th rowspan="1">Packet Length</th><th rowspan="1">Packet ID</th><th rowspan="1">Not Usable Byte</th></tr><tr><td>2 bytes</td><td>2 bytes</td><td>1 byte</td></tr></tbody></table>
|
||||
|
||||
**Packet Length** – packet length by sending/response data.
|
||||
**Packet ID** – same as in acknowledgment packet.
|
||||
**Not Usable Byte** – always will be `0x01`.
|
||||
|
||||
- Sending AVL Packet Payload using UDP channel
|
||||
|
||||
The below table represents the Sending Packet Payload structure.
|
||||
|
||||
<table><tbody><tr><th colspan="4">AVL data encapsulated in UDP channel packet</th></tr><tr><th rowspan="1">AVL Packet ID</th><th rowspan="1">IMEI Length</th><th rowspan="1">Module IMEI</th><th rowspan="1">AVL Data Array</th></tr><tr><td>1 byte</td><td>2 bytes</td><td>15 bytes</td><td>X bytes</td></tr></tbody></table>
|
||||
|
||||
**AVL Packet ID** – ID identifying this AVL packet.
|
||||
**IMEI Length** – always will be `0x000F`.
|
||||
**Module IMEI** – IMEI of a sending module encoded the same as with TCP.
|
||||
**AVL Data Array** – an array of encoded AVL data (same as TCP AVL Data Array).
|
||||
|
||||
- Server response Packet Payload using UDP channel
|
||||
|
||||
The below table represents the Server Response Packet Payload structure.
|
||||
|
||||
<table><tbody><tr><th colspan="2">Server Response to AVL Data Packet</th></tr><tr><th rowspan="1">AVL Packet ID</th><th rowspan="1">Number of Accepted AVL Elements</th></tr><tr><td>1 byte</td><td>1 byte</td></tr></tbody></table>
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
The module sends the UDP channel packet with an encapsulated AVL data packet. The server sends the UDP channel packet with an encapsulated response module that validates the AVL Packet ID and the Number of accepted AVL elements. If the server response is not received with a valid AVL Packet ID within configured timeout, the module can retry sending.
|
||||
|
||||
- Example:
|
||||
|
||||
The module sends the data:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Header</th><th rowspan="1">AVL Data Array</th></tr><tr><td>Length – 0x00FE,<p>Packet ID – 0xCAFE<br>Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>IMEI Length – 0x000F<br>IMEI – 0x313233343536373839303132333435 (Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>Codec ID – 0x08,<p>Number of Data – 0x02<br>(Encoded using continuous bit stream)</p></td></tr><tr><td>00FECAFE01</td><td>DD000F3133343536373839303132333435</td><td>0802…(data elements)…02</td></tr></tbody></table>
|
||||
|
||||
The server must respond with an acknowledgment:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Acknowledgment</th></tr><tr><td>Length – 0x0005,<p>Packet ID – 0xCAFE, Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>Number of Accepted Data – 0x02</p></td></tr><tr><td>0005CAFE01</td><td>DD02</td></tr></tbody></table>
|
||||
|
||||
- **Example**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in this example is given in the hexadecimal form. The different fields of the packet are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`003DCAFE0105000F33353230393330383634303336353508010000016B4F815B30010000000000000000000000000000000103021503010101425DBC000001`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>00 3D</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="3">AVL Packet Header</td><td>AVL packet ID</td><td>05</td></tr><tr><td>IMEI Length</td><td>00 0F</td></tr><tr><td>IMEI</td><td>33 35 32 30 39 33 30 38 36 34 30 33 36 35 35</td></tr><tr><td rowspan="23">AVL Data Array</td><td>Codec ID</td><td>08</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td>Timestamp</td><td>00 00 01 6B 4F 81 5B 30 (GMT: Thursday, June 13, 2019, 6:23:26 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>01</td></tr><tr><td>N of Total ID</td><td>03</td></tr><tr><td>N1 of One Byte IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>15 (AVL ID: 21, Name: GSM Signal)</td></tr><tr><td>1’st IO Value</td><td>03</td></tr><tr><td>2’nd IO ID</td><td>01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>2’nd IO Value</td><td>01</td></tr><tr><td>N2 of Two Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>1’st IO Value</td><td>5D BC</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of EightBytes IO</td><td>00</td></tr><tr><td>Number of Data 2 (Number of Total Records)</td><td>01</td></tr></tbody></table>
|
||||
|
||||
The server response in the hexadecimal stream: `0005CAFE010501`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">Server Response to AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">Server Response Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>00 05</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="2">AVL Packet Acknowledgment</td><td>AVL packet ID</td><td>05</td></tr><tr><td>Number of Accepted Data</td><td>01</td></tr></tbody></table>
|
||||
|
||||
## Codec 8 Extended
|
||||
|
||||
- **Protocols overview**
|
||||
|
||||
Codec8 Extended is used for FMBXXX family devices. This protocol looks familiar to Codec8 but they have some differences. The main differences between them are shown in below table:
|
||||
|
||||
<table><tbody><tr><th rowspan="1"></th><th rowspan="1">Codec8</th><th rowspan="1">Codec8 Extended</th></tr><tr><th rowspan="1">Codec ID</th><td>0x08</td><td>0x8E</td></tr><tr><th rowspan="1">AVL Data IO element length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">AVL Data IO element total IO count length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">AVL Data IO element IO count length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">AVL Data IO element AVL ID length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">Variable size IO elements</th><td>Does not include</td><td>Includes variable size elements</td></tr></tbody></table>
|
||||
|
||||
- **Codec 8 Extended protocol sending over TCP**
|
||||
- **AVL data packet**
|
||||
|
||||
The below table represents the AVL data packet structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Field Length</th><th rowspan="1">Codec ID</th><th rowspan="1">Number of Data 1</th><th colspan="1">AVL Data</th><th rowspan="1">Number of Data 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** – the packet starts with four zero bytes.
|
||||
**Data Field Length** – size is calculated starting from Codec ID to Number of Data 2.
|
||||
**Codec ID** – in Codec8 Extended it is always `0x8E`.
|
||||
**Number of Data 1** – a number that defines how many records are in the packet.
|
||||
**AVL Data** – actual data in the packet (more information below).
|
||||
**Number of Data 2** – a number that defines how many records are in the packet. This number must be the same as “Number of Data 1”.
|
||||
**CRC-16** – calculated from Codec ID to the Second Number of Data. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
**Note:** for [FMB640](https://wiki.teltonika-gps.com/view/FMB640 "FMB640"), [FMB641](https://wiki.teltonika-gps.com/view/FMB641 "FMB641"), [FMC640](https://wiki.teltonika-gps.com/view/FMC640 "FMC640"), and [FMM640](https://wiki.teltonika-gps.com/view/FMM640 "FMM640"), minimum AVL record size is 45 bytes (all IO elements disabled). The maximum AVL record size is 255 bytes. For other devices, the minimum AVL record size is 45 bytes (all IO elements disabled). Maximum AVL packet size is 1280 bytes.
|
||||
|
||||
- AVL Data
|
||||
|
||||
The below table represents the AVL Data structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Timestamp</th><th rowspan="1">Priority</th><th rowspan="1">GPS Element</th><th rowspan="1">IO Element</th></tr><tr><td>8 bytes</td><td>1 byte</td><td>15 bytes</td><td>X bytes</td></tr></tbody></table>
|
||||
|
||||
**Timestamp** – a difference, in milliseconds, between the current time and midnight, January 1970 UTC (UNIX time).
|
||||
**Priority** – a field that defines AVL data priority (more information below).
|
||||
**GPS Element** – locational information of the AVL data (more information below).
|
||||
**IO Element** – additional configurable information from the device (more information below).
|
||||
|
||||
- Priority
|
||||
|
||||
The below table represents Priority values. Packet priority depends on device configuration and records sent.
|
||||
|
||||
<table><tbody><tr><th colspan="2">Priority</th></tr><tr><th rowspan="1">0</th><td>Low</td></tr><tr><th rowspan="1">1</th><td>High</td></tr><tr><th rowspan="1">2</th><td>Panic</td></tr></tbody></table>
|
||||
|
||||
- GPS element
|
||||
|
||||
The below table represents the GPS Element structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Longitude</th><th rowspan="1">Latitude</th><th rowspan="1">Altitude</th><th rowspan="1">Angle</th><th rowspan="1">Satellites</th><th rowspan="1">Speed</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>2 bytes</td><td>2 bytes</td><td>1 byte</td><td>2 bytes</td></tr></tbody></table>
|
||||
|
||||
**Longitude** – east-west position.
|
||||
**Latitude** – north-south position.
|
||||
**Altitude** – meters above sea level.
|
||||
**Angle** – degrees from north pole.
|
||||
**Satellites** – number of satellites in use.
|
||||
**Speed** – speed calculated from satellites.
|
||||
|
||||
**Note:** Speed will be `0x0000` if GPS data is invalid.
|
||||
|
||||
Longitude and latitude are integer values built from degrees, minutes, seconds, and milliseconds by the formula:
|
||||

|
||||
Where:
|
||||
d – Degrees; m – Minutes; s – Seconds; ms – Milliseconds; p – Precision (10000000)
|
||||
If the longitude is in the west or latitude in the south, multiply the result by –1.
|
||||
|
||||
Note:
|
||||
To determine if the coordinate is negative, convert it to binary format and check the very first bit. If it is `0`, the coordinate is positive, if it is `1`, the coordinate is negative.
|
||||
|
||||
Example:
|
||||
Received value: `20 9C CA 80` converted to BIN: `00100000 10011100 11001010 10000000` first bit is 0, which means coordinate is positive converted to DEC: `547146368`. For more information see two‘s complement arithmetic.
|
||||
|
||||
- IO Element
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Event IO ID</th><td>2 bytes</td><td rowspan="33"></td><td rowspan="33"><b>Event IO ID</b> – if data is acquired on the event – this field defines which IO property has changed and generated an event. For example, when if the Ignition state changes and it generates an event, the Event IO ID will be 0x00EF (AVL ID: 239). If it’s not an eventual record – the value is 0x0000.<br><p><b>N</b> – a total number of properties coming with record (N = N1 + N2 + N4 + N8).<br><b>N1</b> – number of properties, which length is 1 byte.<br><b>N2</b> – number of properties, which length is 2 bytes.<br><b>N4</b> – number of properties, which length is 4 bytes.<br><b>N8</b> – number of properties, which length is 8 bytes.<br><b>NX</b> – a number of properties, which length is defined by the length element. <b>N’th IO ID</b> - AVL ID.<br><b>N'th Lenght</b> - AVL ID value lenght.<br><b>N’th IO Value</b> - AVL ID value.<br></p></td></tr><tr><th rowspan="1">N of Total IO</th><td>2 bytes</td></tr><tr><th rowspan="1">N1 of One Byte IO</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>1 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N1’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N1’th IO Value</th><td>1 byte</td></tr><tr><th rowspan="1">N2 of Two Bytes</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>2 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N2’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N2’th IO Value</th><td>2 bytes</td></tr><tr><th rowspan="1">N4 of Four Bytes</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>4 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N4’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N4’th IO Value</th><td>4 byte</td></tr><tr><th rowspan="1">N8 of Eight Bytes</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>8 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N8’IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N8’IO Value</th><td>8 bytes</td></tr><tr><th rowspan="1">NX of X Byte IO</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Length</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>Defined by length</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">NX’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">NX’th Length</th><td>2 bytes</td></tr><tr><th rowspan="1">NX’th Value</th><td>Defined by length</td></tr></tbody></table>
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
Communication with the server is the same as with the Codec8 protocol, except in Codec8 Extended protocol Codec ID is 0x8E.
|
||||
|
||||
- Example:
|
||||
|
||||
The module connects to the server and sends IMEI:
|
||||
`000F333536333037303432343431303133`
|
||||
The server accepts the module:
|
||||
`01`
|
||||
The module sends data packet:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">AVL Data Packet Header</th><th rowspan="1">AVL Data Array</th><th rowspan="1">CRC-16</th></tr><tr><td>Four Zero Bytes – 0x00000000,<p>“AVL Data Array” length – 0x000000FE</p></td><td>Codec ID – 0x8E,<p>Number of Data – <b>0x02</b><br>(Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>CRC of “AVL Data Array”</td></tr><tr><td>00000000000000FE</td><td>8E <b>02</b>...(data elements)...<b>02</b></td><td>00008612</td></tr></tbody></table>
|
||||
|
||||
Server acknowledges data reception (2 data elements): **`00000002`**
|
||||
|
||||
- **Example**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in this example is given in the hexadecimal form. The different fields of the packet are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`000000000000004A8E010000016B412CEE000100000000000000000000000000000000010005000100010100010011001D00010010015E2C880002000B000000003544C87 A000E000000001DD7E06A00000100002994`
|
||||
|
||||
Parsed data:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="4"></td><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Field Length</td><td>00 00 00 4A</td></tr><tr><td>Codec ID</td><td>8E</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td rowspan="25">AVL Data</td><td>Timestamp</td><td>00 00 01 6B 41 2C EE 00 (GMT: Monday, June 10, 2019, 11:36:32 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>00 01</td></tr><tr><td>N of Total ID</td><td>00 05</td></tr><tr><td>N1 of One Byte IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>01</td></tr><tr><td>N2 of Two Bytes IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 11 (AVL ID: 17, Name: Axis X)</td></tr><tr><td>1’st IO Value</td><td>00 1D</td></tr><tr><td>N4 of Four Bytes IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 10 (AVL ID: 16, Name: Total Odometer)</td></tr><tr><td>1’st IO Value</td><td>01 5E 2C 88</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00 02</td></tr><tr><td>1’st IO ID</td><td>00 0B (AVL ID: 11, Name: ICCID1)</td></tr><tr><td>1’st IO Value</td><td>00 00 00 00 35 44 C8 7A</td></tr><tr><td>2’nd IO ID</td><td>00 0E (AVL ID: 14, Name: ICCID2)</td></tr><tr><td>2’nd IO Value</td><td>00 00 00 00 1D D7 E0 6A</td></tr><tr><td>NX of X Byte IO</td><td>00 00</td></tr><tr><td rowspan="2"></td><td>Number of Data 2 (Number of Total Records)</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 29 94</td></tr></tbody></table>
|
||||
|
||||
Server response: `00000001`
|
||||
|
||||
- **Codec8 Extended protocol sending over UDP**
|
||||
- **UDP channel protocol**
|
||||
|
||||
AVL data packet is the same as with Codec8, except Codec ID is changed to `0x8E`. AVL Data encoding was performed according to Codec8 Extended protocol.
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
The module sends the UDP channel packet with an encapsulated AVL data packet. The server sends the UDP channel packet with an encapsulated response module that validates the AVL Packet ID and the Number of accepted AVL elements. If the server response is not received with a valid AVL Packet ID within configured timeout, the module can retry sending.
|
||||
|
||||
- Example:
|
||||
|
||||
The module sends the data:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Header</th><th rowspan="1">AVL Data Array</th></tr><tr><td>Length – 0x00FE,<p>Packet ID – 0xCAFE<br>Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>IMEI Length – 0x000F<br>IMEI – 0x313233343536373839303132333435 (Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>Codec ID – 0x8E,<p>Number of Data – 0x02<br>(Encoded using continuous bit stream)</p></td></tr><tr><td>00FECAFE01</td><td>DD000F3133343536373839303132333435</td><td>8E02…(data elements)…02</td></tr></tbody></table>
|
||||
|
||||
The server must respond with an acknowledgment:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Acknowledgment</th></tr><tr><td>Length – 0x0005,<p>Packet ID – 0xCAFE, Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>Number of Accepted Data – 0x02</p></td></tr><tr><td>0005CAFE01</td><td>DD02</td></tr></tbody></table>
|
||||
|
||||
- **Example**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in this example is given in the hexadecimal form. The different fields of the packet are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`005FCAFE0107000F3335323039333038363430333635358E010000016B4F831C680100000000000000000000000000000000010005000100010100010011009D000100` `10015E2C880002000B000000003544C87A000E000000001DD7E06A000001`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>00 5F</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="3">AVL Packet Header</td><td>AVL packet ID</td><td>07</td></tr><tr><td>IMEI Length</td><td>00 0F</td></tr><tr><td>IMEI</td><td>33 35 32 30 39 33 30 38 36 34 30 33 36 35 35</td></tr><tr><td rowspan="28">AVL Data Array</td><td>Codec ID</td><td>8E</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td>Timestamp</td><td>00 00 01 6B 4F 83 1C 68 (GMT: Thursday, June 13, 2019 6:25:21 AM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>00 01</td></tr><tr><td>N of Total ID</td><td>00 05</td></tr><tr><td>N1 of One Byte IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>00 01</td></tr><tr><td>N2 of Two Bytes IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 11 (AVL ID: 17, Name: Axis X)</td></tr><tr><td>1’st IO Value</td><td>00 1D</td></tr><tr><td>N4 of Four Bytes IO</td><td>00 01</td></tr><tr><td>1’st IO ID</td><td>00 10 (AVL ID: 16, Name: Total Odometer)</td></tr><tr><td>1’st IO Value</td><td>01 5E 2C 88</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00 02</td></tr><tr><td>1’st IO ID</td><td>00 0B (AVL ID: 11, Name: ICCID1)</td></tr><tr><td>1’st IO Value</td><td>00 00 00 00 35 44 C8 7A</td></tr><tr><td>2’nd IO ID</td><td>00 0E (AVL ID: 14, Name: ICCID2)</td></tr><tr><td>2’nd IO Value</td><td>00 00 00 00 1D D7 E0 6A</td></tr><tr><td>NX of X Byte IO</td><td>00 00</td></tr><tr><td>Number of Data 2 (Records)</td><td>01</td></tr></tbody></table>
|
||||
|
||||
The server response in the hexadecimal stream: `0005CAFE010701`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">Server Response to AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">Server Response Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>00 05</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="2">AVL Packet Acknowledgment</td><td>AVL packet ID</td><td>07</td></tr><tr><td>Number of Accepted Data</td><td>01</td></tr></tbody></table>
|
||||
|
||||
## Codec 16
|
||||
|
||||
- **Protocol overview**
|
||||
|
||||
Codec16 is using for [FMB630](https://wiki.teltonika-gps.com/view/FMB630 "FMB630") /FM63XY series devices. This protocol looks familiar like Codec8 but they have some differences. The main differences between them are shown in the table below:
|
||||
|
||||
<table><tbody><tr><th rowspan="1"></th><th rowspan="1">Codec8</th><th rowspan="1">Codec16</th></tr><tr><th rowspan="1">Codec ID</th><td>0x08</td><td>0x10</td></tr><tr><th rowspan="1">AVL Data IO element ID event length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">AVL Data IO element AVL ID length</th><td>1 byte</td><td>2 bytes</td></tr><tr><th rowspan="1">Generation Type</th><td>Not Using</td><td>Is Using</td></tr></tbody></table>
|
||||
|
||||
**Note:** Codec16 is supported from firmware – 00.03.xx and newer. ([FMB630](https://wiki.teltonika-gps.com/view/FMB630 "FMB630") /FM63XY) || AVL IDs that are higher than 255 will can be used only in the Codec16 protocol.
|
||||
|
||||
- **Codec 16 protocol sending over TCP**
|
||||
- **AVL data packet**
|
||||
|
||||
The below table represents the AVL data packet structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Field Length</th><th rowspan="1">Codec ID</th><th rowspan="1">Number of Data 1</th><th colspan="1">AVL Data</th><th rowspan="1">Number of Data 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** – the packet starts with four zero bytes.
|
||||
**Data Field Length** – size is calculated starting from Codec ID to Number of Data 2.
|
||||
**Codec ID** – in Codec16 it is always 0x10.
|
||||
**Number of Data 1** – a number that defines how many records are in the packet.
|
||||
**AVL Data** – actual data in the packet (more information below).
|
||||
**Number of Data 2** – a number that defines how many records are in the packet. This number must be the same as “Number of Data 1”.
|
||||
**CRC-16** – calculated from Codec ID to the Second Number of Data. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
**Note:** for [FMB630](https://wiki.teltonika-gps.com/view/FMB630 "FMB630") and FM63XY, the minimum AVL record size is 45 bytes (all IO elements disabled). The maximum AVL record size is 255 bytes.
|
||||
|
||||
- AVL Data
|
||||
|
||||
The below table represents the AVL Data structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Timestamp</th><th rowspan="1">Priority</th><th rowspan="1">GPS Element</th><th rowspan="1">IO Element</th></tr><tr><td>8 bytes</td><td>1 byte</td><td>15 bytes</td><td>X bytes</td></tr></tbody></table>
|
||||
|
||||
**Timestamp** – a difference, in milliseconds, between the current time and midnight, January 1970 UTC (UNIX time).
|
||||
**Priority** – a field that defines AVL data priority (more information below).
|
||||
**GPS Element** – location information of the AVL data (more information below).
|
||||
**IO Element** – additional configurable information from the device (more information below).
|
||||
|
||||
- Priority
|
||||
|
||||
The below table represents Priority values. Packet priority depends on device configuration and records sent.
|
||||
|
||||
<table><tbody><tr><th colspan="2">Priority</th></tr><tr><th rowspan="1">0</th><td>Low</td></tr><tr><th rowspan="1">1</th><td>High</td></tr><tr><th rowspan="1">2</th><td>Panic</td></tr></tbody></table>
|
||||
|
||||
- GPS element
|
||||
|
||||
The below table represents the GPS Element structure:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Longitude</th><th rowspan="1">Latitude</th><th rowspan="1">Altitude</th><th rowspan="1">Angle</th><th rowspan="1">Satellites</th><th rowspan="1">Speed</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>2 bytes</td><td>2 bytes</td><td>1 byte</td><td>2 bytes</td></tr></tbody></table>
|
||||
|
||||
**Longitude** – east-west position.
|
||||
**Latitude** – north-south position.
|
||||
**Altitude** – meters above sea level.
|
||||
**Angle** – degrees from north pole.
|
||||
**Satellites** – number of satellites in use.
|
||||
**Speed** – speed calculated from satellites.
|
||||
|
||||
**Note:** Speed will be `0x0000` if GPS data is invalid.
|
||||
|
||||
Longitude and latitude are integer values built from degrees, minutes, seconds, and milliseconds by the formula:
|
||||

|
||||
Where:
|
||||
d – Degrees; m – Minutes; s – Seconds; ms – Milliseconds; p – Precision (10000000)
|
||||
If the longitude is in the west or latitude in the south, multiply the result by –1.
|
||||
|
||||
Note:
|
||||
To determine if the coordinate is negative, convert it to binary format and check the very first bit. If it is `0`, the coordinate is positive, if it is `1`, the coordinate is negative.
|
||||
|
||||
Example:
|
||||
Received value: `20 9C CA 80` converted to BIN: `00100000 10011100 11001010 10000000` first bit is 0, which means coordinate is positive converted to DEC: `547146368`. For more information see two‘s complement arithmetic.
|
||||
|
||||
- IO Element
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Event IO ID</th><td>2 bytes</td><td rowspan="27"></td><td rowspan="27"><b>Event IO ID</b> – if data is acquired on the event – this field defines which IO property has changed and generated an event. For example, when if the Ignition state changes and it generates an event, the Event IO ID will be 0xEF (AVL ID: 239). If it’s not an eventual record – the value is 0.<br><p><b>Generation type</b> - data event generation type. More information about it you can find here.<br><b>N</b> – a total number of properties coming with record (N = N1 + N2 + N4 + N8).<br><b>N1</b> – number of properties, which length is 1 byte.<br><b>N2</b> – number of properties, which length is 2 bytes.<br><b>N4</b> – number of properties, which length is 4 bytes.<br><b>N8</b> – number of properties, which length is 8 bytes.<br><b>N’th IO ID</b> - AVL ID.<br><b>N’th IO Value</b> - AVL ID value.<br></p></td></tr><tr><th rowspan="1">Generation Type</th><td>1 byte</td></tr><tr><th rowspan="1">N of Total IO</th><td>1 byte</td></tr><tr><th rowspan="1">N1 of One Byte IO</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>1 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N1’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N1’th IO Value</th><td>1 byte</td></tr><tr><th rowspan="1">N2 of Two Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>2 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N2’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N2’th IO Value</th><td>2 bytes</td></tr><tr><th rowspan="1">N4 of Four Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>4 bytes</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N4’th IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N4’th IO Value</th><td>4 byte</td></tr><tr><th rowspan="1">N8 of Eight Bytes</th><td>1 byte</td></tr><tr><th rowspan="1">1’st IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">1’st IO Value</th><td>8 byte</td></tr><tr><td colspan="2">...</td></tr><tr><th rowspan="1">N8’IO ID</th><td>2 bytes</td></tr><tr><th rowspan="1">N8’IO Value</th><td>8 bytes</td></tr></tbody></table>
|
||||
|
||||
- Generation type
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Value</th><th rowspan="1">Record Created</th></tr><tr><td>0</td><td>On Exit</td></tr><tr><td>1</td><td>On Entrance</td></tr><tr><td>2</td><td>On Both</td></tr><tr><td>3</td><td>Reserved</td></tr><tr><td>4</td><td>Hysteresis</td></tr><tr><td>5</td><td>On Change</td></tr><tr><td>6</td><td>Eventual</td></tr><tr><td>7</td><td>Periodical</td></tr></tbody></table>
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
Communication with the server is the same as with Codec8 protocol, except in Codec16 protocol Codec ID is `0x10` and has generation type.
|
||||
|
||||
- Example:
|
||||
|
||||
The module connects to the server and sends IMEI:
|
||||
`000F333536333037303432343431303133`
|
||||
The server accepts the module:
|
||||
`01`
|
||||
The module sends data packet:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">AVL Data Packet Header</th><th rowspan="1">AVL Data Array</th><th rowspan="1">CRC-16</th></tr><tr><td>Four Zero Bytes – 0x00000000,<p>“AVL Data Array” length – 0x000000FE</p></td><td>Codec ID – 0x10,<p>Number of Data – <b>0x02</b><br>(Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>CRC of “AVL Data Array”</td></tr><tr><td>00000000000000FE</td><td>10 <b>02</b>...(data elements)...<b>02</b></td><td>00008612</td></tr></tbody></table>
|
||||
|
||||
Server acknowledges data reception (2 data elements): **`00000002`**
|
||||
|
||||
- **Example**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in this example is given in the hexadecimal form. The different fields of the packet are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`000000000000005F10020000016BDBC7833000000000000000000000000000000000000B05040200010000030002000B00270042563A00000000016BDBC78718` `00000000000000000000000000000000000B05040200010000030002000B00260042563A00000200005FB3`
|
||||
|
||||
Parsed data:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="4"></td><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Field Length</td><td>00 00 00 5F</td></tr><tr><td>Codec ID</td><td>10</td></tr><tr><td>Number of Data 1 (Records)</td><td>02</td></tr><tr><td rowspan="23">AVL Data<p>(1'st record)</p></td><td>Timestamp</td><td>00 00 01 6B DB C7 83 30 (GMT: Wednesday, July 10, 2019, 12:06:54 PM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>00 0B</td></tr><tr><td>Generation Type</td><td>05</td></tr><tr><td>N of Total ID</td><td>04</td></tr><tr><td>N1 of One Byte IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>00 01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>00</td></tr><tr><td>2’nd IO ID</td><td>00 03 (AVL ID: 3, Name: DIN3)</td></tr><tr><td>2’nd IO Value</td><td>00</td></tr><tr><td>N2 of Two Bytes IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>00 0B (AVL ID: 11, Name: ICCID1)</td></tr><tr><td>1’st IO Value</td><td>00 27</td></tr><tr><td>2’nd IO ID</td><td>00 42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>2’nd IO Value</td><td>56 3A</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td rowspan="23">AVL Data<p>(2'nd record)</p></td><td>Timestamp</td><td>00 00 01 6B DB C7 87 18 (GMT: Wednesday, July 10, 2019, 12:06:55 PM)</td></tr><tr><td>Priority</td><td>01</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>00 0B</td></tr><tr><td>Generation Type</td><td>05</td></tr><tr><td>N of Total ID</td><td>04</td></tr><tr><td>N1 of One Byte IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>00 01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>00</td></tr><tr><td>2’nd IO ID</td><td>00 03 (AVL ID: 3, Name: DIN3)</td></tr><tr><td>2’nd IO Value</td><td>00</td></tr><tr><td>N2 of Two Bytes IO</td><td>02</td></tr><tr><td>1’st IO ID</td><td>00 0B (AVL ID: 11, Name: ICCID1)</td></tr><tr><td>1’st IO Value</td><td>00 26</td></tr><tr><td>2’nd IO ID</td><td>00 42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>2’nd IO Value</td><td>56 3A</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td rowspan="2"></td><td>Number of Data 2 (Number of Total Records)</td><td>02</td></tr><tr><td>CRC-16</td><td>00 00 5F B3</td></tr></tbody></table>
|
||||
|
||||
Server response: `00000002`
|
||||
|
||||
- **Codec16 protocol sending over UDP**
|
||||
- **UDP channel protocol**
|
||||
|
||||
AVL data packet is the same as with Codec8, except Codec ID is changed to `0x10`. AVL Data encoding is performed according to the Codec16 protocol.
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
The module sends the UDP channel packet with an encapsulated AVL data packet. The server sends the UDP channel packet with an encapsulated response module that validates the AVL Packet ID and the Number of accepted AVL elements. If the server responds with a valid AVL Packet ID that is not received within configured timeout, the module can retry sending.
|
||||
|
||||
- Example:
|
||||
|
||||
The module sends the data:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Header</th><th rowspan="1">AVL Data Array</th></tr><tr><td>Length – 0x00FE,<p>Packet ID – 0xCAFE<br>Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>IMEI Length – 0x000F<br>IMEI – 0x313233343536373839303132333435 (Encoded using continuous bit stream. The last byte is padded to align to the byte boundary)</p></td><td>Codec ID – 0x10,<p>Number of Data – 0x02<br>(Encoded using continuous bit stream)</p></td></tr><tr><td>00FECAFE01</td><td>DD000F3133343536373839303132333435</td><td>1002…(data elements)…02</td></tr></tbody></table>
|
||||
|
||||
The server must respond with an acknowledgment:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">UDP Channel Header</th><th rowspan="1">AVL Packet Acknowledgment</th></tr><tr><td>Length – 0x0005,<p>Packet ID – 0xCAFE, Not Usable Byte – 0x01</p></td><td>AVL Packet ID – 0xDD,<p>Number of Accepted Data – 0x02</p></td></tr><tr><td>0005CAFE01</td><td>DD02</td></tr></tbody></table>
|
||||
|
||||
- **Example**
|
||||
|
||||
The hexadecimal stream of AVL Data Packet receiving and response in this example is given in the hexadecimal form. The different fields of the packet are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Received data in the hexadecimal stream:
|
||||
`015BCAFE0101000F33353230393430383532333135393210070000015117E40FE80000000000000000000000000000000000EF05050400010000030000B4000` `0EF01010042111A000001`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">AVL Data Packet Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>01 5B</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="3">AVL Packet Header</td><td>AVL packet ID</td><td>07</td></tr><tr><td>IMEI Length</td><td>00 0F</td></tr><tr><td>IMEI</td><td>33 35 32 30 39 34 30 38 35 32 33 31 35 39 32</td></tr><tr><td rowspan="28">AVL Data Array</td><td>Codec ID</td><td>10</td></tr><tr><td>Number of Data 1 (Records)</td><td>01</td></tr><tr><td>Timestamp</td><td>00 00 01 51 17 E4 0F E8 (GMT: Wednesday, November 18, 2015, 12:00:01 AM)</td></tr><tr><td>Priority</td><td>00</td></tr><tr><td>Longitude</td><td>00 00 00 00</td></tr><tr><td>Latitude</td><td>00 00 00 00</td></tr><tr><td>Altitude</td><td>00 00</td></tr><tr><td>Angle</td><td>00 00</td></tr><tr><td>Satellites</td><td>00</td></tr><tr><td>Speed</td><td>00 00</td></tr><tr><td>Event IO ID</td><td>00 EF</td></tr><tr><td>Generation type</td><td>05</td></tr><tr><td>N of Total ID</td><td>05</td></tr><tr><td>N1 of One Byte IO</td><td>04</td></tr><tr><td>1’st IO ID</td><td>00 01 (AVL ID: 1, Name: DIN1)</td></tr><tr><td>1’st IO Value</td><td>00</td></tr><tr><td>2’nd IO ID</td><td>00 03 (AVL ID: 3, Name: DIN3)</td></tr><tr><td>2’nd IO Value</td><td>00</td></tr><tr><td>3’rd IO ID</td><td>00 B4 (AVL ID: 180, Name: DOUT2)</td></tr><tr><td>3’rd IO Value</td><td>00</td></tr><tr><td>4’th IO ID</td><td>00 EF (AVL ID: 239, Name: Ignition)</td></tr><tr><td>4’th IO Value</td><td>00</td></tr><tr><td>N2 of Two Bytes IO</td><td>01</td></tr><tr><td>1’st IO ID</td><td>42 (AVL ID: 66, Name: External Voltage)</td></tr><tr><td>1’st IO Value</td><td>11 1A</td></tr><tr><td>N4 of Four Bytes IO</td><td>00</td></tr><tr><td>N8 of Eight Bytes IO</td><td>00</td></tr><tr><td>Number of Data 2 (Number of Total Records)</td><td>01</td></tr></tbody></table>
|
||||
|
||||
The server response in the hexadecimal stream: `0005CAFE010701`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="3">Server Response to AVL Data Packet</th></tr><tr><th colspan="2" rowspan="1">Server Response Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td rowspan="3">UDP Channel Header</td><td>Length</td><td>00 05</td></tr><tr><td>Packet ID</td><td>CA FE</td></tr><tr><td>Not usable byte</td><td>01</td></tr><tr><td rowspan="2">AVL Packet Acknowledgment</td><td>AVL packet ID</td><td>07</td></tr><tr><td>Number of Accepted Data</td><td>01</td></tr></tbody></table>
|
||||
|
||||
## Differences between Codec 8, Codec 8 Extended and Codec 16
|
||||
|
||||
In the table below you will see differences between Codec8, Codec8 Extended, and Codec16.
|
||||
|
||||
<table><tbody><tr><th rowspan="1"></th><th rowspan="1">Codec8</th><th rowspan="1">Codec8 Extended</th><th rowspan="1">Codec16</th></tr><tr><th rowspan="1">Codec ID</th><td>0x08</td><td>0x8E</td><td>0x10</td></tr><tr><th rowspan="1">AVL Data IO element length</th><td>1 byte</td><td>2 bytes</td><td>2 bytes</td></tr><tr><th rowspan="1">AVL Data IO element total IO count length</th><td>1 byte</td><td>2 bytes</td><td>2 bytes</td></tr><tr><th rowspan="1">Generation Type</th><td>Is Using</td><td>Not Using</td><td>Is Using</td></tr><tr><th rowspan="1">AVL Data IO element IO count length</th><td>1 byte</td><td>2 bytes</td><td>1 byte</td></tr><tr><th rowspan="1">AVL Data IO element AVL ID length</th><td>1 byte</td><td>2 bytes</td><td>2 bytes</td></tr><tr><th rowspan="1">Variable size IO elements</th><td>Does not include</td><td>Includes variable size elements</td><td>Does not include</td></tr></tbody></table>
|
||||
|
||||
## Codec for communication over GPRS messages
|
||||
|
||||
In this chapter, you will find information about every Codec protocol which are used for communication over GPRS messages and the differences between them.
|
||||
|
||||
## Codec 12
|
||||
|
||||
- **About Codec12**
|
||||
|
||||
Codec12 is the original and main Teltonika protocol for device-server communication over GPRS messages. Codec12 GPRS commands can be used for sending configuration, debug, digital outputs control commands, or other (special purpose commands on special firmware versions). This protocol is also necessary for using [FMB630](https://wiki.teltonika-gps.com/view/FMB630 "FMB630") / [FM6300](https://wiki.teltonika-gps.com/view/FM6300 "FM6300") /FM5300/FM5500/FM4200 features like Garmin, LCD communication, and COM TCP Link Mode.
|
||||
|
||||
- **GPRS command session**
|
||||
|
||||
The following figure shows how the GRPS command session is started over TCP.
|
||||
 First, the Teltonika device opens the GPRS session and sends AVL data to the server (refer to device protocols). Once all records are sent and the correct sent data array acknowledgment is received by the device then GPRS commands in Hex can be sent to the device.
|
||||
The ACK (acknowledgment of IMEI from server) is a one-byte constant 0x01. The acknowledgment of each data array send from the device is four bytes integer – a number of received records.
|
||||
Note, that the GPRS session should remain active between the device and server, while GPRS commands are sent. For this reason, active datalink timeout (global parameters in device configuration) is recommended to be set to 259200 (maximum value).
|
||||
|
||||
- **General Codec12 message structure**
|
||||
|
||||
The following diagram shows the basic structure of Codec12 messages.
|
||||
|
||||
**Command message structure:**
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Size</th><th rowspan="1">Codec ID</th><th rowspan="1">Command Quantity 1</th><th colspan="1">Type (0x05)</th><th rowspan="1">Command Size</th><th rowspan="1">Command</th><th rowspan="1">Command Quantity 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>1 byte</td><td>4 bytes</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Response message structure:**
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Size</th><th rowspan="1">Codec ID</th><th rowspan="1">Response Quantity 1</th><th colspan="1">Type (0x06)</th><th rowspan="1">Response Size</th><th rowspan="1">Response</th><th rowspan="1">Response Quantity 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>1 byte</td><td>4 bytes</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** - the packet starts with four zero bytes.
|
||||
**Data Size** - size is calculated from the Codec ID field to the second command or response quantity field.
|
||||
**Codec ID** - in Codec12 it is always `0x0C`.
|
||||
**Command/Response Quantity 1** - it is ignored when parsing the message.
|
||||
**Type** - it can be 0x05 to denote command or 0x06 to denote response.
|
||||
**Command/Response Size** – command or response length.
|
||||
**Command/Response** – command or response in HEX.
|
||||
**Command/Response Quantity 2** - a byte that defines how many records (commands or responses) are in the packet. This byte will not be parsed but it’s recommended that it should contain the same value as Command/Response Quantity 1.
|
||||
**CRC-16** – calculated from Codec ID to the Command Quantity 2. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
Note that the difference between commands and responses is the message type field: `0x05` means command and `0x06` means response.
|
||||
|
||||
- **Command coding table**
|
||||
|
||||
Command has to be converted from ASCII characters (char) to hexadecimal (HEX):
|
||||

|
||||
|
||||
- **Command parsing example**
|
||||
|
||||
The hexadecimal stream of command and answer in this example is given in the hexadecimal form. The different fields of the message are separated into different table columns for better readability and understanding.
|
||||
|
||||
- **GPRS commands examples**
|
||||
|
||||
The hexadecimal stream of GPRS command and answer in these examples are given in the hexadecimal form. The different fields of messages are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
**1'st example:** Sending *[getinfo](https://wiki.teltonika-gps.com/view/FMB_getinfo "FMB getinfo")* SMS command via GPRS Codec12
|
||||
|
||||
Server request in the hexadecimal stream:
|
||||
`000000000000000F0C010500000007676574696E666F0100004312`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Server Command</th></tr><tr><th rowspan="1">Server Command Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 0F</td></tr><tr><td>Codec ID</td><td>0C</td></tr><tr><td>Command Quantity 1</td><td>01</td></tr><tr><td>Command Type</td><td>05</td></tr><tr><td>Command Size</td><td>00 00 00 07</td></tr><tr><td>Command</td><td>67 65 74 69 6E 66 6F</td></tr><tr><td>Command Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 43 12</td></tr></tbody></table>
|
||||
|
||||
Note that Server Command converted from HEX to ASCII means *[getinfo](https://wiki.teltonika-gps.com/view/FMB_getinfo "FMB getinfo")*
|
||||
|
||||
Device response in the hexadecimal stream:
|
||||
`00000000000000900C010600000088494E493A323031392F372F323220373A3232205254433A323031392F372F323220373A3533205253543A32204552523A` `312053523A302042523A302043463A302046473A3020464C3A302054553A302F302055543A3020534D533A30204E4F4750533A303A3330204750533A312053` `41543A302052533A332052463A36352053463A31204D443A30010000C78F`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Device Answer</th></tr><tr><th rowspan="1">Device Answer Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 90</td></tr><tr><td>Codec ID</td><td>0C</td></tr><tr><td>Response Quantity 1</td><td>01</td></tr><tr><td>Response Type</td><td>06</td></tr><tr><td>Response Size</td><td>00 00 00 88</td></tr><tr><td>Response</td><td>49 4E 49 3A 32 30 31 39 2F 37 2F 32 32 20 37 3A 32 32 20 52 54 43 3A 32 30 31 39 2F 37 2F 32 32 20 37 3A 35 33 20 52 53 54 3A 32 20 45 52 52 3A 31 20 53 52 3A 30 20 42 52 3A 30 20 43 46 3A 30 20 46 47 3A 30 20 46 4C 3A 30 20 54 55 3A 30 2F 30 20 55 54 3A 30 20 53 4D 53 3A 30 20 4E 4F 47 50 53 3A 30 3A 33 30 20 47 50 53 3A 31 20 53 41 54 3A 30 20 52 53 3A 33 20 52 46 3A 36 35 20 53 46 3A 31 20 4D 44 3A 30</td></tr><tr><td>Response Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 C7 8F</td></tr></tbody></table>
|
||||
|
||||
Note that Device Response converted from HEX to ASCII means:
|
||||
*INI:2019/7/22 7:22 RTC:2019/7/22 7:53 RST:2 ERR:1 SR:0 BR:0 CF:0 FG:0 FL:0 TU:0/0 UT:0 [SMS:0](sms:0) NOGPS:0:30 GPS:1 SAT:0 RS:3 RF:65 SF:1 MD:0*
|
||||
|
||||
**2'nd example:** Sending *[getio](https://wiki.teltonika-gps.com/view/FMB_getio "FMB getio")* SMS command via GPRS Codec12
|
||||
|
||||
Server request in the hexadecimal stream:
|
||||
`000000000000000D0C010500000005676574696F01000000CB`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Server Command</th></tr><tr><th rowspan="1">Server Command Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 0D</td></tr><tr><td>Codec ID</td><td>0C</td></tr><tr><td>Command Quantity 1</td><td>01</td></tr><tr><td>Command Type</td><td>05</td></tr><tr><td>Command Size</td><td>00 00 00 05</td></tr><tr><td>Command</td><td>67 65 74 69 6F</td></tr><tr><td>Command Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 00 CB</td></tr></tbody></table>
|
||||
|
||||
Note that Server Command converted from HEX to ASCII means *[getio](https://wiki.teltonika-gps.com/view/FMB_getio "FMB getio")*
|
||||
|
||||
Device response in the hexadecimal stream:
|
||||
`00000000000000370C01060000002F4449313A31204449323A30204449333A302041494E313A302041494E323A313639323420444F313A3020444F323A3101000066E3`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Device Answer</th></tr><tr><th rowspan="1">Device Answer Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 37</td></tr><tr><td>Codec ID</td><td>0C</td></tr><tr><td>Response Quantity 1</td><td>01</td></tr><tr><td>Response Type</td><td>06</td></tr><tr><td>Response Size</td><td>00 00 00 2F</td></tr><tr><td>Response</td><td>44 49 31 3A 31 20 44 49 32 3A 30 20 44 49 33 3A 30 20 41 49 4E 31 3A 30 20 41 49 4E 32 3A 31 36 39 32 34 20 44 4F 31 3A 30 20 44 4F 32 3A 31</td></tr><tr><td>Response Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 66 E3</td></tr></tbody></table>
|
||||
|
||||
Note that Device Response converted from HEX to ASCII means:
|
||||
*DI1:1 DI2:0 DI3:0 AIN1:0 AIN2:16924 DO1:0 DO2:1*
|
||||
|
||||
- **Communication with server**
|
||||
|
||||
The GSM/GPRS commands can be sent from a terminal program. We recommend using Hercules (in TCP server mode). Simply write the command into the Hercules Send field, check the HEX box and click Send button. Note that the TCP server must be listening on a specified port (see Port field and Listen button below).
|
||||
|
||||

|
||||
|
||||
- **FMXX and Codec12 functionality**
|
||||
- **Garmin**
|
||||
|
||||
All information is provided in the “FMXX and Garmin development.pdf” document.
|
||||
|
||||
- **COM TCP Link Mode**
|
||||
|
||||
All information is provided in the “FMxx TCP Link mode test instructions.pdf” document.
|
||||
|
||||
## Codec 13
|
||||
|
||||
- **About Codec13**
|
||||
|
||||
Codec13 is the original Teltonika protocol for device-server communication over GPRS messages and it is based on the Codec12 protocol. The main differences of Codec13 are that timestamp is used in messages and communication is one way only (Codec13 is used for Device -> Server sending).
|
||||
|
||||
- **General Codec13 message structure**
|
||||
|
||||
The following diagram shows the basic structure of Codec 13 messages:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Size</th><th rowspan="1">Codec ID</th><th rowspan="1">Command Quantity 1</th><th colspan="1">Type</th><th rowspan="1">Command Size</th><th rowspan="1">Timestamp</th><th rowspan="1">Command</th><th rowspan="1">Command Quantity 2</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>1 byte</td><td>4 bytes</td><td>4 bytes</td><td>X bytes</td><td>1 byte</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** – the packet starts with a preamble field (four zero bytes).
|
||||
**Data Size** – size is calculated from the Codec ID field to the second Command Quantity field.
|
||||
**Codec ID** – in Codec13 it is always `0x0D`.
|
||||
**Command Quantity 1** – `0x01`, it is ignored when parsing the message.
|
||||
**Command Type** – it is always `0x06` since the packet is direction is FM->Server.
|
||||
**Command Size** – command size field includes the size of the timestamp too, so it is equal to the size of the payload + the size of the timestamp.
|
||||
**Timestamp** – a difference, in milliseconds, between the current time and midnight, January 1970 UTC (UNIX time).
|
||||
**Command** – actual received data.
|
||||
**Command Quantity 2** – a byte that defines how many records (commands) are in the packet. This byte will not be parsed but it’s recommended that it should contain the same value as Command/Response Quantity 1.
|
||||
**CRC-16** – calculated from Codec ID to the Second Number of Data. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
**Note:** Codec13 packets are used only when the “Message Timestamp” parameter in RS232 settings is enabled.
|
||||
|
||||
## Codec 14
|
||||
|
||||
- **About Codec14**
|
||||
|
||||
Codec14 is the original Teltonika protocol for device-server communication over GPRS messages and it is based on the Codec12 protocol.
|
||||
The main difference of Codec14 is that the device will answer the GPRS command if the device's physical IMEI number matches the specified IMEI number in the GPRS command.
|
||||
|
||||
Codec14 GPRS commands can be used for sending configuration, debug, digital outputs control commands, or other (special purpose commands on special firmware versions).
|
||||
|
||||
- **FMB firmware requirements**
|
||||
|
||||
Implemented in base firmware from FMB.Ver.03.25.04.Rev.00 and newer.
|
||||
|
||||
- **General Codec14 message structure**
|
||||
|
||||
The following diagram shows the basic structure of Codec14 messages.
|
||||
|
||||
**Command message structure**
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (preamble)</th><th rowspan="1">Data size</th><th rowspan="1">0x0E (Codec ID)</th><th rowspan="1">Command quantity</th><th colspan="1">0x05<br>(Message type)</th><th rowspan="1">Command size + IMEI size (8 bytes)</th><th rowspan="1">IMEI (HEX)</th><th rowspan="1">Command</th><th rowspan="1">Command quantity</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 bytes</td><td>1 bytes</td><td>1 bytes</td><td>4 bytes</td><td>8 bytes</td><td>X bytes</td><td>1 bytes</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Response message structure**
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (preamble)</th><th rowspan="1">Data size</th><th rowspan="1">0x0E (Codec ID)</th><th rowspan="1">Response quantity</th><th colspan="1">0x06 / 0x11 (Message type)</th><th rowspan="1">Response size + IMEI size (8 bytes)</th><th rowspan="1">IMEI (HEX)</th><th rowspan="1">Response</th><th rowspan="1">Response quantity</th><th rowspan="1">CRC-16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 bytes</td><td>1 bytes</td><td>1 bytes</td><td>4 bytes</td><td>8 bytes</td><td>X bytes</td><td>1 bytes</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
**Preamble** – the packet starts with four zero bytes.
|
||||
**Data Size** – size is calculated from the Codec ID field to the second command or response quantity field.
|
||||
**Codec ID** – in Codec14 it is always `0x0E`.
|
||||
**Command/Response Quantity 1** – it is ignored when parsing the message.
|
||||
**Type** – if it is a request command from the server it has to contain 0x05. The response type field will contain `0x06` if it’s ACK or `0x11` if it’s nACK.
|
||||
*Explanation:* If command message IMEI is equal to actual device IMEI, received command will be executed and response will be sent with ACK (`0x06`) message type field value. If the command message IMEI doesn’t match the actual device IMEI, the received command won’t be executed and a response to the server will be sent with nACK (`0x11`) message type field value.
|
||||
**Command/Response Size** – command or response length.
|
||||
*Note:* make sure that size is IMEI size 8 + actual command size. The minimal value is 8 because Codec14 always contains IMEI and it’s 8 bytes.
|
||||
**IMEI (HEX)** – it is send as HEX value. For example, if the device IMEI is 123456789123456 then the IMEI data field will contain `0x0123456789123456` value.
|
||||
**Command/Response** – command or response in HEX.
|
||||
**Command/Response Quantity 2** - a byte that defines how many records (commands or responses) are in the packet. This byte will not be parsed but it’s recommended that it should contain the same value as Command/Response Quantity 1.
|
||||
**CRC-16** – calculated from Codec ID to the Second Number of Data. CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. For calculation we are using [CRC-16/IBM](https://wiki.teltonika-gps.com/view/Codec#CRC-16 "Codec").
|
||||
|
||||
- **GPRS in Codec14 examples**
|
||||
|
||||
The hexadecimal stream of the GPRS command and answer in this example is given in the hexadecimal form. The different fields of the message are separated into different table columns for better readability and some of them are converted to ASCII values for better understanding.
|
||||
|
||||
Sending *[getver](https://wiki.teltonika-gps.com/view/FMB_getver "FMB getver")* SMS command via GPRS Codec14:
|
||||
|
||||
Server requests in Hexadecimal stream:
|
||||
`00000000000000160E01050000000E0352093081452251676574766572010000D2C1`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Server Command</th></tr><tr><th rowspan="1">Server Command Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 16</td></tr><tr><td>Codec ID</td><td>0E</td></tr><tr><td>Command Quantity 1</td><td>01</td></tr><tr><td>Command Type</td><td>05</td></tr><tr><td>Command Size</td><td>00 00 00 0E</td></tr><tr><td>IMEI</td><td>03 52 09 30 81 45 22 51</td></tr><tr><td>Command</td><td>67 65 74 76 65 72</td></tr><tr><td>Command Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 D2 C1</td></tr></tbody></table>
|
||||
|
||||
Note that Server Command converted from HEX to ASCII means *[getver](https://wiki.teltonika-gps.com/view/FMB_getver "FMB getver")*
|
||||
|
||||
Device ACK response in the hexadecimal stream:
|
||||
`00000000000000AB0E0106000000A303520930814522515665723A30332E31382E31345F3034204750533A41584E5F352E31305F333333332048773A464D42313230` `204D6F643A313520494D45493A33353230393330383134353232353120496E69743A323031382D31312D323220373A313320557074696D653A3137323334204D4143` `3A363042444430303136323631205350433A312830292041584C3A30204F42443A3020424C3A312E362042543A340100007AAE`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Device Answer</th></tr><tr><th rowspan="1">Device Answer Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 37</td></tr><tr><td>Codec ID</td><td>0E</td></tr><tr><td>Response Quantity 1</td><td>01</td></tr><tr><td>Response Type</td><td>06</td></tr><tr><td>Response Size</td><td>00 00 00 A3</td></tr><tr><td>IMEI</td><td>03 52 09 30 81 45 22 51</td></tr><tr><td>Response</td><td>56 65 72 3A 30 33 2E 31 38 2E 31 34 5F 30 34 20 47 50 53 3A 41 58 4E 5F 35 2E 31 30 5F 33 33 33 33 20 48 77 3A 46 4D 42 31 32 30 20 4D 6F 64 3A 31 35 20 49 4D 45 49 3A 33 35 32 30 39 33 30 38 31 34 35 32 32 35 31 20 49 6E 69 74 3A 32 30 31 38 2D 31 31 2D 32 32 20 37 3A 31 33 20 55 70 74 69 6D 65 3A 31 37 32 33 34 20 4D 41 43 3A 36 30 42 44 44 30 30 31 36 32 36 31 20 53 50 43 3A 31 28 30 29 20 41 58 4C 3A 30 20 4F 42 44 3A 30 20 42 4C 3A 31 2E 36 20 42 54 3A 34</td></tr><tr><td>Response Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 7A AE</td></tr></tbody></table>
|
||||
|
||||
Note that Device Response converted from HEX to ASCII means:
|
||||
*Ver:03.18.14\_04 GPS:AXN\_5.10\_3333 Hw:FMB120 Mod:15 IMEI:352093081452251 Init:2018-11-22 7:13 Uptime:17234 MAC:60BDD0016261 SPC:1(0) AXL:0 OBD:0 BL:1.6 BT:4*
|
||||
|
||||
Device nACK response in the hexadecimal stream:
|
||||
`00000000000000100E011100000008035209308145246801000032AC`
|
||||
|
||||
Parsed:
|
||||
|
||||
<table><tbody><tr><th colspan="2">Device Answer</th></tr><tr><th rowspan="1">Device Answer Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 10</td></tr><tr><td>Codec ID</td><td>0E</td></tr><tr><td>Response Quantity 1</td><td>01</td></tr><tr><td>Response Type</td><td>11</td></tr><tr><td>Response Size</td><td>00 00 00 08</td></tr><tr><td>IMEI</td><td>03 52 09 30 81 45 24 68</td></tr><tr><td>Response Quantity 2</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 32 AC</td></tr></tbody></table>
|
||||
|
||||
## Codec 15
|
||||
|
||||
- **Protocol Overview**
|
||||
|
||||
Codec 15 relies on the Codec12 protocol and is employed when both message timestamp and device IMEI are enabled. It serves as the original Teltonika protocol for communication from the device to the server via GPRS messages. This protocol is exclusively applicable to FMX6 professional devices.
|
||||
|
||||
Codec15 is available in RS232 modes:
|
||||
|
||||
1\. TCP/UDP Ascii
|
||||
2\. TCP/UDP Binary
|
||||
3\. TCP/UDP Ascii Buffered
|
||||
4\. TCP/UDP Binary Buffered.
|
||||
|
||||
- **Structure of Codec 15 messages**
|
||||
|
||||
<table><tbody><tr><th rowspan="1">0x00000000 (Preamble)</th><th rowspan="1">Data Size</th><th rowspan="1">0x0F (Codec ID)</th><th rowspan="1">Command quantity</th><th colspan="1">Message type</th><th rowspan="1">Command size + timestamp + imei</th><th rowspan="1">Timestamp</th><th rowspan="1">IMEI</th><th rowspan="1">Command</th><th rowspan="1">Command quantity</th><th rowspan="1">CRC - 16</th></tr><tr><td>4 bytes</td><td>4 bytes</td><td>1 byte</td><td>1 byte</td><td>1 bytes</td><td>4 byte</td><td>4 bytes</td><td>8 bytes</td><td>X bytes</td><td>1 bytes</td><td>4 bytes</td></tr></tbody></table>
|
||||
|
||||
- **Structure explanation**
|
||||
|
||||
**Preamble** - four zero bytes.
|
||||
**Data size** - size is calculated from codec id(0x0F) field to the second command quantity field.
|
||||
**Codec ID** - in Codec 15 it is always 0x0F.
|
||||
**Command quantity** - a number which defines how many commands are in the packet.
|
||||
**Message type** - this value is configurable in RS232 settings box.
|
||||
**Command size + Timestamp + IMEI** - it is equal to size of payload + size of timestamp + size of imei.
|
||||
**Timestamp** – data record creation time in seconds(Unix timestamp).
|
||||
**IMEI** - send as HEX value. Example if device IMEI is 123456789123456 then IMEI data field will contain 0x0123456789123456 value.
|
||||
**Command field** - actual received data.
|
||||
**Command quantity** - a number which defines how many commands are in the packet.
|
||||
**CRC field** - calculated from Codec ID to the Second Number of Data.
|
||||
|
||||
- **Codec 15 examples**
|
||||
|
||||
Device sends message „Hello\\n“ via GPRS Codec15:
|
||||
|
||||
```
|
||||
000000000000001b0f010b00000013654b65a4012345678912345648656c6c6f210a01000093d6
|
||||
```
|
||||
|
||||
<table><tbody><tr><th colspan="2">Parsed command</th></tr><tr><th rowspan="1">Command Part</th><th rowspan="1">HEX Code Part</th></tr><tr><td>Zero Bytes</td><td>00 00 00 00</td></tr><tr><td>Data Size</td><td>00 00 00 1B</td></tr><tr><td>Codec ID</td><td>0F</td></tr><tr><td>Quantity of commands</td><td>01</td></tr><tr><td>Command type</td><td>0B</td></tr><tr><td>Command Size</td><td>00 00 00 13</td></tr><tr><td>Timestamp</td><td>65 4B 65 A4</td></tr><tr><td>IMEI</td><td>01 23 45 67 89 12 34 56</td></tr><tr><td>Command</td><td>48 65 6c 6c 6f 21 0a</td></tr><tr><td>Quantity of commands</td><td>01</td></tr><tr><td>CRC-16</td><td>00 00 93 D6</td></tr></tbody></table>
|
||||
|
||||
CRC: 0x 000093d6 The algorithm to calculate CRC is CRC-16 (also known as CRC-16-IBM). All the fields from codec ID to second command/response quantity field are used to calculate CRC.
|
||||
|
||||
## Differences between Codec 12, Codec 13, Codec 14 and Codec 15
|
||||
|
||||
In the table below you will see differences between Codec12, Codec13, Codec14 and Codec 15.
|
||||
|
||||
<table><tbody><tr><th rowspan="1"></th><th rowspan="1">Codec12</th><th rowspan="1">Codec13</th><th rowspan="1">Codec14</th><th rowspan="1">Codec15</th></tr><tr><th rowspan="1">Communication</th><td>Server - Device Communication</td><td>One-way (Device -> Server communication)</td><td>Server - Device Communication</td><td>One-way (Device -> Server communication)</td></tr><tr><th rowspan="1">Codec ID</th><td>0x0C</td><td>0x0D</td><td>0x0E</td><td>0x0F</td></tr><tr><th rowspan="1">Response Message Type</th><td>0x06</td><td>-</td><td>0x06 (if it is ACK) or 0x11 (if it is nACK)</td><td>-</td></tr><tr><th rowspan="1">Command / Response size</th><td>Only Command/Response</td><td>Only Command</td><td>Command/Response + IMEI</td><td>Command + IMEI</td></tr><tr><th rowspan="1">Timestamp</th><td>Not Using</td><td>Is Using</td><td>Not Using</td><td>Is Using</td></tr><tr><th rowspan="1">IMEI</th><td>Not Using</td><td>Not Using</td><td>Is Using</td><td>Is Using</td></tr></tbody></table>
|
||||
|
||||
## 24 Position SMS Data Protocol
|
||||
|
||||
24-hour SMS is usually sent once every day and contains GPS data for the last 24 hours. The TP-DCS field of this SMS should indicate that message contains 8-bit data (i.e. TP-DCS can be `0x04`).
|
||||
Note, that 24 position data protocol is used only with subscribed SMS. Event SMS uses standard AVL data protocol.
|
||||
|
||||
- **Encoding**
|
||||
|
||||
To be able to compress 24 GPS data entries into one SMS (140 octets), the data is encoded extensively using bit fields. The data packet can be interpreted as a bitstream, where all bits are numbered as follows:
|
||||
|
||||
<table><tbody><tr><th rowspan="1">Byte 1</th><th rowspan="1">Byte 2</th><th rowspan="1">Byte 3</th><th rowspan="1">Byte 4...</th></tr><tr><td>Bits 0 - 7</td><td>Bits 8 - 15</td><td>Bits 16 - 24</td><td>Bits 25 -...</td></tr></tbody></table>
|
||||
|
||||
Bits in a byte are numbered starting from the least significant bit. A field of 25 bits would consist of bits 0 to 24 where 0 is the least significant bit and bit 24 – is the most significant bit.
|
||||
|
||||
- **Structure**
|
||||
|
||||
Below in the tables, you will see the SMS Data Structure:
|
||||
|
||||
<table><tbody><tr><th colspan="3">SMS Data Structure</th></tr><tr><td>8</td><td>Codec ID</td><td>Codec ID = 4 (0x04)</td></tr><tr><td>35</td><td>Timestamp</td><td>Time corresponding to the first (oldest) GPS data element, represented in seconds elapsed from 2000.01.01 00:00 EET.</td></tr><tr><td>5</td><td>ElementCount</td><td>Number of GPS data elements</td></tr></tbody></table>
|
||||
|
||||
<table><tbody><tr><th colspan="4">SMS Data Structure</th></tr><tr><td rowspan="3">ElementCount *</td><td></td><td>GPSDataElement</td><td>GPS data elements</td></tr><tr><td></td><td>Byte - align padding</td><td>Padding bits to align to 8 - bits boundary represented in seconds elapsed from 2000.01.01 00:00 EET.</td></tr><tr><td>64</td><td>IMEI</td><td>IMEI of sending device as 8 byte long integer</td></tr></tbody></table>
|
||||
|
||||
The time of only the first GPS data element is specified in the Timestamp field. The time corresponding to each further element can be computed as elementTime = Timestamp + (1 hour \* elementNumber).
|
||||
|
||||
<table><tbody><tr><th colspan="5" rowspan="1">GPS Data Element</th></tr><tr><th rowspan="1"></th><th rowspan="1"></th><th rowspan="1">Size (bits)</th><th colspan="1">Field</th><th rowspan="1">Description</th></tr><tr><td></td><td></td><td>1</td><td>ValidElement</td><td>ValidElement = 1 – there is a valid Gps Data Element following,<p>ValidElement = 0 – no element at this position</p></td></tr><tr><td rowspan="5">ValidElement == 1</td><td></td><td>1</td><td>DifferentialCoords</td><td>Format of following data</td></tr><tr><td rowspan="2">DifferentialCoords == 1</td><td>14</td><td>LongitudeDiff</td><td>Difference from previous element‘s longitude.<p>LongitudeDiff = prevLongitude – Longitude + 213 – 1</p></td></tr><tr><td>14</td><td>LatitudeDiff</td><td>Difference from previous element‘s latitude<p>LatitudeDiff = prevLatitude – Latitude + 213 – 1</p></td></tr><tr><td rowspan="2">DifferentialCoords == 0</td><td>21</td><td>Longitude</td><td>Longitude = {(LongDegMult + 18 * 108) * (221 – 1)} over {36*108}</td></tr><tr><td>20</td><td>Latitude</td><td>Latitude = (LatDegMult + 9*108) * (220 – 1) over {18*108}</td></tr><tr><td></td><td></td><td>8</td><td>Speed</td><td>Speed in km/h</td></tr></tbody></table>
|
||||
|
||||
**Longitude** - longitude field value of GPSDataElement
|
||||
**Latitude** - latitude field value of GPSDataElement
|
||||
**LongDegMult** - longitude in degrees multiplied by 107 (integer part)
|
||||
**LatDegMult** - latitude in degrees multiplied by 107 (integer part)
|
||||
**prevLongitude** - longitude field value of previous GPSDataElemen
|
||||
**prevLatitude** - latitude field value of previous GPSDataElement
|
||||
|
||||
- **Decoding GPS position**
|
||||
|
||||
When decoding GPS data with DifferentialCoords = 1, Latitude and Longitude values can be computed as follows: Longitude = prevLongitude – LongitudeDiff + 213 – 1, Latitude = prevLatitude – LatitudeDiff + 213 – 1.
|
||||
If there were no previous non-differential positions, differential coordinates should be computed assuming prevLongitude = prevLatitude = 0.
|
||||
When Longitude and Latitude values are known, longitude and latitude representation in degrees can be computed as follows:
|
||||
|
||||

|
||||
|
||||
- **SMS Events**
|
||||
|
||||
When configured to generate an SMS event user will get this SMS upon event:
|
||||
*<Year/Month/Day> <Hour:Minute:Second> P:<profile\_nr> <SMS Text> Val:<Event Value> Lon:<longitude> Lat:<latitude> Q:<HDOP>*
|
||||
|
||||
Example:
|
||||
*2016./04/11 12:00:00 P:3 Digital Input 1 Val:1 Lon:51.12258 Lat: 25.7461 Q:0.6*
|
||||
|
||||
## Sending data using SMS
|
||||
|
||||
This type of data sent is used for FMBXXX devices which can be configured in [SMS Data Sending settings](https://wiki.teltonika-gps.com/view/FMB120_SMS/Call_settings#SMS_Data_Sending "FMB120 SMS/Call settings").
|
||||
|
||||
- **Data sending via SMS**
|
||||
|
||||
AVL data or events can be sent encapsulated in binary SMS. The TP-DCS field of these SMS should indicate that message contains 8-bit data (for example TP-DCS can be `0x04`).
|
||||
|
||||
<table><tbody><tr><th colspan="2">SMS data (TP-UD)</th></tr><tr><th rowspan="1">AVL data array</th><th rowspan="1">IMEI</th></tr><tr><td>X bytes</td><td>8 bytes</td></tr></tbody></table>
|
||||
|
||||
**AVL data array** – array of encoded AVL data.
|
||||
**IMEI** – IMEI of sending module encoded as a big-endian 8-byte long number.
|
||||
|
||||
## CRC-16
|
||||
|
||||
CRC (Cyclic Redundancy Check) is an error-detecting code used to detect accidental changes to RAW data. The algorithm on how to calculate CRC-16 (also known as CRC-16/IBM) you will find below.
|
||||

|
||||
Reference in New Issue
Block a user