This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Commit 8ef36e5 1 parent 21f21a3 commit 8ef36e5 Copy full SHA for 8ef36e5
File tree 2 files changed +109
-0
lines changed
2 files changed +109
-0
lines changed Original file line number Diff line number Diff line change
1
+ # IoT通讯协议 之 GPIO
2
+
3
+ 本节规定了GPIO的交互内容
4
+
5
+ ## 1、查询
6
+
7
+ ``` json5
8
+ {
9
+ " module" : " gpio" ,
10
+ " command" : " list" ,
11
+ }
12
+ ```
13
+
14
+
15
+ 查询反馈
16
+
17
+ ``` json5
18
+ {
19
+ " result" : " ok/fail" , // 结果
20
+ " reason" : " 密码错误" , // 错误原因
21
+ " data" : [
22
+ {
23
+ " path" : " /dev/gpio0" ,
24
+ " name" : " 开关1" ,
25
+ " type" : " io" , // io, adc
26
+ " value" : 1 ,
27
+ " writable" : true ,
28
+ },
29
+ ]
30
+ }
31
+ ```
32
+
33
+
34
+ ## 2、设置GPIO
35
+
36
+ ``` json5
37
+ {
38
+ " module" : " gpio" ,
39
+ " command" : " write" ,
40
+ " data" : {
41
+ " path" : " /dev/gpio0" ,
42
+ " value" : 1
43
+ }
44
+ }
45
+ ```
46
+
47
+
48
+ ## 3、读GPIO
49
+ ``` json5
50
+ {
51
+ " module" : " gpio" ,
52
+ " command" : " read" ,
53
+ " data" : {
54
+ " path" : " /dev/gpio0" ,
55
+ }
56
+ }
57
+ ```
58
+
59
+ 响应
60
+ ``` json5
61
+ {
62
+ " path" : " /dev/gpio0" ,
63
+ " value" : 1 ,
64
+ }
65
+ ```
66
+
67
+ ## 4、GPIO数据上报
68
+
69
+ ``` json5
70
+ {
71
+ " module" : " gpio" ,
72
+ " command" : " status" ,
73
+ " data" : [
74
+ {
75
+ " path" : " /dev/gpio0" ,
76
+ " value" : 1
77
+ },
78
+ ]
79
+ }
80
+ ```
Original file line number Diff line number Diff line change 1
1
package rpc
2
+
3
+ type GpioPath struct {
4
+ Path string `json:"path"`
5
+ }
6
+
7
+ type GpioItem struct {
8
+ Name string `json:"name"`
9
+ Path string `json:"path"`
10
+ Type string `json:"type"`
11
+ Value int64 `json:"value"`
12
+ Writable bool `json:"writable"`
13
+ }
14
+
15
+ type GpioValue struct {
16
+ Path string `json:"path"`
17
+ Value int64 `json:"value"`
18
+ }
19
+
20
+ type GpioSearchRequest GpioPath
21
+
22
+ type GpioSearchResponse []GpioItem
23
+
24
+ type GpioReadRequest GpioPath
25
+
26
+ type GpioReadResponse GpioValue
27
+
28
+ type GpioWriteRequest GpioValue
29
+
30
+ type GpioWriteResponse struct {}
You can’t perform that action at this time.
0 commit comments