Skip to content

Commit

Permalink
sd: get and set characteristic attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ysoldak committed Apr 16, 2023
1 parent e79ea1e commit d28e8fe
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gatts_sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,21 @@ func (c *Characteristic) Write(p []byte) (n int, err error) {

return len(p), nil
}

// GetAttributes retrieves persistent system attribute information
// Use together with SetAttributes to save and restore characteristic state
func (c *Characteristic) GetAttributes(p []byte) (n int, err error) {
connHandle := currentConnection.Get()
p_len := uint16(len(p))
errCode := C.sd_ble_gatts_sys_attr_get(connHandle, &p[0], &p_len, 0)
return int(p_len), makeError(errCode)
}

// SetAttributes updates persistent system attribute information
// Use together with GetAttributes to save and restore characteristic state
func (c *Characteristic) SetAttributes(p []byte) (err error) {
connHandle := currentConnection.Get()
p_len := uint16(len(p))
errCode := C.sd_ble_gatts_sys_attr_set(connHandle, &p[0], p_len, 0)
return makeError(errCode)
}

0 comments on commit d28e8fe

Please sign in to comment.