nRF51 SDK: Generic Attribute Profile (GATT) Server

| nRF51 SDK

- Home
- Related Pages
- API Reference
- Data Structures

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Enumerations | Functions
Generic Attribute Profile (GATT) Server
S310 (ANT and BLE peripheral)

Definitions and prototypes for the GATTS interface. More...

## Modules

| Defines

## Data Structures

struct | ble_gatts_attr_md_t
| Attribute metadata. More...
struct | ble_gatts_attr_t
| GATT Attribute. More...
struct | ble_gatts_attr_context_t
| GATT Attribute Context. More...
struct | ble_gatts_char_pf_t
| GATT Characteristic Presentation Format. More...
struct | ble_gatts_char_md_t
| GATT Characteristic metadata. More...
struct | ble_gatts_char_handles_t
| GATT Characteristic Definition Handles. More...
struct | ble_gatts_hvx_params_t
| GATT HVx parameters. More...
struct | ble_gatts_read_authorize_params_t
| GATT Read Authorization parameters. More...
struct | ble_gatts_write_authorize_params_t
| GATT Write Authorisation parameters. More...
struct | ble_gatts_rw_authorize_reply_params_t
| GATT Read or Write Authorize Reply parameters. More...
struct | ble_gatts_evt_write_t
| Event structure for BLE_GATTS_EVT_WRITE. More...
struct | ble_gatts_evt_read_t
| Event structure for authorize read request. More...
struct | ble_gatts_evt_rw_authorize_request_t
| Event structure for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. More...
struct | ble_gatts_evt_sys_attr_missing_t
| Event structure for BLE_GATTS_EVT_SYS_ATTR_MISSING. More...
struct | ble_gatts_evt_hvc_t
| Event structure for BLE_GATTS_EVT_HVC. More...
struct | ble_gatts_evt_timeout_t
| Event structure for BLE_GATTS_EVT_TIMEOUT. More...
struct | ble_gatts_evt_t
| GATT Server event callback event structure. More...

## Enumerations

enum

BLE_GATTS_SVCS {
SD_BLE_GATTS_SERVICE_ADD = 0xA0, SD_BLE_GATTS_INCLUDE_ADD, SD_BLE_GATTS_CHARACTERISTIC_ADD, SD_BLE_GATTS_DESCRIPTOR_ADD,
SD_BLE_GATTS_VALUE_SET, SD_BLE_GATTS_VALUE_GET, SD_BLE_GATTS_HVX, SD_BLE_GATTS_SERVICE_CHANGED,
SD_BLE_GATTS_RW_AUTHORIZE_REPLY, SD_BLE_GATTS_SYS_ATTR_SET, SD_BLE_GATTS_SYS_ATTR_GET, SD_BLE_GATTS_SERVICE_ADD = 0xA0,
SD_BLE_GATTS_INCLUDE_ADD, SD_BLE_GATTS_CHARACTERISTIC_ADD, SD_BLE_GATTS_DESCRIPTOR_ADD, SD_BLE_GATTS_VALUE_SET,
SD_BLE_GATTS_VALUE_GET, SD_BLE_GATTS_HVX, SD_BLE_GATTS_SERVICE_CHANGED, SD_BLE_GATTS_RW_AUTHORIZE_REPLY,
SD_BLE_GATTS_SYS_ATTR_SET, SD_BLE_GATTS_SYS_ATTR_GET, SD_BLE_GATTS_SERVICE_ADD = 0xA0, SD_BLE_GATTS_INCLUDE_ADD,
SD_BLE_GATTS_CHARACTERISTIC_ADD, SD_BLE_GATTS_DESCRIPTOR_ADD, SD_BLE_GATTS_VALUE_SET, SD_BLE_GATTS_VALUE_GET,
SD_BLE_GATTS_HVX, SD_BLE_GATTS_SERVICE_CHANGED, SD_BLE_GATTS_RW_AUTHORIZE_REPLY, SD_BLE_GATTS_SYS_ATTR_SET,
SD_BLE_GATTS_SYS_ATTR_GET
}

| GATTS API SVC numbers. More...

enum

