teltonika-avl-protocol 0.1.0

Teltonika AVL protocol written in Rust
Documentation
  • Coverage
  • 0%
    0 out of 72 items documented0 out of 29 items with examples
  • Size
  • Source code size: 29.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.68 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 43s Average build duration of successful builds.
  • all releases: 43s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • mpowell90/teltonika-avl-protocol
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mpowell90

Crates.io Docs Docs

About the project

The AVL protocol defines a set of codecs that enable interfacing with a variety of Teltonika vehicle tracking devices.

Depending on the device feature set and physical configuration, codec packets can contain GPS data such as longitude/latitude coordinates, angle of travel, altitude, and current speed, as well as IO event data such as ignition status and more.

Included

  • Data-types and functionality for encoding and decoding AVL Codec8 packets.
  • no-std compatible
  • Re-exports Heapless::Vec as StackVec to avoid polluting namespace incase your project uses std

Implemented Codecs

  • Codec 8 (0x08)

Installation

cargo add teltonika-avl-protocol

or add to Cargo.toml dependencies, crates.io for latest version.

Codec8 packet handling

use teltonika_avl_protocol::{
    StackVec,
    codec8::{
        AvlDataRecord, AvlGpsElement, AvlN1Element, AvlN2Element, AvlN4Element, AvlN8Element,
        Codec8Packet, Coordinate, Priority,
    },
};

pub fn main() {
    let mut buf = [0; Codec8Packet::MAX_LENGTH];

    let packet = Codec8Packet {
        avl_data_records: StackVec::from_slice(&[AvlDataRecord {
            timestamp: 0x000000016b40d8ea30,
            priority: Priority::Medium,
            gps_element: AvlGpsElement {
                longitude: Coordinate(0.0),
                latitude: Coordinate(0.0),
                altitude: 0,
                angle: 0,
                satellites: 0,
                speed: 0,
            },
            event_io_id: 1,
            total_io_count: 4,
            n1_elements: StackVec::from_slice(&[AvlN1Element {
                id: 0x15,
                value: 0x03,
            }])
            .unwrap(),
            n2_elements: StackVec::from_slice(&[AvlN2Element {
                id: 0x42,
                value: 0x5e0f,
            }])
            .unwrap(),
            n4_elements: StackVec::from_slice(&[AvlN4Element {
                id: 0xf1,
                value: 0x0000601a,
            }])
            .unwrap(),
            n8_elements: StackVec::from_slice(&[AvlN8Element {
                id: 0x4e,
                value: 0x0,
            }])
            .unwrap(),
        }])
        .unwrap(),
    };

    let bytes_encoded = packet.encode(&mut buf).unwrap();

    let (bytes_decoded, packet_decoded) = Codec8Packet::decode(&buf[..bytes_encoded]).unwrap();

    assert_eq!(bytes_encoded, bytes_decoded);
    assert_eq!(packet, packet_decoded);
}

Contributing

This project is open to contributions, create a new issue and let's discuss.

License

Distributed under the MIT License. See LICENSE.txt for more information.

Acknowledgments

This is an independent open-source project and is not an official Teltonika project, product, or repository.

The Teltonika name and the following specification are copyright of Teltonika IOT Group.

Teltonika AVL Protocol specification: https://wiki.teltonika-gps.com/view/Teltonika_AVL_Protocols