设备TSL配置信息是指设备的属性、事件和服务的配置信息,可通过调用API,获取设备的TSL配置信息。

请求Topic

获取设备TSL配置Topic:{srcApp}/request/thing/$Your_ProductKey/$Your_DeviceName/getTsl

其中,$Your_ProductKey表示设备所属产品的ProductKey,$Your_DeviceName表示设备的名称。

请求Payload

{
  "requestId": "0bc458b5-47f6-472f-bd88-3624696e****",
  "version": "1.0",
  "timeout":3          # 最少1s,最多120s
}

参数说明请参见Payload通用参数说明

响应Topic

获取设备TSL响应Topic:linkedge/response/{srcApp}/$Your_ProductKey/$Your_DeviceName/getTsl

其中,$Your_ProductKey表示设备所属产品的ProductKey,$Your_DeviceName表示设备的名称。

响应Payload

{
    "params":{
        "productKey":"a1KRepm****",
        "deviceName":"modbus_tcp_dev_1",
        "code":0,
        "message":"success",
        "tsl":"{"events":[{"desc":"属性上报","identifier":"post","method":"thing.event.property.post","name":"post","outputData":[{"dataType":{"specs":{"max":"2147483647","min":"-2147483648","unit":"Mpa"},"type":"double"},"identifier":"pressure1","name":"pressure1"}],"required":true,"type":"info"}],"profile":{"productKey":"a1KRepm****"},"properties":[{"accessMode":"rw","dataType":{"specs":{"max":"2147483647","min":"-2147483648","unit":"Mpa"},"type":"double"},"identifier":"pressure1","name":"pressure1","required":true}],"schema":"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json","services":[{"callType":"async","desc":"属性设置","identifier":"set","inputData":[{"dataType":{"specs":{"max":"2147483647","min":"-2147483648","unit":"Mpa"},"type":"double"},"identifier":"pressure1","name":"pressure1"}],"method":"thing.service.property.set","name":"set","outputData":[],"required":true},{"callType":"async","desc":"属性获取","identifier":"get","inputData":["pressure1"],"method":"thing.service.property.get","name":"get","outputData":[{"dataType":{"specs":{"max":"2147483647","min":"-2147483648","unit":"Mpa"},"type":"double"},"identifier":"pressure1","name":"pressure1"}],"required":true}]}",
        "tslConfig":"{"profile":{"productKey":"a1KRepm****"},"properties":[{"identifier":"pressure1","operateType":"holdingRegister","originalDataType":{"specs":{"registerCount":1,"reverseRegister":0,"swap16":0},"type":"int16"},"pollingTime":1000,"registerAddress":"0x01","scaling":1,"trigger":1,"writeFunctionCode":16}]}"
    },
    "requestId":"0bc458b5-47f6-472f-bd88-3624696e****",
    "version":"1.0",
    "timestamp":1572248575744,
    "code":0,
    "message":"success"
}

完整示例

./mosquitto_sub -u <your_username> -p <your_password> -p 8883 -t thing/response/testApp/+/+/getTsl -v & 
./mosquitto_pub -u <your_username> -p <your_password> -p 8883 -t testApp/request/thing/a1arJcX****/alpine_light_sensor/getTsl -m "{\"requestId\": \"0bc458b5-47f6-472f-bd88-3624696e****\",\"timeout\":5}"
thing/response/testApp/a1arJcX****/alpine_light_sensor/getTsl {"params":{"productKey":"a1arJcX****","deviceName":"alpine_light_sensor","code":0,"message":"success","tsl":"{\"events\":[{\"desc\":\"属性上报\",\"identifier\":\"post\",\"method\":\"thing.event.property.post\",\"name\":\"post\",\"outputData\":[{\"dataType\":{\"specs\":{\"max\":\"65535\",\"min\":\"0\",\"step\":\"0.01\",\"unit\":\"Lux\",\"unitName\":\"照度\"},\"type\":\"double\"},\"identifier\":\"MeasuredIlluminance\",\"name\":\"光照度检测值\"}],\"required\":true,\"type\":\"info\"}],\"profile\":{\"productKey\":\"a1arJcX****\"},\"properties\":[{\"accessMode\":\"r\",\"dataType\":{\"specs\":{\"max\":\"65535\",\"min\":\"0\",\"step\":\"0.01\",\"unit\":\"Lux\",\"unitName\":\"照度\"},\"type\":\"double\"},\"identifier\":\"MeasuredIlluminance\",\"name\":\"光照度检测值\",\"required\":true}],\"schema\":\"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json\",\"services\":[{\"callType\":\"async\",\"desc\":\"属性设置\",\"identifier\":\"set\",\"inputData\":[],\"method\":\"thing.service.property.set\",\"name\":\"set\",\"outputData\":[],\"required\":true},{\"callType\":\"async\",\"desc\":\"属性获取\",\"identifier\":\"get\",\"inputData\":[\"MeasuredIlluminance\"],\"method\":\"thing.service.property.get\",\"name\":\"get\",\"outputData\":[{\"dataType\":{\"specs\":{\"max\":\"65535\",\"min\":\"0\",\"step\":\"0.01\",\"unit\":\"Lux\",\"unitName\":\"照度\"},\"type\":\"double\"},\"identifier\":\"MeasuredIlluminance\",\"name\":\"光照度检测值\"}],\"required\":true}]}","productKey":"a1arJcX****","deviceName":"alpine_light_sensor","code":0,"message":"success","tslConfig":"{\"profile\":{\"productKey\":\"a1arJcX****\"}}"},"requestId":"0bc458b5-47f6-472f-bd88-3624696e****","version":"1.0","timestamp":1572249171823,"code":0,"message":"success"}
说明 其中:
  • mosquitto_submosquitto_pub是用来订阅和发送MQTT消息的命令行工具,详细信息请参见官方文档
  • <your_username>:替换为云端开启MQTT API中设置的访问边缘Open API的用户名。
  • <your_password>:替换为云端开启MQTT API中设置的访问边缘Open API的密码。