Skip to content

Commit ca3c1e0

Browse files
committed
sd: get and set characteristic attributes
1 parent bd75a42 commit ca3c1e0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gatts_sd.go

+18
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,21 @@ func (c *Characteristic) Write(p []byte) (n int, err error) {
146146

147147
return len(p), nil
148148
}
149+
150+
// GetAttributes retrieves persistent system attribute information
151+
// Use together with SetAttributes to save and restore characteristic state
152+
func (c *Characteristic) GetAttributes(p []byte) (n int, err error) {
153+
connHandle := currentConnection.Get()
154+
p_len := uint16(len(p))
155+
errCode := C.sd_ble_gatts_sys_attr_get(connHandle, &p[0], &p_len, 0)
156+
return int(p_len), makeError(errCode)
157+
}
158+
159+
// SetAttributes updates persistent system attribute information
160+
// Use together with GetAttributes to save and restore characteristic state
161+
func (c *Characteristic) SetAttributes(p []byte) (err error) {
162+
connHandle := currentConnection.Get()
163+
p_len := uint16(len(p))
164+
errCode := C.sd_ble_gatts_sys_attr_set(connHandle, &p[0], p_len, 0)
165+
return makeError(errCode)
166+
}

0 commit comments

Comments
 (0)