nRF51 SDK v10.0.0
Data Structures | Typedefs | Enumerations | Functions
GATT Server Cache Manager

An internal module of Peer Manager. A module for managing persistent storing of GATT attributes pertaining to the GATT server role of the local device. More...

Data Structures

struct  gscm_evt_t
 Structure containing an event from the GSCM module. More...
 

Typedefs

typedef void(* gscm_evt_handler_t )(gscm_evt_t const *p_event)
 Event handler for events from the GATT Server Cache Manager module. More...
 

Enumerations

enum  gscm_evt_id_t {
  GSCM_EVT_LOCAL_DB_CACHE_STORED,
  GSCM_EVT_LOCAL_DB_CACHE_UPDATED,
  GSCM_EVT_SC_STATE_STORED
}
 Events that can come from the GATT Server Cache Manager module. More...
 

Functions

ret_code_t gscm_init (gscm_evt_handler_t evt_handler)
 Function for initializing the GATT Server Cache Manager module. More...
 
ret_code_t gscm_local_db_cache_update (uint16_t conn_handle)
 Function for triggering local GATT database data to be stored persistently. Values are retrieved from the SoftDevice and written to persistent storage. More...
 
ret_code_t gscm_local_db_cache_apply (uint16_t conn_handle)
 Function for applying stored local GATT database data to the SoftDevice. Values are retrieved from persistent storage and given to the SoftDevice. More...
 
ret_code_t gscm_local_db_cache_set (pm_peer_id_t peer_id, pm_peer_data_local_gatt_db_t *p_local_db)
 Function for setting new values in the local database cache. More...
 
ret_code_t gscm_local_db_cache_get (pm_peer_id_t peer_id, pm_peer_data_local_gatt_db_t *p_local_db)
 Function for retrieving values in the local database cache. More...
 
void gscm_local_database_has_changed (void)
 Function for storing the fact that the local database has changed, for all currently bonded peers. More...
 
bool gscm_service_changed_ind_needed (uint16_t conn_handle)
 Function for checking if a service changed indication should be sent. More...
 
ret_code_t gscm_service_changed_ind_send (uint16_t conn_handle)
 Function for sending a service changed indication to a connected peer. More...
 
void gscm_peer_was_notified_of_db_change (pm_peer_id_t peer_id)
 Function for specifying that a peer has been made aware of the latest local database change. More...
 

Detailed Description

An internal module of Peer Manager. A module for managing persistent storing of GATT attributes pertaining to the GATT server role of the local device.

Typedef Documentation

typedef void(* gscm_evt_handler_t)(gscm_evt_t const *p_event)

Event handler for events from the GATT Server Cache Manager module.

Parameters
[in]eventThe event that has happened.
[in]peerThe id of the peer the event pertains to.
[in]flagsThe data the event pertains to.

Enumeration Type Documentation

Events that can come from the GATT Server Cache Manager module.

Enumerator
GSCM_EVT_LOCAL_DB_CACHE_STORED 

The persistent cache for the local database has been updated with provided values, for one peer.

GSCM_EVT_LOCAL_DB_CACHE_UPDATED 

The persistent cache for the local database has been updated with values from the SoftDevice, for one peer.

GSCM_EVT_SC_STATE_STORED 

The service changed pending flag in persistent storage has been updated, for one peer.

Function Documentation

ret_code_t gscm_init ( gscm_evt_handler_t  evt_handler)

Function for initializing the GATT Server Cache Manager module.

Parameters
[in]evt_handlerCallback for events from the GATT Server Cache Manager module.
Return values
NRF_SUCCESSInitialization was successful.
NRF_ERROR_NULLevt_handler was NULL.
void gscm_local_database_has_changed ( void  )

Function for storing the fact that the local database has changed, for all currently bonded peers.

Note
This will cause a later call to gscm_service_changed_ind_needed to return true for a connection with a currently bonded peer.
ret_code_t gscm_local_db_cache_apply ( uint16_t  conn_handle)

Function for applying stored local GATT database data to the SoftDevice. Values are retrieved from persistent storage and given to the SoftDevice.

