This TypeScript project converts a Teltonika device's UDP connection, that transmits data using Codec 8/8E, into an MQTT connection that transmits data using Codec JSON.
This is used for integrating legacy devices within OpenRemote, the open-source IoT device management platform. In this way, we are able to support all versions of Teltonika devices, regardless of their Codec/Protocol support.
To use, change the variables found within index.ts. If setup properly, OpenRemote will transmit the messages to the OpenRemote MQTT Broker.
Download the docker-compose.yml
file:
wget https://github.com/pankalog/TeltonikaLegacyCodecSupport/blob/main/docker-compose.yml
And run the server:
docker-compose -p teltonika-server up -d
To set your own environment variables, download the example .env
file:
wget https://github.com/pankalog/TeltonikaLegacyCodecSupport/blob/main/.env
And edit the file to match your specific server settings.
To allow support of all devices within OpenRemote, a new server has been developed. When the server receives properly-formatted and sequenced data, according to Teltonika's Codec 8 and 8E documentation, the server will then connect with a unique MQTT client ID to the specified MQTT broker, sending the contents of the UDP Codec 8 payload formatted in the same way as a Codec JSON, MQTT payload message.
In this way, this server serves as an adapter between older devices with no support for MQTT and/or Codec JSON to the more recent transmission protocol and codec, assuring maximum compatibility of OpenRemote with the entirety of the product-line of Teltonika Telematics.
The server allows for Teltonika devices to connect using Codec 8 and 8E protocols. Any data that is sent to the server is sent via MQTT to any server and topic the user selects in Teltonika's Codec JSON format. Different devices use different UUIDs as the client ID.
The index file is the main developer interface for the server. The UDPServerManager is an EventEmitter, and the events emitted are where the MQTT messages are constructed and sent to the MQTT broker.
Here is a description of what each UdpServerManager
event is:
-
message
:imei, uuid, content
: When amessage
event is emitted, the device withimei
anduuid
has sent a data packet, which is of typeProtocolParser
. Using that class, you can check the metadata of the packet to ensure it contains data the user requires. -
connected
:imei, uuid
: A device with theimei
has connected, and it has been assigned withuuid
. Used for creating a connection to the MQTT broker using theuuid
as a client ID -
disconnected
:imei
: The device withimei
has disconnected.
-
complete-teltonika-parser
: used to parse Teltonika payloads and conduct all necessary checks and data parsing from the devices. -
mqtt
: MQTT.js used for interfacing to the MQTT broker -
moment
: Used for timestamp manipulation, for correct payload formatting -
net
: Used for creating the UDPServer -
crypto
: Used for generating UUIDs. -
events
: Used for extending the EventEmitter
- Compatibility is based solely on npm package
complete-teltonika-parser
, the base of this package - Allows for any type of MQTT(s) connection to be established
- Allows for UDP connection by the device to the application
- Allows multiple devices to be connected by managing WS states
- Raises events in UdpServerManager; for now, these events are fired when a device is connected, sends a message, and disconnects.
- Safe device connect/disconnect
- Bidirectional communication to/from the device, including SMS messages
- MQTT state watch
- Implement more events
- Check multi-device support