BLE_GATTS_EVTS {
BLE_GATTS_EVT_WRITE = 0x50, BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, BLE_GATTS_EVT_SYS_ATTR_MISSING, BLE_GATTS_EVT_HVC,
BLE_GATTS_EVT_SC_CONFIRM, BLE_GATTS_EVT_TIMEOUT, BLE_GATTS_EVT_WRITE = 0x50, BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST,
BLE_GATTS_EVT_SYS_ATTR_MISSING, BLE_GATTS_EVT_HVC, BLE_GATTS_EVT_SC_CONFIRM, BLE_GATTS_EVT_TIMEOUT,
BLE_GATTS_EVT_WRITE = 0x50, BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, BLE_GATTS_EVT_SYS_ATTR_MISSING, BLE_GATTS_EVT_HVC,
BLE_GATTS_EVT_SC_CONFIRM, BLE_GATTS_EVT_TIMEOUT
}

| GATT Server Event IDs. More...

## Functions

uint32_t | sd_ble_gatts_service_add (uint8_t type, ble_uuid_t const *const p_uuid, uint16_t *const p_handle)
| Add a service declaration to the local server ATT table. More...
uint32_t | sd_ble_gatts_include_add (uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *const p_include_handle)
| Add an include declaration to the local server ATT table. More...
uint32_t | sd_ble_gatts_characteristic_add (uint16_t service_handle, ble_gatts_char_md_t const *const p_char_md, ble_gatts_attr_t const *const p_attr_char_value, ble_gatts_char_handles_t *const p_handles)
| Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the local server ATT table. More...
uint32_t | sd_ble_gatts_descriptor_add (uint16_t char_handle, ble_gatts_attr_t const *const p_attr, uint16_t *const p_handle)
| Add a descriptor to the local server ATT table. More...
uint32_t | sd_ble_gatts_value_set (uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t const *const p_value)
| Set the value of a given attribute. More...
uint32_t | sd_ble_gatts_value_get (uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t *const p_data)
| Get the value of a given attribute. More...
uint32_t | sd_ble_gatts_hvx (uint16_t conn_handle, ble_gatts_hvx_params_t const *const p_hvx_params)
| Notify or Indicate an attribute value. More...
uint32_t | sd_ble_gatts_service_changed (uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)
| Indicate the Service Changed attribute value. More...
uint32_t | sd_ble_gatts_rw_authorize_reply (uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *const p_rw_authorize_reply_params)
| Respond to a Read/Write authorization request. More...
uint32_t | sd_ble_gatts_sys_attr_set (uint16_t conn_handle, uint8_t const *const p_sys_attr_data, uint16_t len)
| Update persistent system attribute information. More...
uint32_t | sd_ble_gatts_sys_attr_get (uint16_t conn_handle, uint8_t *const p_sys_attr_data, uint16_t *const p_len)
| Retrieve persistent system attribute information from the stack. More...

## Detailed Description

Definitions and prototypes for the GATTS interface.

## Enumeration Type Documentation

enum BLE_GATTS_EVTS

GATT Server Event IDs.

Enumerator
BLE_GATTS_EVT_WRITE | Write operation performed.
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST | Read/Write Authorization request.
BLE_GATTS_EVT_SYS_ATTR_MISSING | A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set().
BLE_GATTS_EVT_HVC | Handle Value Confirmation.
BLE_GATTS_EVT_SC_CONFIRM | Service Changed Confirmation.
BLE_GATTS_EVT_TIMEOUT | Timeout.
BLE_GATTS_EVT_WRITE | GATTS BLE Event base. Write operation performed.
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST | Read/Write Authorization request.
BLE_GATTS_EVT_SYS_ATTR_MISSING | A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set().
BLE_GATTS_EVT_HVC | Handle Value Confirmation.
BLE_GATTS_EVT_SC_CONFIRM | Service Changed Confirmation.
BLE_GATTS_EVT_TIMEOUT | Timeout.
BLE_GATTS_EVT_WRITE | Write operation performed.
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST | Read/Write Authorization request.
BLE_GATTS_EVT_SYS_ATTR_MISSING | A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set().
BLE_GATTS_EVT_HVC | Handle Value Confirmation.
BLE_GATTS_EVT_SC_CONFIRM | Service Changed Confirmation.
BLE_GATTS_EVT_TIMEOUT | Timeout.

enum BLE_GATTS_SVCS

GATTS API SVC numbers.

