V2.5 Allocate DPS Device¶
分配与激活 DPS 设备。
使用此 API 前,确保已安装 EnOS 2.4 CU2 或更新版本。
请求格式¶
POST https://{apigw-address}/dps-service/v2.5/pvs/device?action=allocate
请求参数(URI)¶
名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|---|
orgId | Query | 必需 | String | 设备所属的组织 ID。如何获取 orgId 信息>> |
请求参数(Body)¶
名称 | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|
sn | 必需 | String | 系统生成的设备 SN 号,环境内唯一。 |
deviceData | 可选 | Map(Key 为 String,Value 为 Integer,String,Enum 或 Date) | 设备主数据。Key 为主数据的标识符,其 Value 必须与主数据的数据类型对应。确保已 创建该主数据,或使用 内置主数据。 |
响应参数¶
名称 | 数据类型 | 描述 |
---|---|---|
data | PvsDevice 结构体 | DPS 设备的信息。更多信息,参见 PvsDevice 结构体。 |
PvsDevice 结构体 ¶
名称 | 数据类型 | 描述 |
---|---|---|
sn | String | 系统生成的设备 SN 号,环境内唯一。 |
groupId | String | 注册组 ID。 |
regionId | String | 设备被分配至的 region ID。 |
orgId | String | 设备被分配至的组织 ID。 |
productKey | String | 设备在 EnOS 管理控制台 中对应的 product key。 |
batchOrder | Integer | 设备创建批次编号。 |
batchTag | StringI18n | 设备创建批次标签。国际化名称表示方法 >> |
deviceData | Map | 设备主数据。 |
desc | String | 设备描述。 |
status | PvsDeviceStatus 结构体 | 设备当前状态。更多信息,参见 PvsDeviceStatus 结构体。 |
reprovisioning | Boolean |
|
allocateErrorMsg | String | 设备上一次的分配失败信息。 |
createBy | String | 创建人的用户 ID。 |
createTime | Long | 设备的创建时间。 |
updateBy | String | 更新人的用户 ID。 |
updateTime | Long | 设备的修改时间。 |
manufacturerOrgId | String | 设备预注册的组织 ID。 |
connectStatus | String | 设备的连接状态,包含 init 、connected 和 failed 。 |
allocateStatus | String | 设备的分配状态,包含 init 和 allocated 。 |
PvsDeviceStatus 结构体 ¶
名称 | 数据类型 | 描述 |
---|---|---|
currentStatus | String | 设备当前状态,包含 init 、allocated 、connected 、finished 和 discarded 。 |
connectedTime | Long | 设备的连接时间。 |
allocatedTime | Long | 设备的分配时间。 |
finishedTime | Long | 设备激活完成的时间。 |
discardedTime | Long | 设备废弃的时间。 |
错误码¶
代码 | 错误信息 | 描述 |
---|---|---|
35400 | OrgId is required | OrgId 为空/不合法。 |
35404 | Group/Device group not found | 注册组/主数据组不存在。 |
35601 | Verify not pass/sn not found | 设备号不存在/不合法。 |
示例¶
请求示例¶
url: https://{apigw-address}/dps-service/v2.5/pvs/device?action=allocate&orgId=yourOrgId
method: POST
requestBody:
{
"sn": "yourSn",
"deviceData": {
"max_capacity": 1.0,
"scale": 1
}
}
返回示例¶
{
"code": 0,
"msg": "OK",
"requestId": "fb8495da-fa7d-4ba6-b105-bcc75517e0d8",
"data": {
"sn": "yourSn",
"groupId": "yourGroupId",
"regionId": "regionId",
"orgId": "yourOrgId",
"productKey": "yourProductKey",
"batchOrder": 723,
"batchTag": {
"defaultValue": "yourDevice",
"i18nValue": {}
},
"deviceData": {
"date": "2023-06-08",
"commDeviceSn": "yourDevice",
"seqNo": 1,
"timezone": "+14:00",
"optModel": "yourDevice",
"deviceName": {
"defaultValue": "yourDevice",
"i18nValue": {
"en_US": "yourDevice",
"zh_CN": "yourDevice",
"ja_JP": "yourDevice",
"es_ES": "yourDevice"
}
},
"deviceSn": "yourDevice",
"orgId": "o15735524440141",
"capacity": 12,
"capacity_rated": 11,
"assetId": "yourAssetId",
"parentDeviceSn": "yourDevice",
"optIndex": [
"yourDevice",
"yourDevice"
],
"optVersion": "yourDevice",
"tokenReplacing": "yourDevice",
"optSN": [
"yourDevice",
"yourDevice"
],
"topoSize": 11,
"modelID": "yourDevice",
"version": "yourDevice",
"enum": "DISTRIBUTED",
"modelName": "yourDevice",
"regionId": "beta",
"regcode": "yourDevice",
"tokenInUse": "yourDevice"
},
"desc": "yourDevice",
"status": {
"currentStatus": "allocated",
"connectedTime": null,
"allocatedTime": 1690779060469,
"finishedTime": null,
"discardedTime": null
},
"reprovisioning": false,
"allocateErrorMsg": null,
"createBy": null,
"createTime": 1690775762727,
"updateBy": null,
"updateTime": 1690775762727,
"manufacturerOrgId": "manufacturerOrgId",
"connectStatus": "init",
"allocateStatus": "allocated"
}
}