Teltonika SDK Typescript
    Preparing search index...

    Class TeltonikaDevice<T>

    Represents a single Teltonika device connection over a network socket. This class manages the device's state, incoming data buffering, and command sending.

    TeltonikaDevice

    Type Parameters

    • T extends Socket
    Index

    Accessors

    • get isInit(): boolean

      Indicates whether the device has been initialized (IMEI assigned).

      Returns boolean

    • get isWaitingPacket(): boolean

      Indicates whether the device currently has unprocessed buffered data.

      Returns boolean

    Constructors

    • Creates a new TeltonikaDevice instance.

      Type Parameters

      • T extends Socket

      Parameters

      • options: { socket: T }
        • socket: T

          The network socket to use for communication.

      Returns TeltonikaDevice<T>

    Methods

    • Appends incoming data to the device's internal buffer.

      Parameters

      • data: Buffer

        The incoming data chunk.

      Returns void

    • Clears the device's internal buffer.

      Returns void

    • Closes the connection with the device.

      Returns void

    • Initializes the device with its IMEI and GPRS codec. Sends a handshake byte (0x01) to the device after initialization.

      Parameters

      • imei: string

        The IMEI of the device.

      • gprs: TeltonikaGPRSCodec

        The GPRS codec for command communication.

      Returns void

    • Sends a command to the device using the specified codec or the device's default GPRS codec.

      Parameters

      • cmd: string

        The command string to send.

      • Optionalcodec: TeltonikaGPRSCodec

        Optional codec to override the device's default codec.

      Returns void

    Properties

    buffer: Buffer = ...

    Buffer to temporarily store incoming data from the device until processed.

    The GPRS codec used by this device for command communication. Undefined until the device is initialized.

    imei?: string

    IMEI of the connected Teltonika device. Undefined until the device is initialized.

    socket: T

    The underlying network socket for communicating with the device.

    uuid: string

    Unique identifier for this device instance.