-
Notifications
You must be signed in to change notification settings - Fork 0
/
ble.go
118 lines (95 loc) · 2.44 KB
/
ble.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package shelly
import (
"context"
"github.com/mongoose-os/mos/common/mgrpc"
"github.com/mongoose-os/mos/common/mgrpc/frame"
)
type BLEStatus struct{}
type BLEGetStatusRequest struct{}
func (r *BLEGetStatusRequest) Method() string {
return "BLE.GetStatus"
}
func (r *BLEGetStatusRequest) NewTypedResponse() *BLEStatus {
return &BLEStatus{}
}
func (r *BLEGetStatusRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *BLEGetStatusRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*BLEStatus,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type BLEConfig struct {
// Enable is true if bluetooth is enabled, false otherwise.
Enable *bool `json:"enable,omitempty"`
// RPC is the configuration of the rpc service.
RPC *BLERPCConfig `json:"rpc,omitempty"`
// Observer is the configuration of the BT LE observer.
Observer *BLEObserverConfig `json:"observer,omitempty"`
}
type BLERPCConfig struct {
// Enable is true if rpc service is enabled, false otherwise.
Enable *bool `json:"enable,omitempty"`
}
type BLEObserverConfig struct {
// Enable is true if BT LE observer is enabled, false otherwise. Not applicable
// for battery-operated devices.
Enable *bool `json:"enable,omitempty"`
}
type BLEGetConfigRequest struct{}
func (r *BLEGetConfigRequest) Method() string {
return "BLE.GetConfig"
}
func (r *BLEGetConfigRequest) NewTypedResponse() *BLEConfig {
return &BLEConfig{}
}
func (r *BLEGetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *BLEGetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*BLEConfig,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type BLESetConfigRequest struct {
Config BLERPCConfig `json:"config"`
}
func (r *BLESetConfigRequest) Method() string {
return "BLE.SetConfig"
}
func (r *BLESetConfigRequest) NewTypedResponse() *SetConfigResponse {
return &SetConfigResponse{}
}
func (r *BLESetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *BLESetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*SetConfigResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}