forked from tinygo-org/cbgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
descriptor.go
32 lines (26 loc) · 859 Bytes
/
descriptor.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
package cbgo
import "unsafe"
/*
// See cutil.go for C compiler flags.
#import "bt.h"
*/
import "C"
// Descriptor: https://developer.apple.com/documentation/corebluetooth/cbdescriptor
type Descriptor struct {
ptr unsafe.Pointer
}
// UUID: https://developer.apple.com/documentation/corebluetooth/cbattribute/1620638-uuid
func (d Descriptor) UUID() UUID {
cstr := C.cb_dsc_uuid(d.ptr)
return MustParseUUID(C.GoString(cstr))
}
// Characteristic: https://developer.apple.com/documentation/corebluetooth/cbdescriptor/1519035-characteristic
func (d Descriptor) Characteristic() Characteristic {
ptr := C.cb_dsc_characteristic(d.ptr)
return Characteristic{ptr}
}
// Value: https://developer.apple.com/documentation/corebluetooth/cbdescriptor/1518778-value
func (d Descriptor) Value() []byte {
ba := C.cb_dsc_value(d.ptr)
return byteArrToByteSlice(&ba)
}