From ea100d1fcef5b8b2fb329520497e1c708ea21538 Mon Sep 17 00:00:00 2001 From: zhengjw22 Date: Wed, 5 Jun 2024 17:16:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/src/content/docs/guides/restapi.mdx | 100 +++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/pages/src/content/docs/guides/restapi.mdx b/pages/src/content/docs/guides/restapi.mdx index de73c16..ef788a8 100644 --- a/pages/src/content/docs/guides/restapi.mdx +++ b/pages/src/content/docs/guides/restapi.mdx @@ -203,7 +203,7 @@ driver-box 提供了一套常用的 REST API,方便开发者结合自身需求 **响应参数** | 字段名 | 字段类型 | 字段描述 | |-------|--------|-----------------| -| value | Device[] | 设备影子列表 | +| data | Device[] | 设备影子列表 | | 字段名 | 字段类型 | 字段描述 | @@ -277,5 +277,101 @@ driver-box 提供了一套常用的 REST API,方便开发者结合自身需求 ### 查询某个设备数据 +**请求方式:** GET + +**请求路径:** /api/v1/shadow/device + +**接口描述:** +获取当前网关中指定设备 ID 的影子数据 + +**请求参数** + +| 字段名 | 字段类型 | 是否必填 | 字段描述 | +| ------ | -------- | -------- | -------- | +|id|string|是|设备 ID| + +**响应参数** +| 字段名 | 字段类型 | 字段描述 | +|-------|--------|-----------------| +| data | Device | 设备影子 | + + +**示例** + + + + ```shell + curl http://127.0.0.1:8081/api/v1/shadow/device?id=swtich-1 + ``` + + + ```json + { + "success": true, + "errorCode": 200, + "errorMsg": "", + "data": { + "id": "swtich-1", + "points": [ + { + "name": "onOff", + "value": 1, + "updated_at": "2024-06-05 16:27:41", + "write_time": "0001-01-01 00:00:00" + } + ], + "online": false, + "ttl": "5m0s", + "disconnect_times": 0, + "updated_at": "2024-06-05 16:32:41" + } + } + ``` + + -### 查询某个设备点位数据 \ No newline at end of file +### 查询某个设备点位数据 +**请求方式:** GET + +**请求路径:** /api/v1/shadow/devicePoint + +**接口描述:** +获取当前网关中指定设备的某个点位影子数据 + +**请求参数** + +| 字段名 | 字段类型 | 是否必填 | 字段描述 | +| ------ | -------- | -------- | -------- | +|id|string|是|设备 ID| +|point|string|是|点位名| + +**响应参数** +| 字段名 | 字段类型 | 字段描述 | +|-------|--------|-----------------| +| data | DevicePoint | 设备影子 | + + +**示例** + + + + ```shell + curl http://127.0.0.1:8081/api/v1/shadow/devicePoint?id=swtich-1&point=onOff + ``` + + + ```json + { + "success": true, + "errorCode": 200, + "errorMsg": "", + "data": { + "name": "onOff", + "value": 1, + "updated_at": "2024-06-05 16:27:41", + "write_time": "0001-01-01 00:00:00" + } + } + ``` + + \ No newline at end of file