Automatically translate this page?

How to send commands to Teltonika devices?

Discovering three commands for Teltonika devices: getparam, setparam, and codec12.

This article describes the supported commands for Teltonika devices and the mechanics of their execution from flespi via REST API. To get the general guidance on how to send commands to any device please review this article.

Three commands for Teltonika devices are supported by flespi: getparam, setparam and codec12. We will go over each of the commands, discuss what they are designed to do, and demonstrate how each of them works.

Command getparam

Command getparam requests the current configuration parameter value. Each parameter is identified by a 3 to 5 digit ID. Parameter IDs for a popular FMB device family can be found here. For more specific guidance to parameter IDs please contact your Teltonika representative.

The command schema is as follows:

      "name": "getparam",
      "schema": {
        "additionalProperties": false,
        "description": "Get configuration parameter by its number",
        "properties": {
          "param": {
            "title": "Param number",
            "type": "number"
          }
        },
        "required": [
          "param"
        ],

        "title": "Get configuration param",
        "type": "object",
        "x-view-order": [
          "param"
        ]
      }

Check out step 2 of this guide to learn curl command to get command schema for any supported device protocol. 

The key piece of information to notice in the command schema above is the required property fields. For getparam we can see that the only required property is “param”, which should use a number for the data type.

To execute the command, use the following POST request to place the command into the command queue for the channel. Curl command looks like this:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' -d '[{"address":{"ident":"YOUR_DEVICE_IDENT","type":"connection"},"name":"getparam","properties":{"param":138},"ttl":86400}]' 'https://flespi.io/gw/channels/YOUR_CHANNEL_ID/commands-queue'

The command above requests the value for the parameter ID 138, which is a movement source for the Teltonika FMB series devices

To check if the command was successfully executed, as well as the response, the following GET request should be used. Curl command looks like this:

curl -X GET --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' 'https://flespi.io/gw/channels/YOUR_CHANNEL_ID/commands-result'

The actual result of the execution to request the value of ID 138 would look as follows:

{
 "result": [
    {
      "address": {
        "ident": "359632100187225",
        "type": "connection"
      },
      "channel_id": 13877,
      "executed": true,
      "id": 44719815,
      "name": "getparam",
      "properties": {
        "param": 138
      },
      "response": "Param ID:138 Value:2",
      "timestamp": 1596214427.430689,
      "transport": "tcp"
    }
  ],
  "next_key": 3347504279060501
}

Items to note: parameter “executed” should have the value true, “response” contains the response from the device "Param ID:138 Value:2". By checking the Teltonika documentation we see that value 2 means that movement source is Accelerometer.

Command setparam

Command setparam assigns the submitted value to a configuration parameter. Each parameter is identified by a 3 to 5 digit ID. Parameter IDs for a popular FMB device family can be found here. For more specific guidance to parameter IDs please contact your Teltonika representative.

The command schema is as follows:

      "name": "setparam",
      "schema": {
        "additionalProperties": false,
        "description": "Set configuration parameter by its number",
        "properties": {
          "param": {
            "title": "Param number",
            "type": "number"
          },
          "value": {
            "title": "Param value",
            "type": "string"
          }
        },
        "required": [
          "param",
          "value"
        ],

        "title": "Set configuration param",
        "type": "object",
        "x-view-order": [
          "param",
          "value"
        ]
      }

Check out step 2 of this guide to learn curl command to get command schema for any supported device protocol. 

The key piece of information to notice in the command schema above is the required property fields. For setparam we can see that the two required properties are “param” and “value”. Note that the data type for “param” is number, while data type for “value” is a string.

To execute the command, use the following POST request to place the command into the command queue for the channel. Curl command looks like this:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' -d '[{"address":{"ident":"YOUR_DEVICE_IDENT","type":"connection"},"name":"setparam","properties":{"param":138,"value":"1"},"ttl":86400}]' 'https://flespi.io/gw/channels/YOUR_CHANNEL_ID/commands-queue'

The command above sets the value for the parameter ID 138, which is a movement source for Teltonika FMB series devices, to 1. Per Teltonika documentation, value 1 means that the movement source is Ignition.

