Skip to content

Commit 54e7cab

Browse files
committed
sd: get and set characteristic attributes
1 parent 3f79b9e commit 54e7cab

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
@@ -148,3 +148,21 @@ func (c *Characteristic) Write(p []byte) (n int, err error) {
148148

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

0 commit comments

Comments
 (0)