硬件管理
硬件管理接口用于管理硬件设备。所有接口都需要开发者权限。
获取硬件列表
获取硬件列表。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| page | integer | 否 | 页码,默认1 |
| size | integer | 否 | 每页数量 |
GET /dev/hardware/list?page=1&size=10
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
获取硬件详情
获取指定硬件的详细信息。请求参数
GET /dev/hardware/hw_123
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
创建硬件
创建新的硬件。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| name | string | 是 | 硬件名称 |
| description | string | 否 | 硬件描述 |
| config | object | 否 | 硬件配置 |
POST /dev/hardware
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"name": "新硬件",
"description": "这是一个新硬件",
"config": {
"type": "sensor",
"model": "v1.0"
}
}
更新硬件
更新指定硬件的信息。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| id | string | 是 | 硬件ID |
| name | string | 否 | 硬件名称 |
| description | string | 否 | 硬件描述 |
| config | object | 否 | 硬件配置 |
PUT /dev/hardware/hw_124
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"name": "更新后的硬件",
"description": "这是更新后的硬件描述"
}
删除硬件
删除指定的硬件。请求参数
DELETE /dev/hardware/hw_124
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
获取硬件日志
获取指定硬件的日志记录。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| id | string | 是 | 硬件ID |
| page | integer | 否 | 页码,默认1 |
| size | integer | 否 | 每页数量 |
| start_time | string | 否 | 开始时间 |
| end_time | string | 否 | 结束时间 |
GET /dev/hardware/hw_123/logs?page=1&size=10
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
推送硬件日志
向指定硬件推送日志。请求参数
| 参数名 | 类型 | 必选 | 说明 |
|---|
| id | string | 是 | 硬件ID |
| type | string | 是 | 日志类型 |
| content | string | 是 | 日志内容 |
POST /dev/hardware/hw_123/logs
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
{
"type": "info",
"content": "设备状态更新"
}
错误码说明
错误码说明
| 错误码 | 说明 |
|---|
| 400 | 请求参数错误 |
| 401 | 未授权或令牌无效 |
| 403 | 权限不足(需要开发者权限) |
| 404 | 硬件不存在 |
| 422 | 请求参数验证失败 |
| 500 | 服务器错误 |