-
Notifications
You must be signed in to change notification settings - Fork 140
/
gatts.go
58 lines (50 loc) · 1.89 KB
/
gatts.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
package bluetooth
// Service is a GATT service to be used in AddService.
type Service struct {
handle uint16
UUID
Characteristics []CharacteristicConfig
}
// CharacteristicConfig contains some parameters for the configuration of a
// single characteristic.
//
// The Handle field may be nil. If it is set, it points to a characteristic
// handle that can be used to access the characteristic at a later time.
type CharacteristicConfig struct {
Handle *Characteristic
UUID
Value []byte
Flags CharacteristicPermissions
WriteEvent func(client Connection, offset int, value []byte)
}
// CharacteristicPermissions lists a number of basic permissions/capabilities
// that clients have regarding this characteristic. For example, if you want to
// allow clients to read the value of this characteristic (a common scenario),
// set the Read permission.
type CharacteristicPermissions uint8
// Characteristic permission bitfields.
const (
CharacteristicBroadcastPermission CharacteristicPermissions = 1 << iota
CharacteristicReadPermission
CharacteristicWriteWithoutResponsePermission
CharacteristicWritePermission
CharacteristicNotifyPermission
CharacteristicIndicatePermission
)
// Broadcast returns whether broadcasting of the value is permitted.
func (p CharacteristicPermissions) Broadcast() bool {
return p&CharacteristicBroadcastPermission != 0
}
// Read returns whether reading of the value is permitted.
func (p CharacteristicPermissions) Read() bool {
return p&CharacteristicReadPermission != 0
}
// Write returns whether writing of the value with Write Request is permitted.
func (p CharacteristicPermissions) Write() bool {
return p&CharacteristicWritePermission != 0
}
// WriteWithoutResponse returns whether writing of the value with Write Command
// is permitted.
func (p CharacteristicPermissions) WriteWithoutResponse() bool {
return p&CharacteristicWriteWithoutResponsePermission != 0
}