Parameters
[in]conn_handleConnection handle to apply values to.
Return values
NRF_SUCCESSStore operation started.
BLE_ERROR_INVALID_CONN_HANDLEconn_handle does not refer to an active connection with a bonded peer.
NRF_ERROR_INVALID_DATAThe stored data was rejected by the SoftDevice, which probably means that the local database has changed. The system part of the sys_attributes was attempted applied, so service changed indications can be sent to subscribers.
NRF_ERROR_BUSYUnable to perform operation at this time. Reattempt later.
NRF_ERROR_INVALID_STATEModule is not initialized.
Returns
An unexpected return value from an internal function call.
ret_code_t gscm_local_db_cache_get ( pm_peer_id_t  peer_id,
pm_peer_data_local_gatt_db_t p_local_db 
)

Function for retrieving values in the local database cache.

Parameters
[in]peer_idPeer to get values for.
[in,out]p_local_dbWhere to store the data. The length field needs to reflect the available buffer space. On a successful read, the length field is updated to match the length of the read data.
Return values
NRF_SUCCESSValues retrieved successfully.
NRF_ERROR_NOT_FOUNDThe peer ID was invalid or unallocated.
NRF_ERROR_NULLp_local_db was NULL.
NRF_ERROR_INVALID_STATEModule is not initialized.
ret_code_t gscm_local_db_cache_set ( pm_peer_id_t  peer_id,
pm_peer_data_local_gatt_db_t p_local_db 
)

Function for setting new values in the local database cache.

Note
If the peer is connected, the values will also be applied immediately to the connection.
The data in the pointer must be available until the GSCM_EVT_LOCAL_DB_STORED event is received.
Parameters
[in]peer_idPeer to set values for.
[in]p_local_dbDatabase values to apply. If NULL, the values will instead be cleared.
Return values
NRF_SUCCESSOperation started, and values were applied (if connected).
NRF_ERROR_NOT_FOUNDThe peer ID was invalid or unallocated.
NRF_ERROR_INVALID_STATEModule is not initialized.
Returns
An unexpected return value from an internal function call.
ret_code_t gscm_local_db_cache_update ( uint16_t  conn_handle)

Function for triggering local GATT database data to be stored persistently. Values are retrieved from the SoftDevice and written to persistent storage.

Parameters
[in]conn_handleConnection handle to perform update on.
Return values
NRF_SUCCESSStore operation started.
BLE_ERROR_INVALID_CONN_HANDLEconn_handle does not refer to an active connection with a bonded peer.
NRF_ERROR_BUSYUnable to perform operation at this time. Reattempt later.
NRF_ERROR_DATA_SIZEWrite buffer not large enough. Call will never work with this GATT database.
NRF_ERROR_NO_MEMNo room in persistent_storage. Free up space; the operation will be automatically reattempted after the next compression procedure
NRF_ERROR_INVALID_STATEModule is not initialized.
void gscm_peer_was_notified_of_db_change ( pm_peer_id_t  peer_id)

Function for specifying that a peer has been made aware of the latest local database change.

Note
After calling this, a later call to gscm_service_changed_ind_needed will to return false for this peer unless gscm_local_database_has_changed is called again.
Parameters
[in]peer_idThe connection to send the indication on.
bool gscm_service_changed_ind_needed ( uint16_t  conn_handle)

Function for checking if a service changed indication should be sent.

Parameters
[in]conn_handleThe connection to check.
Returns
true if a service changed indication should be sent, false if not.
ret_code_t gscm_service_changed_ind_send ( uint16_t  conn_handle)

Function for sending a service changed indication to a connected peer.

Parameters
[in]conn_handleThe connection to send the indication on.
Return values
NRF_SUCCESSIndication sent or not needed.
BLE_ERROR_INVALID_CONN_HANDLEconn_handle does not refer to an active connection.
NRF_ERROR_BUSYUnable to send indication at this time. Reattempt later.
BLE_ERROR_GATTS_SYS_ATTR_MISSINGInformation missing. Apply local cache, then reattempt.
NRF_ERROR_INVALID_PARAMFrom sd_ble_gatts_service_changed. Unexpected.

This document was last updated on Mon Nov 9 2015.
Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone.