This article describes how IoT Platform sends the configuration data and Thing Specification Language (TSL) models of sub-devices to a connected gateway.

Send configuration data

Request topic: /sys/{productKey}/{deviceName}/thing/model/config/push

Configuration data that is sent in the Alink JSON format:

{
  "id": 123,
  "version": "1.0",
  "method": "thing.config.push"
  "data": {
    "digest":"",
    "digestMethod":"",
    "url": ""
  }
}

The following table describes the parameters.

Parameter Type Description
id String

The message ID. Valid values: 0 to 4294967295. Each message ID must be unique for the device.

version String The version of the protocol. Valid value: 1.0.
method String The request method. Valid value: thing.model.config.push.
data Object The configuration data.
digest String The signature to verify the integrity of configuration data that is obtained from the endpoint of an Object Storage Service (OSS) bucket.
digestMethod String The signature algorithm. Default value: sha256.
url String The endpoint of an OSS bucket where the configuration data of sub-devices is stored. You can access the endpoint to obtain the configuration data.

Format of configuration data for sub-devices

Sample configuration data that is stored in an OSS bucket:

{
  "modelList": [
    {
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "services": [
        {
          "outputData": "",
          "identifier": "AngleSelfAdaption",
          "inputData": [
            {
              "identifier": "test01",
              "index": 0
            }
          ],
          "displayName": "test01"
        }
      ],
      "properties": [
        {
          "identifier": "identifier",
          "displayName": "test02"
        },
        {
          "identifier": "identifier_01",
          "displayName": "identifier_01"
        }
      ],
      "events": [
        {
          "outputData": [
            {
              "identifier": "test01",
              "index": 0
            }
          ],
          "identifier": "event1",
          "displayName": "abc"
        }
      ]
    },
    {
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "properties": [
        {
          "originalDataType": {
            "specs": {
              "registerCount": 1,
              "reverseRegister": 0,
              "swap16": 0
            },
            "type": "bool"
          },
          "identifier": "test01",
          "registerAddress": "0x03",
          "scaling": 1,
          "operateType": "inputStatus",
          "trigger": {
        },
        {
          "originalDataType": {
            "specs": {
              "registerCount": 1,
              "reverseRegister": 0,
              "swap16": 0
            },
            "type": "bool"
          },
          "identifier": "test02",
          "registerAddress": "0x05",
          "scaling": 1,
          "operateType": "coilStatus",
          "trigger": 2
        }
      ]
    },
    {
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "properties": [
        {
          "identifier": "test_02",
          "customize": {
            "test_02": 123
          }
        },
        {
          "identifier": "test_01",
          "customize": {
            "test01": 1
          }
        }
      ]
    }
  ],
  "serverList": [
    {
      "baudRate": 1200,
      "protocol": "RTU",
      "pageSize": 8,
      "stopBits": 2,
      "parity": 1,
      "name": "modbus01",
      "serialPort": "0",
      "serverId": "D73251B427****"
    },
    {
      "protocol": "TCP",
      "port": 8000,
      "ip": "192.168.0.1",
      "name": "modbus02",
      "serverId": "586CB066D****"
    },
    {
      "password": "XIJTginONohPEUAyZ****==",
      "secPolicy": "Basic128Rsa15",
      "name": "server_01",
      "secMode": "Sign",
      "userName": "123",
      "serverId": "55A9D276A7E****",
      "url": "tcp:00",
      "timeout": 10
    },
    {
      "password": "hAaX5s13gwX2JwyvUk****==",
      "name": "service_09",
      "secMode": "None",
      "userName": "1234",
      "serverId": "44895C63E3F****",
      "url": "tcp:00",
      "timeout": 10
    }
  ],
  "DeviceList": [
    {
      "deviceConfig": {
        "displayNamePath": "123",
        "serverId": "44895C63E3FF4013924CEF31519A****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test_02"
    },
    {
      "deviceConfig": {
        "displayNamePath": "1",
        "serverId": "55A9D276A7****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test_03"
    },
    {
      "deviceConfig": {
        "slaveId": 1,
        "serverId": "D73251B4277****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test01"
    },
    {
      "deviceConfig": {
        "slaveId": 2,
        "serverId": "586CB066D6****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test",
    }
  ],
  "tslList": [
    {
      "schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "services": [
        {
          "outputData": []
          "identifier": "set",
          "inputData": [
            {
              "identifier": "test02",
              "dataType": {
                "specs": {
                  "unit": "mm",
                  "min": "0",
                  "max": "1",
                },
                "type": "int"
              },
              "name": "Beta feature 02"
            }
          ],
          "method": "thing.service.property.set",
          "name": "set",
          "required": true,
          "callType": "async",
          "desc": "Set properties",
        },
        {
          "outputData": [
            {
              "identifier": "test01",
              "dataType": {
                "specs": {
                  "unit": "m",
                  "min": "0",
                  "max": "1"
                },
                "type": "int"
              },
              "name": "Beta feature 01"
            },
            {
              "identifier": "test02",
              "dataType": {
                "specs": {
                  "unit": "mm",
                  "min": "0",
                  "max": "1"
                },
                "type": "int"
              },
              "name": "Beta feature 02"
            }
          ],
          "identifier": "get",
          "inputData": [
            "test01",
            "test02"
          ],
          "method": "thing.service.property.get",
          "name": "get",
          "required": true,
          "callType": "async",
          "desc": "Obtain properties",
        }
      ],
      "properties": [
        {
          "identifier": "test01",
          "dataType": {
            "specs": {
              "unit": "m",
              "min": "0",
              "max": "1"
            },
            "type": "int"
          },
          "name":"Beta feature 01",
          "accessMode": "r",
          "required": false
        },
        {
          "identifier": "test02",
          "dataType": {
            "specs": {
              "unit": "mm",
              "min": "0",
              "max": "1"
            },
            "type": "int"
          },
          "name": "Beta feature 02",
          "accessMode": "rw",
          "required": false
        }
      ],
      "events": [
        {
          "outputData": [
            {
              "identifier": "test01",
              "dataType": {
                "specs": {
                  "unit": "m",
                  "min": "0",
                  "max": "1"
                },
                "type": "int"
              },
              "name": "Beta feature 01"
            },
            {
              "identifier": "test02",
              "dataType": {
                "specs": {
                  "unit": "mm",
                  "min": "0",
                  "max": "1"
                },
                "type": "int"
              },
              "name": "Beta feature 02"
            }
          ],
          "identifier": "post",
          "method": "thing.event.property.post",
          "name": "post",
          "type":"info",
          "required": true,
          "desc": "Report properties",
        }
      ]
    },
    {
      "schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "services": [
        {
          "outputData": []
          "identifier": "set",
          "inputData": [
            {
              "identifier": "identifier",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "7614"
            },
            {
              "identifier": "identifier_01",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "Beta feature 1"
            }
          ],
          "method": "thing.service.property.set",
          "name": "set",
          "required": true,
          "callType": "async",
          "desc": "Set properties",
        },
        {
          "outputData": [
            {
              "identifier": "identifier",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "7614"
            },
            {
              "identifier": "identifier_01",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "Beta feature 1"
            }
          ],
          "identifier": "get",
          "inputData": [
            "identifier",
            "identifier_01"
          ],
          "method": "thing.service.property.get",
          "name": "get",
          "required": true,
          "callType": "async",
          "desc": "Obtain properties",
        },
        {
          "outputData": []
          "identifier": "AngleSelfAdaption",
          "inputData": [
            {
              "identifier": "test01",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "10",
                  "step": "1"
                },
                "type": "int"
              },
              "name": "Parameter 1",
            }
          ],
          "method": "thing.service.AngleSelfAdaption",
          "name": "Adaptive angle calibration",
          "required": false,
          "callType": "async"
        }
      ],
      "properties": [
        {
          "identifier": "identifier",
          "dataType": {
            "specs": {
              "length": "2048"
            },
            "type": "text"
          },
          "name": "7614",
          "accessMode": "rw",
          "required": true
        },
        {
          "identifier": "identifier_01",
          "dataType": {
            "specs": {
              "length": "2048"
            },
            "type": "text"
          },
          "name":"Beta feature 1",
          "accessMode": "rw",
          "required": false
        }
      ],
      "events": [
        {
          "outputData": [
            {
              "identifier": "identifier",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "7614"
            },
            {
              "identifier": "identifier_01",
              "dataType": {
                "specs": {
                  "length": "2048"
                },
                "type": "text"
              },
              "name": "Beta feature 1"
            }
          ],
          "identifier": "post",
          "method": "thing.event.property.post",
          "name": "post",
          "type":"info",
          "required": true,
          "desc": "Report properties",
        },
        {
          "outputData": [
            {
              "identifier": "test01",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "20",
                  "step": "1"
                },
                "type": "int"
              },
              "name": "Beta feature 1"
            }
          ],
          "identifier": "event1",
          "method": "thing.event.event1.post",
          "name": "event1",
          "type":"info",
          "required": false
        }
      ]
    },
    {
      "schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "services": [
        {
          "outputData": []
          "identifier": "set",
          "inputData": [
            {
              "identifier": "test_01",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "1"
                },
                "type": "int"
              },
              "name": "Parameter 1",
            },
            {
              "identifier": "test_02",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "10"
                },
                "type": "double"
              },
              "name": "Parameter 2",
            }
          ],
          "method": "thing.service.property.set",
          "name": "set",
          "required": true,
          "callType": "async",
          "desc": "Set properties",
        },
        {
          "outputData": [
            {
              "identifier": "test_01",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "1"
                },
                "type": "int"
              },
              "name": "Parameter 1",
            },
            {
              "identifier": "test_02",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "10"
                },
                "type": "double"
              },
              "name": "Parameter 2",
            }
          ],
          "identifier": "get",
          "inputData": [
            "test_01",
            "test_02"
          ],
          "method": "thing.service.property.get",
          "name": "get",
          "required": true,
          "callType": "async",
          "desc": "Obtain properties",
        }
      ],
      "properties": [
        {
          "identifier": "test_01",
          "dataType": {
            "specs": {
              "min": "1",
              "max": "100",
              "step": "1"
            },
            "type": "int"
          },
          "name": "Parameter 1",
          "accessMode": "rw",
          "required": false
        },
        {
          "identifier": "test_02",
          "dataType": {
            "specs": {
              "min": "1",
              "max": "100",
              "step": "10"
            },
            "type": "double"
          },
          "name": "Parameter 2",
          "accessMode": "rw",
          "required": false
        }
      ],
      "events": [
        {
          "outputData": [
            {
              "identifier": "test_01",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "1"
                },
                "type": "int"
              },
              "name": "Parameter 1",
            },
            {
              "identifier": "test_02",
              "dataType": {
                "specs": {
                  "min": "1",
                  "max": "100",
                  "step": "10"
                },
                "type": "double"
              },
              "name": "Parameter 2",
            }
          ],
          "identifier": "post",
          "method": "thing.event.property.post",
          "name": "post",
          "type":"info",
          "required": true,
          "desc": "Report properties",
        }
      ]
    }
  ]
}

The following table describes the parameters.

Parameter Type Description
modelList Object The extended information of all sub-devices of a gateway. For more information, see Description of the modelList parameter.
serverList Object The connection channel information of all sub-devices of a gateway. For more information, see Description of the serverList parameter.
deviceList Object The configuration data of all sub-devices of a gateway. For more information, see Description of the deviceList parameter.
tslList Object The TSL models of all sub-devices of a gateway. For more information, see The TSL format.

Description of the modelList parameter

Available device protocols include Modbus, OPC UA, and custom. The extended information changes based on the protocol.

  • Sample extended information of a Modbus sub-device:

    {
      "profile ":{
        "productKey": "a1bPo9p****",
      },
      "properties": [
        {
          "originalDataType": {
            "specs": {
              "registerCount": 1,
              "reverseRegister": 0,
              "swap16": 0
            },
            "type": "bool"
          },
          "identifier": "test01",
          "registerAddress": "0x03",
          "scaling": 1,
          "operateType": "inputStatus",
          "trigger": 1
        },
        {
          "originalDataType": {
            "specs": {
              "registerCount": 1,
              "reverseRegister": 0,
              "swap16": 0
            },
            "type": "bool"
          },
          "identifier": "test02",
          "registerAddress": "0x05",
          "scaling": 1,
          "operateType": "coilStatus",
          "trigger": 2
        }
      ]
    }

    The following table describes the parameters.

    Parameter Type Description
    identifier String The identifier of each property, event, or service.
    operateType String The operation type. Valid values:
    • coilStatus
    • inputStatus
    • holdingRegister
    • inputRegister
    registerAddress String The register address.
    originalDataType Object The data type of original data.
    type String The data type. Valid values:

    int16, uint16, int32, uint32, int64, uint64, float, double, string, and bool.

    specs Object The description.
    registerCount Integer The number of registers.
    swap16 Integer Specifies whether to swap the first and last 8 bits of the 16-bit data in the register. 0: do not swap and 1: swap.
    reverseRegister Integer Specifies whether to swap the first and last 16 bits of the original 32-bit data.
    • 0: do not swap
    • 1: swap
    scaling Integer The zoom factor.
    trigger Integer The report method. Valid values:
    • 1: specifies to report data at a specific time
    • 2: specifies to report changes
  • Sample extended information of an OPC UA sub-device:

    {
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "services": [
        {
          "outputData": {
          "identifier": "AngleSelfAdaption",
          "inputData": [
            {
              "identifier": "test01",
              "index": 0
            }
          ],
          "displayName": "test01"
        }
      ],
      "properties": [
        {
          "identifier": "identifier",
          "displayName": "test02"
        },
        {
          "identifier": "identifier_01",
          "displayName": "identifier_01"
        }
      ],
      "events": [
        {
          "outputData": [
            {
              "identifier": "test01",
              "index": 0
            }
          ],
          "identifier": "event1",
          "displayName": "abc"
        }
      ]
    }

    The following table describes the parameters.

    Parameter Type Description
    services Object The services.
    properties Object The properties.
    events Object The events.
    outputData Object The output parameters, for example, the response data of a data reporting event or service invocation.
    identifier String The identifier of each property, event, service.
    inputData Object The input parameters, for example, the input parameters of a service.
    index Integer The index information.
    displayName String The name of each property, event, or service.
  • Sample extended information of a custom sub-device:
    {
      "profile ":{
        "productKey": "a1ZlGQv****"
      },
      "properties": [
        {
          "identifier": "test_02",
          "customize": {
            "test_02": 123
          }
        },
        {
          "identifier": "test_01",
          "customize": {
            "test01": 1
          }
        }
      ]
    }

    The following table describes the parameters.

    Parameter Type Description
    ProductKey String The key of the product. In IoT Platform, each product key must be unique.
    properties Object The properties.
    identifier String The identifier of each property.
    customize Object The custom information of the property. When you define a property, you can specify the information for the property.

Description of the serverList parameter

The connection channel information is available for Modbus and OPC UA sub-devices.

  • Sample connection channel information of a Modbus sub-device:

    [
      {
        "baudRate": 1200,
        "protocol": "RTU",
        "pageSize": 8,
        "stopBits": 2,
        "parity": 1,
        "name": "modbus01",
        "serialPort": "0",
        "serverId": "D73251B427****"
      },
      {
        "protocol": "TCP",
        "port": 8000,
        "ip": "192.168.0.1",
        "name": "modbus02",
        "serverId": "586CB066D****"
      }
    ]
    Parameter Type Description
    protocol String The protocol type. Valid values: TCP and RTU.
    port Integer The port number.
    ip String The IP address.
    name String The channel name of the sub-device.
    serverId String The channel ID of the sub-device.
    baudRate Integer The baud rate.
    byteSize Integer The number of bytes.
    stopBits Integer The stop bit.
    parity Integer The parity bit. Valid values:
    • E: even parity check
    • O: odd parity check
    • N: no check
    serialPort String The serial port number.
  • Sample connection channel information of an OPC UA sub-device:

    {
      "password": "XIJTginONohPEUAyZx****==",
      "secPolicy": "Basic128Rsa15",
      "name": "server_01",
      "secMode": "Sign",
      "userName": "123",
      "serverId": "55A9D276A7E****",
      "url": "tcp:00",
      "timeout": 10
    }

    The following table lists the parameters.

    Parameter Type Description
    password String The password. The Advanced Encryption Standard (AES) algorithm is used to encrypt the password.
    secPolicy String The encryption algorithm. Valid values: None, Basic128Rsa15, and Basic256.
    secMode String The encryption mode. Valid values: None, Sign, and SignAndEncrypt.
    name String The channel name of the sub-device.
    userName String The username.
    serverId String The channel ID of the sub-device.
    url String The URL of the server.
    timeout Integer The timeout period.

    Encrypt the password of an OPC UA sub-device

    IoT Platform uses the AES encryption algorithm and 128-bit grouping. The default mode is cipher block chaining (CBC). The default padding is PKCS5Padding. The secret of a device is used as a key. The encrypted result is encoded in the Base64 format.

    Example:
    Note We recommend that you use Java SE 6u181 or later, Java SE 7u171, Java SE 8u161, and Java SE 9. If you run the following sample code on Java of an earlier version, errors may occur. For more information about Java errors, see Java Bug Database.
    private static String instance = "AES/CBC/PKCS5Padding";
    
        private static String algorithm = "AES";
    
        private static String charsetName = "utf-8";
        /**
         * Encryption algorithm.
         *
         * @param data             The data to be encrypted.
         * @param deviceSecret The secret of the device.
         * @return
         */
        public static String aesEncrypt(String data, String deviceSecret) {
            try {
                Cipher cipher = Cipher.getInstance(instance);
                byte[] raw = deviceSecret.getBytes();
                SecretKeySpec key = new SecretKeySpec(raw, algorithm);
                IvParameterSpec ivParameter = new IvParameterSpec(deviceSecret.substring(0, 16).getBytes());
                cipher.init(Cipher.ENCRYPT_MODE, key, ivParameter);
                byte[] encrypted = cipher.doFinal(data.getBytes(charsetName));
    
                return new BASE64Encoder().encode(encrypted);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
            return null;
        }
    
        public static String aesDecrypt(String data, String deviceSecret) {
            try {
                byte[] raw = deviceSecret.getBytes(charsetName);
                byte[] encrypted1 = new BASE64Decoder().decodeBuffer(data);
                SecretKeySpec key = new SecretKeySpec(raw, algorithm);
                Cipher cipher = Cipher.getInstance(instance);
                IvParameterSpec ivParameter = new IvParameterSpec(deviceSecret.substring(0, 16).getBytes());
                cipher.init(Cipher.DECRYPT_MODE, key, ivParameter);
                byte[] originalBytes = cipher.doFinal(encrypted1);
                String originalString = new String(originalBytes, charsetName);
                return originalString;
            } catch (Exception ex) {
                ex.printStackTrace();
            }
    
            return null;
        }
    
        public static void main(String[] args) throws Exception {
            String text = "test123";
            String secret = "testTNmjyWHQzniA8wEkTNmjyWH****";
            String status = null;
            data = aesEncrypt(text, secret);
            System.out.println(data);
            System.out.println(aesDecrypt(data, secret));
        }

Description of the deviceList parameter

  • Sample configuration information of a Modbus sub-device:

    {
      "deviceConfig": {
        "slaveId": 1,
        "serverId": "D73251B42777****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test01"
    }

    The following table describes the parameters.

    Parameter Type Type
    deviceConfig Object The configuration information.
    slaveId Integer The identifier of the sub-device.
    serverId String The channel ID of the sub-device.
    productKey String The product key of the sub-device.
    deviceName String The name of the sub-device.
  • Sample configuration information of an OPC UA sub-device:

    {
      "deviceConfig": {
        "displayNamePath": "123",
        "serverId": "44895C63E3FF4013924CEF31519A****"
      },
      "productKey": "a1ZlGQv****",
      "deviceName": "test_02"
    }

    The following table describes the parameters.

    Parameter Type Description
    deviceConfig Object The configuration information.
    productKey String The product key of the sub-device.
    deviceName String The name of the sub-device.
    displayNamePath String The custom name.
    serverId String The channel ID of the sub-device.