设备端API

通用设备数据上下行接口

设备具备发布权限,用于设备上报数据

  • iot/{projectCode}/{productCode}/{deviceCode}/event

设备具备订阅权限,用于设备获取应用下发的数据

  • iot/{projectCode}/{productCode}/{deviceCode}/control

设备拓扑关系

获取设备的拓扑关系

网关设备

  • 请求Topic:iot/{projectCode}/{productCode}/{deviceCode}/thing/topo/get
{
    "id": "123",
    "version": "1.0",
    "params": "",
    "method": ""
}
  • 响应Topic:iot/{projectCode}/{productCode}/{deviceCode}/thing/topo/get_reply
{
    "id":"123",
    "code":"200",
    "data":[
        {
            " IotDeviceCode ":"deviceName1234",
            " IotModelCode ":"1234556554"
        }
    ]
}

子设备上下线

子设备上线

  • 请求Topic:iot/{projectCode}/{productCode}/{deviceCode}/online

因为子设备通过网关通道与物联网平台通信,以上Topic为网关设备的Topic。Topic中变量 {projectCode}/{productCode}/{deviceCode}需替换为网关设备的对应信息。

{
    "id":"123",
    "params":{
        "IotModelCode":"123",
        "IotDeviceCode":"test"
    }
}
  • 响应Topic:

iot/{projectCode}/{productCode}/{deviceCode}/online_reply

{
    "id":"123",
    "code":"200",
    "message":"success",
    "data":"",
    "ts": 1565838594136
}

子设备下线

  • 请求Topic:iot/{projectCode}/{productCode}/{deviceCode}/offline

因为子设备通过网关通道与物联网平台通信,以上Topic为网关设备的Topic。Topic中变量 {projectCode}/{productCode}/{deviceCode}需替换为网关设备的对应信息。

{
    "id": 123,
    "params": {
        "IotModelCode": "123",
        "IotDeviceCode": "test"
    }
}
  • 响应Topic:iot/{projectCode}/{productCode}/{deviceCode}/offline_reply
{
    "id": "123",
    "code": "200",
    "message": "success",
    "data": "",
    "ts": 1559734298019
}

设备生命周期变更

设备上下线状态

通过该Topic获取设备的上下线状态。

  • 数据流转Topic:iot/{projectCode}/{productCode}/{deviceCode}/mqtt/status
{
   "status" : "online",
   "IotModelCode" : "xxxxxxxxxxx",
   "IotDeviceCode" :"xxxxxxxxxx",
   "time": 1565851637014 
}

TSL物模型模板

设备可以通过上行请求获取设备的TSL模板。

  • TOPIC:iot/{projectCode}/{productCode}/{deviceCode}/thing/dsltemplate/get
{
   "id": "123",
   "version": "1.0",
   "params": "",
   "method": "thing.dsltemplate.get"
   }
  • REPLY TOPIC:iot/{projectCode}/{productCode}/{deviceCode}/thing/dsltemplate/get_reply

只包含属性的物模型示例(暂不支持事件和服务):

{
    "schema": "https://iop.inspur.com/schema.json",
    "profile": {
        "modelCode": "4rdep3ll"
    },
    "link": "",
    "properties": [{
        "identifier": "1",
        "dataType": {
            "specs": {
                "unit": "平方米 / ㎡",
                "min": "1",
                "max": "1",
                "step": "1"
            },
            "type": "float"
        },
        "name": "1",
        "accessMode": "rw",
        "required": false
    }, {
        "identifier": "temperature",
        "dataType": {
            "specs": {
                "unit": "摄氏度 / °C",
                "min": "1",
                "max": "100",
                "step": "0.1"
            },
            "type": "float"
        },
        "name": "温度",
        "accessMode": "rw",
        "required": false
    }]
}