Skip to main content

硬件管理

硬件管理接口用于管理硬件设备。所有接口都需要开发者权限。

获取硬件列表

/dev/hardware/list
获取硬件列表。

请求参数

参数名类型必选说明
pageinteger页码,默认1
sizeinteger每页数量
GET /dev/hardware/list?page=1&size=10
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

获取硬件详情

/dev/hardware/:id
获取指定硬件的详细信息。

请求参数

参数名类型必选说明
idstring硬件ID
GET /dev/hardware/hw_123
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

创建硬件

/dev/hardware
创建新的硬件。

请求参数

参数名类型必选说明
namestring硬件名称
descriptionstring硬件描述
configobject硬件配置
POST /dev/hardware
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
  "name": "新硬件",
  "description": "这是一个新硬件",
  "config": {
    "type": "sensor",
    "model": "v1.0"
  }
}

更新硬件

/dev/hardware/:id
更新指定硬件的信息。

请求参数

参数名类型必选说明
idstring硬件ID
namestring硬件名称
descriptionstring硬件描述
configobject硬件配置
PUT /dev/hardware/hw_124
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
  "name": "更新后的硬件",
  "description": "这是更新后的硬件描述"
}

删除硬件

/dev/hardware/:id
删除指定的硬件。

请求参数

参数名类型必选说明
idstring硬件ID
DELETE /dev/hardware/hw_124
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

获取硬件日志

/dev/hardware/:id/logs
获取指定硬件的日志记录。

请求参数

参数名类型必选说明
idstring硬件ID
pageinteger页码,默认1
sizeinteger每页数量
start_timestring开始时间
end_timestring结束时间
GET /dev/hardware/hw_123/logs?page=1&size=10
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

推送硬件日志

/dev/hardware/:id/logs
向指定硬件推送日志。

请求参数

参数名类型必选说明
idstring硬件ID
typestring日志类型
contentstring日志内容
POST /dev/hardware/hw_123/logs
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
  "type": "info",
  "content": "设备状态更新"
}

错误码说明

错误码说明

错误码说明
400请求参数错误
401未授权或令牌无效
403权限不足(需要开发者权限)
404硬件不存在
422请求参数验证失败
500服务器错误