This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# IoT通讯协议 之 GPIO | ||
|
||
本节规定了GPIO的交互内容 | ||
|
||
## 1、查询 | ||
|
||
```json5 | ||
{ | ||
"module": "gpio", | ||
"command": "list", | ||
} | ||
``` | ||
|
||
|
||
查询反馈 | ||
|
||
```json5 | ||
{ | ||
"result": "ok/fail", //结果 | ||
"reason": "密码错误", //错误原因 | ||
"data": [ | ||
{ | ||
"path": "/dev/gpio0", | ||
"name": "开关1", | ||
"type": "io", //io, adc | ||
"value": 1, | ||
"writable": true, | ||
}, | ||
] | ||
} | ||
``` | ||
|
||
|
||
## 2、设置GPIO | ||
|
||
```json5 | ||
{ | ||
"module": "gpio", | ||
"command": "write", | ||
"data": { | ||
"path": "/dev/gpio0", | ||
"value": 1 | ||
} | ||
} | ||
``` | ||
|
||
|
||
## 3、读GPIO | ||
```json5 | ||
{ | ||
"module": "gpio", | ||
"command": "read", | ||
"data": { | ||
"path": "/dev/gpio0", | ||
} | ||
} | ||
``` | ||
|
||
响应 | ||
```json5 | ||
{ | ||
"path": "/dev/gpio0", | ||
"value": 1, | ||
} | ||
``` | ||
|
||
## 4、GPIO数据上报 | ||
|
||
```json5 | ||
{ | ||
"module": "gpio", | ||
"command": "status", | ||
"data": [ | ||
{ | ||
"path": "/dev/gpio0", | ||
"value": 1 | ||
}, | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
package rpc | ||
|
||
type GpioPath struct { | ||
Path string `json:"path"` | ||
} | ||
|
||
type GpioItem struct { | ||
Name string `json:"name"` | ||
Path string `json:"path"` | ||
Type string `json:"type"` | ||
Value int64 `json:"value"` | ||
Writable bool `json:"writable"` | ||
} | ||
|
||
type GpioValue struct { | ||
Path string `json:"path"` | ||
Value int64 `json:"value"` | ||
} | ||
|
||
type GpioSearchRequest GpioPath | ||
|
||
type GpioSearchResponse []GpioItem | ||
|
||
type GpioReadRequest GpioPath | ||
|
||
type GpioReadResponse GpioValue | ||
|
||
type GpioWriteRequest GpioValue | ||
|
||
type GpioWriteResponse struct{} |