Difference between revisions of "Codec14"

From Wiki Knowledge Base | Teltonika
Jump to: navigation, search
Line 9: Line 9:
 
*'''FMB firmware requirements'''
 
*'''FMB firmware requirements'''
  
Implemented in base FW from FMB.Ver.03.25.04.Rev.00+.
+
Implemented in base firmware from FMB.Ver.03.25.04.Rev.00 and newer.
  
 
*'''General Codec14 message structure'''
 
*'''General Codec14 message structure'''
Line 78: Line 78:
 
: 4. Then goes '''command or response quantity field.''' Response message will contain same quantity field value as request command quantity 1st byte (quantity byte that’s located before message field type byte). 2nd byte (quantity byte that’s located at the end before CRC) will not be parsed but it’s recommended that it should contain same value as 1st byte. <br>
 
: 4. Then goes '''command or response quantity field.''' Response message will contain same quantity field value as request command quantity 1st byte (quantity byte that’s located before message field type byte). 2nd byte (quantity byte that’s located at the end before CRC) will not be parsed but it’s recommended that it should contain same value as 1st byte. <br>
 
: 5. After that goes one byte '''message type field.''' If it’s request command from server it has to contain 0x05. The response type field will contain 0x06 if it’s ACK or 0x11 if it’s nACK. <br>
 
: 5. After that goes one byte '''message type field.''' If it’s request command from server it has to contain 0x05. The response type field will contain 0x06 if it’s ACK or 0x11 if it’s nACK. <br>
Explanation:  If received IMEI from server is equal to actual device IMEI received command will be executed and response will be send with ACK (0x06) message type field value.  If received IMEI doesn’t match actual device IMEI, received command won’t be executed and response to server will be send with nACK (0x11) message type field value. <br>
+
Explanation:  If received IMEI from server is equal to actual device IMEI, received command will be executed and response will be sent with ACK (0x06) message type field value.  If received IMEI doesn’t match actual device IMEI, received command won’t be executed and response to server will be sent with nACK (0x11) message type field value. <br>
 
: 6. Then follows four bytes '''command or response size field.''' (make sure that size is IMEI size 8 + actual command size.) Minimal value is 8 because codec14 always contain IMEI and it’s 8 bytes. <br>
 
: 6. Then follows four bytes '''command or response size field.''' (make sure that size is IMEI size 8 + actual command size.) Minimal value is 8 because codec14 always contain IMEI and it’s 8 bytes. <br>
 
: 7. After it follows the '''IMEI'''. IMEI is send as HEX value. Example if device IMEI is 123456789123456 then IMEI data field will contain 0x0123456789123456 value. <br>
 
: 7. After it follows the '''IMEI'''. IMEI is send as HEX value. Example if device IMEI is 123456789123456 then IMEI data field will contain 0x0123456789123456 value. <br>

Revision as of 16:04, 14 June 2019

Codec 14

  • About Codec14

Codec14 is original Teltonika protocol for device-server communication over GPRS messages and it is based on Codec12 protocol

Codec14 GPRS commands can be used for sending configuration, debug, digital outputs control commands or other (special purpose command 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 basic structure of Codec14 messages.

Command message structure

0x00000000 Data size 0x0E Command quantity 0x05 Command size + IMEI size (8 bytes) IMEI (HEX) Command Command quantity CRC
4 bytes 4 bytes 1 bytes 1 bytes 1 bytes 4 bytes 8 bytes X bytes 1 bytes 4 bytes


Response message structure

0x00000000 Data size 0x0E Response quantity 0x06 / 0x11 Response size + IMEI size (8 bytes) IMEI (HEX) Response Response quantity CRC
4 bytes 4 bytes 1 bytes 1 bytes 1 bytes 4 bytes 8 bytes X bytes 1 bytes 4 bytes


  • Structure explanation:
1. The message starts with preamble field - four zero bytes.
2. Then goes four bytes data size field (size is calculated from 0x0E field to the second command or response quantity field).
3. Then follows one byte Codec ID field (in Codec 14 it is always 0x0E).
4. Then goes command or response quantity field. Response message will contain same quantity field value as request command quantity 1st byte (quantity byte that’s located before message field type byte). 2nd byte (quantity byte that’s located at the end before CRC) will not be parsed but it’s recommended that it should contain same value as 1st byte.
5. After that goes one byte message type field. If it’s request command from 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 received IMEI from server is equal to actual device IMEI, received command will be executed and response will be sent with ACK (0x06) message type field value. If received IMEI doesn’t match actual device IMEI, received command won’t be executed and response to server will be sent with nACK (0x11) message type field value.

6. Then follows four bytes command or response size field. (make sure that size is IMEI size 8 + actual command size.) Minimal value is 8 because codec14 always contain IMEI and it’s 8 bytes.
7. After it follows the IMEI. IMEI is send as HEX value. Example if device IMEI is 123456789123456 then IMEI data field will contain 0x0123456789123456 value.
8. After it follows the command or response field itself. If message type field is nACK (0x11) this data field will be empty.
9. After that goes the second command or response quantity field.
10. At the end there’s four bytes CRC field.

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. The algorithm of how to calculate CRC is shown in Figure 3 CRC calculation algorithm.

CRC is shown in Figure 3 CRC calculation algorithm.


  • GPRS in Codec14 examples

Sending "getver" SMS command via GPRS Codec14:
Server requests:
Hexadecimal stream:
00000000000000160E01050000000E0352093081452251676574766572010000D2C1
Parsed:
Zero: 0x00000000
Packet Length: 0x00000016
Codec: 0E
Quantity of commands: 0x01
Command type: 0x05
Command size: 0x0000000E
IMEI: 0x0352093081452251 (HEX string)
Command: 0x676574766572 (HEX of getver)
Quantity of commands: 01
CRC: 0x0000D2C1


Device ACK response:
Hexadecimal stream:
00000000000000AB0E0106000000A303520930814522515665723A30332E31382E3
1345F3034204750533A41584E5F352E31305F333333332048773A464D4231323020
4D6F643A313520494D45493A33353230393330383134353232353120496E69743A3
23031382D31312D323220373A313320557074696D653A3137323334204D41433A3
63042444430303136323631205350433A312830292041584C3A30204F42443A3020
424C3A312E362042543A34
0100007AAE
Parsed:
Zero: 0x00000000
Packet Length: 0x000000AB
Codec: 0x0E
Quantity of commands: 01
Command type: 0x06
Command size: 0x000000A3
IMEI: 0x0352093081452251
Command response in ASCII after conversion:
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

Quantity of commands: 01
CRC: 0x00007AAE


Device nACK response:
Hexadecimal stream:
00000000000000100E011100000008035209308145225101000032AC
Parsed: Zero: 0x00000000
Packet Length: 0x00000010
Codec: 0x0E
Quantity of commands: 01
Command type: 0x0x11
Command size: 0x00000008
IMEI: 0x0352093081452251
Quantity of commands: 01
CRC: 0x000032AC