Enumerator
SD_BLE_GATTS_SERVICE_ADD | Add a service.
SD_BLE_GATTS_INCLUDE_ADD | Add an included service.
SD_BLE_GATTS_CHARACTERISTIC_ADD | Add a characteristic.
SD_BLE_GATTS_DESCRIPTOR_ADD | Add a generic attribute.
SD_BLE_GATTS_VALUE_SET | Set an attribute value.
SD_BLE_GATTS_VALUE_GET | Get an attribute value.
SD_BLE_GATTS_HVX | Handle Value Notification or Indication.
SD_BLE_GATTS_SERVICE_CHANGED | Perform a Service Changed Indication to one or more peers.
SD_BLE_GATTS_RW_AUTHORIZE_REPLY | Reply to an authorization request for a read or write operation on one or more attributes.
SD_BLE_GATTS_SYS_ATTR_SET | Set the persistent system attributes for a connection.
SD_BLE_GATTS_SYS_ATTR_GET | Get updated persistent system attributes after terminating a connection.
SD_BLE_GATTS_SERVICE_ADD | GATTS BLE SVC base. Add a service.
SD_BLE_GATTS_INCLUDE_ADD | Add an included service.
SD_BLE_GATTS_CHARACTERISTIC_ADD | Add a characteristic.
SD_BLE_GATTS_DESCRIPTOR_ADD | Add a generic attribute.
SD_BLE_GATTS_VALUE_SET | Set an attribute value.
SD_BLE_GATTS_VALUE_GET | Get an attribute value.
SD_BLE_GATTS_HVX | Handle Value Notification or Indication.
SD_BLE_GATTS_SERVICE_CHANGED | Perform a Service Changed Indication to one or more peers.
SD_BLE_GATTS_RW_AUTHORIZE_REPLY | Reply to an authorization request for a read or write operation on one or more attributes.
SD_BLE_GATTS_SYS_ATTR_SET | Set the persistent system attributes for a connection.
SD_BLE_GATTS_SYS_ATTR_GET | Get updated persistent system attributes after terminating a connection.
SD_BLE_GATTS_SERVICE_ADD | Add a service.
SD_BLE_GATTS_INCLUDE_ADD | Add an included service.
SD_BLE_GATTS_CHARACTERISTIC_ADD | Add a characteristic.
SD_BLE_GATTS_DESCRIPTOR_ADD | Add a generic attribute.
SD_BLE_GATTS_VALUE_SET | Set an attribute value.
SD_BLE_GATTS_VALUE_GET | Get an attribute value.
SD_BLE_GATTS_HVX | Handle Value Notification or Indication.
SD_BLE_GATTS_SERVICE_CHANGED | Perform a Service Changed Indication to one or more peers.
SD_BLE_GATTS_RW_AUTHORIZE_REPLY | Reply to an authorization request for a read or write operation on one or more attributes.
SD_BLE_GATTS_SYS_ATTR_SET | Set the persistent system attributes for a connection.
SD_BLE_GATTS_SYS_ATTR_GET | Get updated persistent system attributes after terminating a connection.

## Function Documentation

uint32_t sd_ble_gatts_characteristic_add | ( | uint16_t | service_handle,
|  | ble_gatts_char_md_t const *const | p_char_md,
|  | ble_gatts_attr_t const *const | p_attr_char_value,
|  | ble_gatts_char_handles_t *const | p_handles
| ) |  |

Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the local server ATT table.

Note
  It is currently only possible to add a characteristic to the last added service (i.e. only sequential addition is supported at this time).
  Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits, readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values.
  If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.

Parameters

  [in] | service_handle | Handle of the service where the characteristic is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
  [in] | p_char_md | Characteristic metadata.
  [in] | p_attr_char_value | Pointer to the attribute structure corresponding to the characteristic value.
  [out] | p_handles | Pointer to the structure where the assigned handles will be stored.

Returns
  NRF_SUCCESS Successfully added a characteristic.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
  NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
  NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
  NRF_ERROR_NO_MEM Not enough memory to complete operation.
  NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by BLE_GATTS_ATTR_LENS_MAX.

uint32_t sd_ble_gatts_descriptor_add | ( | uint16_t | char_handle,
|  | ble_gatts_attr_t const *const | p_attr,
|  | uint16_t *const | p_handle
| ) |  |

Add a descriptor to the local server ATT table.

Note
  It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential addition is supported at this time).

Parameters

  [in] | char_handle | Handle of the characteristic where the descriptor is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
  [in] | p_attr | Pointer to the attribute structure.
  [out] | p_handle | Pointer to a 16-bit word where the assigned handle will be stored.

