命令下发会指定某台MQTT设备,并对此设备的指定属性进行异步读写。
功能描述:MQTT设备异步下发命令读取/写入功能点属性信息
POST /api/v1/commands-async/mqtt
Body:
Name | Type | Description | Required |
---|---|---|---|
deviceId | int | 设备ID | Yes |
functionType | string | 命令类型,可选值propertyGet/propertySet | Yes |
identifier | string | 属性名 | Yes |
identifierValue | object | 属性值,functionType值为propertySet时必需 | No |
mode | int | 替换(1,默认)/更新标志(2) | No |
timeout | int | 自定义超时时间 | No |
Body example:
{
"deviceId":10086,
"functionType": "propertySet",
"identifier": "身高",
"identifierValue": "180"
}
当功能属性类型为Bytes时,identifierValue由多个16进制字符和空格组成,空格无实际意义,例如:
"identifierValue": "13 0F 03"
cURL example:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/commands-async/mqtt?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"deviceId":10086,
"functionType": "propertySet",
"identifier": "身高",
"identifierValue": "180"
}'
Response data:
Name | Type | Description |
---|---|---|
commandId | String | 命令ID |
Response
{
"code":0,
"message":"",
"data":{
"commandId": "02e86b96-a484-4e4e-9282-84b804f68fd5"
}
}
功能描述:设备异步下发命令读取/写入功能点属性信息
POST /api/v1/device/command/byname/async
Body:
Name | Type | Description | Required |
---|---|---|---|
productId | int | 产品ID | Yes |
deviceName | string | 设备名称 | Yes |
functionType | string | 命令类型,可选值propertyGet/propertySet | Yes |
identifier | string | 属性名 | Yes |
identifierValue | object | 属性值,functionType值为propertySet时必需 | No |
mode | int | 替换(1,默认)/更新标志(2) | No |
timeout | int | 自定义超时时间 | No |
Body example:
{
"productId":10086,
"deviceName": "test",
"functionType": "propertySet",
"identifier": "身高",
"identifierValue": "180"
}
当功能属性类型为Bytes时,identifierValue由多个16进制字符和空格组成,空格无实际意义,例如:
"identifierValue": "13 0F 03"
cURL example:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/device/command/byname/async?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"productId":10086,
"deviceName": "test",
"functionType": "propertySet",
"identifier": "身高",
"identifierValue": "180"
}'
Response data:
Name | Type | Description |
---|---|---|
commandId | String | 命令ID |
Response
{
"code":0,
"message":"",
"data":{
"commandId": "02e86b96-a484-4e4e-9282-84b804f68fd5"
}
}
功能描述:提供对指定组下的MQTT设备的读,写命令的下发功能,返回命令执行的结果。
POST /api/v1/command/multi/mqtt
Body:
Name | Type | Description | Required |
---|---|---|---|
groupId | int | 组ID | Yes |
functionType | string | 命令类型,可选值propertyGet/propertySet | Yes |
identifier | string | 属性名 | Yes |
identifierValue | object | 属性值,functionType值为propertySet时必需,值类型:String/Integer/Long/Float/Double/Boolean/Date/Bytes | No |
Body example:
{
"groupId": 674,
"functionType": "propertySet",
"identifier": "tempratrue",
"identifierValue": 30
}
当功能属性类型为Bytes时,identifierValue由多个16进制字符和空格组成,空格无实际意义,例如:
"identifierValue": "13 0F 03"
cURL example:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/command/multi/mqtt?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"groupId": 674,
"functionType": "propertySet",
"identifier": "tempratrue",
"identifierValue": 30
}'
Response data:
Name | Type | Description |
---|---|---|
batchId | String | 批次ID |
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": {
"batchId":"xxxx"
}
}
功能描述:添加一条离线的MQTT设备的读,写命令,等到设备上线时,再进行下发,返回命令ID。
POST /api/v1/offlinecmds/mqtt
Body
Name | Type | Description | Required |
---|---|---|---|
type | int | 命令类型, 0:read 1:write | Yes |
deviceId | int | 设备ID | Yes |
propertyName | string | 属性名 | Yes |
value | object | 属性值,type为write时必需,值类型:String/Integer/Long/Float/Double/Boolean/Date/Bytes | No |
retry | int | 重试次数 | Yes |
expiredTime | int | 失效时间戳 | Yes |
Body example:
{
"type":1,
"deviceId": 674,
"propertyName": "tempratrue",
"value": 30,
"expiredTime": 1554176244494,
"retry": 3
}
当功能属性类型为Bytes时,value由多个16进制字符和空格组成,空格无实际意义,例如:
"value": "13 0F 03"
cURL example:
curl --location --request POST '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/offlinecmds/mqtt?accessKeyId={accessKeyId}&signatureNonce=495&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"type":1,
"deviceId": 674,
"propertyName": "tempratrue",
"value": 30,
"expiredTime": 1554176244494,
"retry": 3
}'
Response data:
Name | Type | Description |
---|---|---|
commandId | String | 命令ID |
Response example:
{
"code": 0,
"msg": "",
"data": {
"commandId": "5caaf54ae1382315d9c69c63"
}
}
功能描述:查询MQTT设备离线命令,返回离线命令的详细信息。
GET /api/v1/offlinecmds/mqtt/{commandId}
Path:
Name | Type | Description | Required |
---|---|---|---|
commandId | int | 命令ID | Yes |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/offlinecmds/mqtt/5caaf54ae1382315d9c69c63?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response data:
Name | Type | Description |
---|---|---|
id | String | 命令ID |
type | int | 命令类型 |
deviceId | int | 设备ID |
propertyName | String | 属性名 |
value | object | 属性值 |
retry | int | 重试次数 |
executeCount | int | 执行次数 |
expiredTime | long | 命令过期时间 |
createTime | long | 命令创建时间 |
sendStatus | int | 命令状态 0: 等待执行; 1: 命令被取消; 2:命令过期; 3:命令成功执行; 4:命令执行失败; |
Response example:
{
"success": true,
"code": 0,
"msg": "",
"data": {
"createTime": 1555574172141,
"deviceId": 674,
"executeCount": 0,
"expiredTime": 1554176244494,
"id": "5cb82d9c60db240001b45eb6",
"propertyName": "tempratrue",
"retry": 3,
"sendStatus": 0,
"type": 1,
"value": 30
}
}
功能描述:分页查询MQTT设备离线命令,返回具体分页信息和离线命令信息列表。
GET /api/v1/offlinecmds/mqtt
Query
Name | Type | Description | Required |
---|---|---|---|
deviceId | int | 设备ID | Yes |
start | int | 起始时间戳(毫秒级时间戳) | No |
end | int | 结束时间戳(毫秒级时间戳) | No |
pageSize | int | 分页大小 | Yes |
currentPage | int | 页码 | Yes |
cURL example:
curl --location --request GET '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/offlinecmds/mqtt?accessKeyId={accessKeyId}&signatureNonce=166&signature={signature}&deviceId=10000801&pageSize=10¤tPage=1' \
--header 'platform: 1' \
--header 'projectId: {projectId}'
Response data:
Name | Type | Description |
---|---|---|
currentPage | int | 当前页码 |
pageSize | int | 每页条数 |
totalCount | long | 总条数 |
totalPage | int | 总页数 |
content | struct[] | 当前页内容 |
Response data content的子对象结构体:
Name | Type | Description |
---|---|---|
id | String | 命令ID |
type | int | 命令类型 |
deviceId | int | 设备ID |
propertyName | String | 属性名 |
value | object | 属性值 |
retry | int | 重试次数 |
executeCount | int | 执行次数 |
expiredTime | long | 命令过期时间 |
createTime | long | 命令创建时间 |
sendStatus | int | 命令状态 0: 等待执行; 1: 命令被取消; 2:命令过期; 3:命令成功执行; 4:命令执行失败; |
Response
{
"success": true,
"code": 0,
"msg": "",
"data": {
"content": [
{
"createTime": 0,
"deviceId": ,
"executeCount": 0,
"expiredTime": 155469354000,
"id": "5caafe52e1382347fb7b02ad",
"propertyName": "",
"retry": 1,
"sendStatus": 0,
"type": 0,
"value": null
}
],
"currentPage": 1,
"pageSize": 2,
"totalCount": 1,
"totalPage": 1
}
}
功能描述:更新指定的离线命令。
PUT /api/v1/offlinecmds/mqtt
Body:
Name | Type | Description | Required |
---|---|---|---|
commandId | string | 命令ID | Yes |
value | object | 属性值,type为write时必需,值类型:String/Integer/Long/Float/Double/Boolean/Date/Bytes | No |
retry | int | 重试次数,[3, 10]之间 | No |
expiredTime | int | 失效时间戳 | No |
Body example:
{
"commandId": "5cac3699e13823f48566d52a",
"value": 30,
"expiredTime": 1554176244494,
"retry": 3
}
当功能属性类型为Bytes时,value由多个16进制字符和空格组成,空格无实际意义,例如:
"value": "13 0F 03"
cURL example:
curl --location --request PATCH '{URI-scheme}://{Endpoint}{path-prefix}/api/v1/offlinecmds/mqtt?accessKeyId={accessKeyId}&signatureNonce=719&signature={signature}' \
--header 'platform: 1' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
"commandId": "5cac3699e13823f48566d52a",
"value": 30,
"expiredTime": 1554176244494,
"retry": 3
}'
Response example:
{
"code":0,
"message":null,
"success":true,
"data":"true"
}