How to send commands to Teltonika devices?

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

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

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

Command custom

Command custom allows sending any custom data to the device as codec12 command. For specific guidance on what custom commands are available for your Teltonika devices model, please contact your Teltonika representative or search for it in the Teltonika wiki (e.g. here is the list of commands for the FMB640 device series).

The command schema is as follows:

      "name": "custom",
      "schema": {
        "anyOf": [
          {
            "additionalProperties": false,
            "description": "Send custom command with text payload",
            "properties": {
              "text": {
                "title": "Text payload",
                "type": "string"
              }
            },
            "required": [
              "text"
            ],
            "title": "Text payload",
            "type": "object",
            "x-view-order": [
              "text"
            ]
          },
          {
            "additionalProperties": false,
            "description": "Send custom command with binary payload",
            "properties": {
              "hex": {
                "pattern": "^([0-9A-Fa-f]{2})+$",
                "title": "Binary payload in HEX form",
                "type": "string"
              }
            },
            "required": [
              "hex"
            ],
            "title": "Binary payload",
            "type": "object",
            "x-view-order": [
              "hex"
            ]
          }
        ],
        "description": "Send custom command via connection or over SMS",
        "title": "Custom command"
      }

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 custom we can see that schema must consist of any of parameters:

  • "text" property is used if you need to send ASCII text.
  • “hex” property is used if you need to send binary data. In this case, the property string value has to be HEX-formated (even number of symbols from 0 to 9 and from A to F)

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":"custom","properties":{"text":"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": "custom",
      "properties": {
        "text": "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"

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 on 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 and to see the response, use the following GET request. 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 the 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 on 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 a number, while the 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;"


See also
Using plugins to resolve position coordinates into address using Here reverse geocoding API and add it into the device messages.
Configuring custom parsing for NMEA-formatted GPS data to convert it into JSON message with standardized parameters.