To check if the command was successfully executed, as well as the response, the following GET request should be used. Curl command looks like this:

curl -X GET --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' 'https://flespi.io/gw/channels/YOUR_CHANNEL_ID/commands-result'

The actual result of the successful execution of setparam command to set the value of ID 138 to 1 would look as follows:

{
 "result": [
    {
      "address": {
        "ident": "359632100187225",
        "type": "connection"
      },
      "channel_id": 13877,
      "executed": true,
      "id": 45060043,
      "name": "setparam",
      "properties": {
        "param": 138,
        "value": "1"
      },
      "response": "New value 138:1;",
      "timestamp": 1596805117.464677,
      "transport": "tcp"
    }
  ],
  "next_key": 3348743045775382
}

Items to note: parameter “executed” should have the value true, “response” contains the response from the device "New value 138:1;"

Command codec12

Command codec12 allows executing custom commands. For specific guidance on what custom commands are available for your Teltonika devices model, please contact your Teltonika representative.

The command schema is as follows:

      "name": "codec12",
      "schema": {
        "additionalProperties": false,
        "description": "Send command encoded in Codec 12",
        "properties": {
          "crlf": {
            "default": true,
            "title": "Add CR and LF bytes after text payload",
            "type": "boolean"
          },
          "hex": {
            "default": false,
            "title": "Payload is encoded as HEX string",
            "type": "boolean"
          },
          "payload": {
            "title": "Text or hex data to send",
            "type": "string"
          }
        },
        "required": [
          "payload"
        ],

        "title": "Codec 12 command",
        "type": "object",
        "x-view-order": [
          "payload",
          "crlf",
          "hex"
        ]
      }

Check out step 2 of this guide to learn curl command to get command schema for any supported device protocol. 

The key piece of information to notice in the command schema above is the required property fields. For codec12 we can see that the only required property is “payload”, which should use string for the data type. 

There are also two default properties:

  • "crlf" property, which is set to true, adds CR and LF bytes after the payload. If adding CR and LF bytes is not needed, this property should be added to command syntax and set to false
  • “hex” property is set to false. If your payload is represented with hexadecimal values, this property should be added to command syntax and set to true.

To execute the command, use the following POST request to place the command into the command queue for the channel. Curl command looks like this:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' -d '[{"address":{"ident":"YOUR_DEVICE_IDENT","type":"connection"},"name":"codec12","properties":{"payload":"ggps"},"ttl":86400}]' 'https://flespi.io/gw/channels/YOUR_CHANNEL_ID/commands-queue'

The custom command ggps executed with the curl command above requests the device’s current location information along with the Google maps link. 

To check if the command was successfully executed, as well as the response, the following GET request should be used. Curl command looks like this:

curl -X GET --header 'Accept: application/json' --header 'Authorization: FlespiToken YOUR_FLESPI_TOKEN' 'https://flespi.io/gw/channels/Your_channel_ID/commands-result'

The actual result of the successful execution of ggps custom command would look as follows:

{
 "result": [
    {
      "address": {
        "ident": "359632100187225",
        "type": "connection"
      },
      "channel_id": 13877,
      "executed": true,
      "id": 45069054,
      "name": "codec12",
      "properties": {
        "crlf": true,
        "hex": false,
        "payload": "ggps"
      },
      "response": "D:20/8/7 T:15:29:22 S:0.00 C:52.946293, 27.813925 Url: http://maps.google.com/?q=52.946293,27.813925&om=1speed:0",
      "timestamp": 1596814163.370816,
      "transport": "tcp"
    }
  ],
  "next_key": 3348762016612370
}

Items to note: parameter “executed” should have the value true, “response” contains the response from the device "D:20/8/7 T:15:29:22 S:0.00 C:52.946293, 27.813925 Url: http://maps.google.com/?q=52.946293,27.813925&om=1speed:0"


See also
Four ways for the massive creation of devices in the flespi platform.
Using flespi MQTT stream to publish the data from your devices to the MQTT broker.