forked from JuulLabs-OSS/cbgo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mutabledescriptor.go
31 lines (24 loc) · 725 Bytes
/
mutabledescriptor.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
package cbgo
import "unsafe"
/*
// See cutil.go for C compiler flags.
#import "bt.h"
*/
import "C"
// MutableDescriptor: https://developer.apple.com/documentation/corebluetooth/cbmutabledescriptor
type MutableDescriptor struct {
ptr unsafe.Pointer
}
func NewMutableDescriptor(uuid UUID, value []byte) MutableDescriptor {
cuuid := C.CString(uuid.String())
defer C.free(unsafe.Pointer(cuuid))
cvalue := byteSliceToByteArr(value)
defer C.free(unsafe.Pointer(cvalue.data))
return MutableDescriptor{
ptr: unsafe.Pointer(C.cb_mdsc_alloc(cuuid, &cvalue)),
}
}
// Descriptor converts a MutableDescriptor into its underlying Descriptor.
func (d MutableDescriptor) Descriptor() Descriptor {
return Descriptor{d.ptr}
}