Returns
  NRF_SUCCESS Successfully added a descriptor.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
  NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
  NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
  NRF_ERROR_NO_MEM Not enough memory to complete operation.
  NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by BLE_GATTS_ATTR_LENS_MAX.

uint32_t sd_ble_gatts_hvx | ( | uint16_t | conn_handle,
|  | ble_gatts_hvx_params_t const *const | p_hvx_params
| ) |  |

Notify or Indicate an attribute value.

This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that the application can atomically perform a value update and a server initiated transaction with a single API call. If the application chooses to indicate an attribute value, a BLE_GATTS_EVT_HVC will be sent up as soon as the confirmation arrives from the peer.

Note
  The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. When receiveing the error codes NRF_ERROR_INVALID_STATE, NRF_ERROR_BUSY, BLE_ERROR_GATTS_SYS_ATTR_MISSING and BLE_ERROR_NO_TX_BUFFERS the ATT table has been updated. The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
  It is important to note that a notification will consume an application buffer, and will therefore generate a BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the standard server internal buffer and thus will only generate a BLE_GATTS_EVT_HVC event as soon as the confirmation has been received from the peer. Please see the documentation of sd_ble_tx_buffer_count_get for more details.

Parameters

  [in] | conn_handle | Connection handle.
  [in] | p_hvx_params | Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with the contents pointed by it before sending the notification or indication.

Returns
  NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
  BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
  BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
  NRF_ERROR_NOT_FOUND Attribute not found.
  NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
  NRF_ERROR_BUSY Procedure already in progress.
  BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use sd_ble_gatts_sys_attr_set to set them to a known value.
  BLE_ERROR_NO_TX_BUFFERS There are no available buffers to send the data, applies only to notifications.

uint32_t sd_ble_gatts_include_add | ( | uint16_t | service_handle,
|  | uint16_t | inc_srvc_handle,
|  | uint16_t *const | p_include_handle
| ) |  |

Add an include declaration to the local server ATT table.

Note
  It is currently only possible to add an include declaration to the last added service (i.e. only sequential addition is supported at this time).
  The included service must already be present in the ATT table prior to this call.

Parameters

  [in] | service_handle | Handle of the service where the included service is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
  [in] | inc_srvc_handle | Handle of the included service.
  [out] | p_include_handle | Pointer to a 16-bit word where the assigned handle will be stored.

Returns
  NRF_SUCCESS Successfully added an include declaration.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
  NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
  NRF_ERROR_NO_MEM Not enough memory to complete operation.
  NRF_ERROR_NOT_FOUND Attribute not found.

uint32_t sd_ble_gatts_rw_authorize_reply | ( | uint16_t | conn_handle,
|  | ble_gatts_rw_authorize_reply_params_t const *const | p_rw_authorize_reply_params
| ) |  |

Respond to a Read/Write authorization request.

Note
  This call should only be used as a response to a BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.

Parameters

  [in] | conn_handle | Connection handle.
  [in] | p_rw_authorize_reply_params | Pointer to a structure with the attribute provided by the application.

Returns
  NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, ATT table updated.
  BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
  NRF_ERROR_INVALID_STATE No authorization request pending.
  NRF_ERROR_INVALID_PARAM Authorization op invalid, or for Read Authorization reply: requested handles not replied with, or for Write Authorization reply: handle supplied does not match requested handle.

uint32_t sd_ble_gatts_service_add | ( | uint8_t | type,
|  | ble_uuid_t const *const | p_uuid,
|  | uint16_t *const | p_handle
| ) |  |

Add a service declaration to the local server ATT table.

Parameters

  [in] | type | Toggles between primary and secondary services, see BLE_GATTS_SRVC_TYPES.
  [in] | p_uuid | Pointer to service UUID.
  [out] | p_handle | Pointer to a 16-bit word where the assigned handle will be stored.

Note
  Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to add a secondary service declaration that is not referenced by another service later in the ATT table.

Returns
  NRF_SUCCESS Successfully added a service declaration.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
  NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
  NRF_ERROR_NO_MEM Not enough memory to complete operation.

uint32_t sd_ble_gatts_service_changed | ( | uint16_t | conn_handle,
|  | uint16_t | start_handle,
|  | uint16_t | end_handle
| ) |  |

Indicate the Service Changed attribute value.

This call will send a Handle Value Indication to one or more peers connected to inform them that the attribute table layout has changed. As soon as the peer has confirmed the indication, a BLE_GATTS_EVT_SC_CONFIRM event will be issued.

