AbstractCalculates the CRC-16 of the data payload.
Creates a response buffer to acknowledge receipt of the packet. Typically contains the number of data records processed.
Returns the internal state of the packet.
Initializes a new packet instance by parsing the raw buffer.
Validates CRC and extracts records using parseRecords.
The raw packet buffer received from the device.
Calculate the byte length of the IO section.
This method walks through all IO groups in the order defined by
Teltonika Codec8E specification:
Each group starts with a 2-byte counter followed by that many IO entries. The total IO section length is derived exclusively from these counters and value sizes.
Buffer containing the IO section, starting at N1 of One Byte IO
IO group value sizes (default: [1, 2, 4, 8, 0])
Define the layout to calcul IO length.
Total number of bytes occupied by the IO section
Parse Teltonika packet header fields from the raw buffer.
Packet structure (Codec8 / Codec8E):
0–3 : Preamble (always 0x00000000) 4–7 : Data Field Length 8 : Codec ID 9 : Number of Data 1 (records count) 10.. : AVL Data -5 : Number of Data 2 (records count) -4..-1: CRC-16
Full Teltonika packet buffer
Codec8E packet example:
00 00 00 00 // Preamble
00 00 00 4A // Data Field Length (74 bytes)
8E // Codec ID (Codec8E)
01 // Number of Data 1
... // AVL Data
01 // Number of Data 2
00 00 29 94 // CRC-16
const buffer = Buffer.from(
"000000000000004A8E01" +
"0000016B4F831C6801" + // timestamp + priority
"000000000000000000000000" +
"00010005000100010100010011001d" +
"00010010015e2c88" +
"0002000b000000003544c87a000e000000001dd7e06a" +
"0001" +
"00002994",
"hex"
);
packet.parse(buffer);
console.log(packet.codecId); // 0x8E
console.log(packet.numberOfData1); // 1
console.log(packet.numberOfData2); // 1
console.log(packet.size); // 74
Parse all IO groups (N1, N2, N4, N8, NX) of an AVL record and merge them into a single IO object.
Buffer containing IO section of the AVL record
Total number of IO properties (N)
IO group value sizes (default: [1, 2, 4, 8, 0])
Define the layout to parse IO.
Object mapping AVL IO IDs to raw Buffer values
From https://wiki.teltonika-gps.com/view/Codec#Codec_8_Extended
Codec8E AVL IO example:
Event IO ID:
00 01
N of Total ID:
00 05
N1 (1 byte):
00 01
00 01 | 01
N2 (2 bytes):
00 01
00 11 | 00 1D
N4 (4 bytes):
00 01
00 10 | 01 5E 2C 88
N8 (8 bytes):
00 02
00 0B | 00 00 00 00 35 44 C8 7A
00 0E | 00 00 00 00 1D D7 E0 6A
NX:
00 00
const ioBuffer = Buffer.from(
"0001000101" +
"00010011001d" +
"00010010015e2c88" +
"0002000b000000003544c87a000e000000001dd7e06a" +
"0000",
"hex"
);
const io = packet.parseIo(ioBuffer, 5);
console.log(io);
// {
// 1: <Buffer 01>, // DIN1
// 17: <Buffer 00 1d>, // Axis X
// 16: <Buffer 01 5e 2c 88>, // Total Odometer
// 11: <Buffer 00 00 00 00 35 44 c8 7a>, // ICCID1
// 14: <Buffer 00 00 00 00 1d d7 e0 6a> // ICCID2
// }
Parse a single IO group from an AVL record.
This method parses one IO group (N1, N2, N4, N8 or NX) according to Teltonika Codec8E specification.
Buffer containing IO data starting at the group counter
Current offset in the buffer
Value size in bytes:
Define the layout to parse io group.
Parsed IO values and updated offset
AbstractparseParse records from a Teltonika packet.
This method must be implemented by codec-specific packet classes
(e.g. Codec8, Codec8E, Codec16).
The implementation is responsible for:
Full Teltonika packet buffer
Array of parsed records
ProtectedcodecCodec identifier of this packet
ProtectedcrcCRC-16 checksum from the packet
ProtecteddataRaw data buffer containing the payload
ProtectednumberNumber of data records (part 1)
ProtectednumberNumber of data records (part 2)
ProtectedpreamblePreamble of the packet (first 4 bytes)
ProtectedrawFull raw buffer of the packet, including header and CRC
Parsed records from the packet
ProtectedsizeSize of the data part of the packet
Base abstract class representing a Teltonika data packet. Handles parsing of packet headers, CRC validation, and extraction of records.
TeltonikaBasePacket
Example