查询设备的服务能力
接口说明
应用服务器可调用此接口查询设备的服务能力,控制设备时需要根据设备支持的能力,对设备进行相应的控制。
URI
| 请求方法 | GET |
|---|---|
| URI | /api/v3.0/devices/{deviceId}/capabilities |
| 传输协议 | HTTPS |
请求参数
| 名称 | 必选/可选 | 类型 | 位置 | 说明 |
|---|---|---|---|---|
| app_key | 必选 | String | Header | 已鉴权应用的appId。 |
| Authorization | 必选 | String | Header | 请求的认证信息,值为“Bearer ******”,其中******为Auth鉴权接口返回的accessToken。 |
| deviceId | 必选 | String | Path | 设备ID。 |
| ownerAppId | 可选 | String | Query | 资源所属应用的appId,访问其他应用所持有的资源时需要填写。 |
响应参数
| 名称 | 类型 | 说明 |
|---|---|---|
| deviceCapabilities | List<DeviceCapabilityDTO> | 设备服务能力列表。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| deviceId | String(256) | 设备ID。 |
| serviceCapabilities | List<ServiceCapabilityDTO> | 服务能力列表。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| commands | List<ServiceCommand> | 设备支持命令列表。 |
| description | String(10240) | 描述。 |
| option | String | 服务选项,描述服务的重要性,取值:Master、Mandatory、Optional。 |
| properties | List<ServiceProperty> | 设备属性列表。 |
| serviceId | String(256) | 服务标识。 |
| serviceType | String(256) | 服务类型。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| commandName | String(256) | 命令名称。 |
| paras | List<ServiceCommandPara> | 属性列表。 |
| responses | List<ServiceCommandResponse> | 命令响应。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| dataType | String(256) | 数据类型。 |
| enumList | List<String> | 枚举类型列表。 |
| max | String | 最大值。 |
| maxLength | Integer | 最大长度。 |
| min | String | 最小值。 |
| paraName | String(256) | 参数名称。 |
| required | Boolean | 是否必选。 |
| step | Double | 每次属性值变化的步长。 |
| unit | String(256) | 单位(符号)。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| paras | List<ServiceCommandPara> | 响应参数。 |
| responseName | String(256) | 响应名称。 |
| 名称 | 类型 | 说明 |
|---|---|---|
| dataType | String(256) | 数据类型。 |
| enumList | List<String> | 枚举类型列表。 |
| max | String | 属性最大值。 |
| maxLength | Integer(<=2147483647) | 最大长度。 |
| method | String(256) | 访问方法。 R:可读 W:可写 E:可观察 |
| min | String | 属性最小值。 |
| propertyName | String(256) | 属性名称。 |
| required | Boolean | 是否必选。 |
| step | Double | 每次属性值变化的步长。 |
| unit | String(256) | 单位。 |
请求示例
GET https://{host}:{port}/api/v3.0/devices/{deviceId}/capabilities?ownerAppId={ownerAppId}
Content-Type: application/json
app_key: ********
Authorization: ********
响应示例
Status Code: 200 OK
Content-Type: application/json
{
"deviceCapabilities" : [ {
"serviceCapabilities" : [ {
"serviceType" : "string",
"description" : "string",
"serviceId" : "string",
"commands" : [ {
"commandName" : "string",
"responses" : [ {
"responseName" : "string",
"paras" : [ {
"enumList" : [ "string" ],
"unit" : "string",
"min" : "string",
"max" : "string",
"dataType" : "string",
"step" : 0.0,
"maxLength" : 0,
"required" : true,
"paraName" : "string"
} ]
} ],
"paras" : [ {
"enumList" : [ "string" ],
"unit" : "string",
"min" : "string",
"max" : "string",
"dataType" : "string",
"step" : 0.0,
"maxLength" : 0,
"required" : true,
"paraName" : "string"
} ]
} ],
"properties" : [ {
"enumList" : [ "string" ],
"unit" : "string",
"min" : "string",
"method" : "string",
"max" : "string",
"propertyName" : "string",
"dataType" : "string",
"step" : 0.0,
"maxLength" : 0,
"required" : true
} ],
"option" : "string"
} ],
"deviceId" : "string"
} ]
} 错误码
| HTTP状态码 | HTTP状态码说明 | 错误码 | 错误码描述 |
|---|---|---|---|
| 200 | OK | - | - |
| 400 | Bad Request | 100409 | The deviceId is invalid. 处理建议:检查并填写正确的deviceId。 |
| 401 | Unauthorized | 100025 | AppId for auth not exist. 处理建议:检查并填写正确的appId。 |
| 403 | Forbidden | 100203 | The application does not exist. 处理建议:检查并填写正确的appId。 |
| 100217 | The application hasn't been authorized. 处理建议:应用没有被授权,检查该应用是否有权限 | ||
| 404 | Not Found | 100403 | The device is not existed. 处理建议:检查并填写正确的deviceId。 |
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.