Note
  Some of the restrictions and limitations that apply to sd_ble_gatts_hvx also apply here.

Parameters

  [in] | conn_handle | Connection handle.
  [in] | start_handle | Start of affected attribute handle range.
  [in] | end_handle | End of affected attribute handle range.

Returns
  NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
  BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
  NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
  NRF_ERROR_BUSY Procedure already in progress.
  BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use sd_ble_gatts_sys_attr_set to set them to a known value.

uint32_t sd_ble_gatts_sys_attr_get | ( | uint16_t | conn_handle,
|  | uint8_t *const | p_sys_attr_data,
|  | uint16_t *const | p_len
| ) |  |

Retrieve persistent system attribute information from the stack.

This call is used to retrieve information about values to be stored perisistently by the application after a connection has been terminated. When a new connection is made to the same bond, the values should be restored using sd_ble_gatts_sys_attr_set. The data should be read before any new advertising is started, or any new connection established. The connection handle for the previous now defunct connection will remain valid until a new one is created to allow this API call to refer to it.

Parameters

  [in] | conn_handle | Connection handle of the recently terminated connection.
  [in] | p_sys_attr_data | Pointer to a buffer where updated information about system attributes will be filled in. NULL can be provided to obtain the length of the data
  [in,out] | p_len | Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data.

Returns
  NRF_SUCCESS Successfully retrieved the system attribute information.
  BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.

uint32_t sd_ble_gatts_sys_attr_set | ( | uint16_t | conn_handle,
|  | uint8_t const *const | p_sys_attr_data,
|  | uint16_t | len
| ) |  |

Update persistent system attribute information.

Supply to the stack information about persistent system attributes. This call is legal in the connected state only, and is usually made immediately after a connection is established and the bond identified. usually as a response to a BLE_GATTS_EVT_SYS_ATTR_MISSING.

p_sysattrs may point directly to the application's stored copy of the struct. If the pointer is NULL, the system attribute info is initialized, assuming that the application does not have any previously saved data for this bond.

Note
  The state of persistent system attributes is reset upon connection and then remembered for its duration.
  If this call returns with an error code different from NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or reset the SoftDevice to return to a known state.

Parameters

  [in] | conn_handle | Connection handle.
  [in] | p_sys_attr_data | Pointer to a saved copy of system attributes supplied to the stack, or NULL.
  [in] | len | Size of data pointed by p_sys_attr_data, in octets.

Returns
  NRF_SUCCESS Successfully set the system attribute information.
  BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
  NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with sd_ble_gatts_sys_attr_get.
  NRF_ERROR_NO_MEM Not enough memory to complete operation.

uint32_t sd_ble_gatts_value_get | ( | uint16_t | handle,
|  | uint16_t | offset,
|  | uint16_t *const | p_len,
|  | uint8_t *const | p_data
| ) |  |

Get the value of a given attribute.

Parameters

  [in] | handle | Attribute handle.
  [in] | offset | Offset in bytes to read from.
  [in,out] | p_len | Length in bytes to be read, total length of attribute value (in bytes, starting from offset) after successful return.
  [in,out] | p_data | Pointer to a buffer (at least len bytes long) where to store the attribute value. Set to NULL to obtain the complete length of attribute value.

Note
  If the attribute value is longer than the size of the supplied buffer, p_len will return the total attribute value length (excluding offset), and not the number of bytes actually returned in p_data. The application may use this information to allocate a suitable buffer size.

Returns
  NRF_SUCCESS Successfully retrieved the value of the attribute.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_NOT_FOUND Attribute not found.

uint32_t sd_ble_gatts_value_set | ( | uint16_t | handle,
|  | uint16_t | offset,
|  | uint16_t *const | p_len,
|  | uint8_t const *const | p_value
| ) |  |

Set the value of a given attribute.

Parameters

  [in] | handle | Attribute handle.
  [in] | offset | Offset in bytes to write from.
  [in,out] | p_len | Length in bytes to be written, length in bytes written after successful return.
  [in] | p_value | Pointer to a buffer (at least len bytes long) containing the desired attribute value.

Returns
  NRF_SUCCESS Successfully set the value of the attribute.
  NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  NRF_ERROR_NOT_FOUND Attribute not found.
  NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
  NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by BLE_GATTS_ATTR_LENS_MAX.