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

An internal module of Peer Manager. A module for managing persistent storing of GATT attributes. More...

Data Structures

struct  gcm_evt_param_conn_handle_t
 A structure meant to be used for event parameters for multiple event types. More...
 
struct  gcm_evt_t
 Structure containing an event from the GCM module. More...
 

Typedefs

typedef void(* gcm_evt_handler_t )(gcm_evt_t const *p_event)
 Event handler for events from the GATT Cache Manager module. More...
 

Enumerations

enum  gcm_evt_id_t {
  GCM_EVT_LOCAL_DB_CACHE_STORED,
  GCM_EVT_LOCAL_DB_CACHE_UPDATED,
  GCM_EVT_LOCAL_DB_CACHE_APPLIED,
  GCM_EVT_ERROR_LOCAL_DB_CACHE_APPLY,
  GCM_EVT_REMOTE_DB_CACHE_UPDATED,
  GCM_EVT_SERVICE_CHANGED_INDICATION_SENT,
  GCM_EVT_ERROR_DATA_SIZE,
  GCM_EVT_ERROR_STORAGE_FULL,
  GCM_EVT_ERROR_UNEXPECTED
}
 Events that can come from the GATT Cache Manager module. More...
 

Functions

ret_code_t gcm_init (gcm_evt_handler_t evt_handler)
 Function for initializing the GATT Cache Manager module. More...
 
void gcm_ble_evt_handler (ble_evt_t *p_ble_evt)
 Function for dispatching SoftDevice events to the GATT Cache Manager module. More...
 
ret_code_t gcm_remote_db_store (pm_peer_id_t peer_id, pm_peer_data_remote_gatt_db_t *p_remote_db)
 Function for storing a discovered remote database persistently. More...
 
ret_code_t gcm_remote_db_retrieve (pm_peer_id_t peer_id, pm_peer_data_remote_gatt_db_t *p_remote_db)
 Function for retrieving a persistently stored remote database. More...
 
ret_code_t gcm_local_db_cache_update (uint16_t conn_handle)
 Function for triggering local GATT database data to be stored persistently. Values are retrieved from SoftDevice and written to persistent storage. More...
 
ret_code_t gcm_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 gcm_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 gcm_local_database_has_changed (void)
 Function for manually informing that the local database has changed. More...
 

Detailed Description

An internal module of Peer Manager. A module for managing persistent storing of GATT attributes.

Typedef Documentation

typedef void(* gcm_evt_handler_t)(gcm_evt_t const *p_event)

Event handler for events from the GATT 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 Cache Manager module.

Enumerator
GCM_EVT_LOCAL_DB_CACHE_STORED 

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

GCM_EVT_LOCAL_DB_CACHE_UPDATED 

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

GCM_EVT_LOCAL_DB_CACHE_APPLIED 

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

GCM_EVT_ERROR_LOCAL_DB_CACHE_APPLY 

The stored local database values for a peer were rejected by the SoftDevice, which means the database has changed.

GCM_EVT_REMOTE_DB_CACHE_UPDATED 

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

GCM_EVT_SERVICE_CHANGED_INDICATION_SENT 

A service changed indication has been sent to and confirmed by a peer.

GCM_EVT_ERROR_DATA_SIZE 

An operation failed because the write buffer of the Peer Database module was not large enough. This is a fatal error.

GCM_EVT_ERROR_STORAGE_FULL 

An operation failed because there was no available storage room in persistent storage. Please free up room, and the operation will automatically continue.

GCM_EVT_ERROR_UNEXPECTED 

An operation failed with an unexpected error. The error is provided. This is possibly a fatal error.

Function Documentation

void gcm_ble_evt_handler ( ble_evt_t p_ble_evt)

Function for dispatching SoftDevice events to the GATT Cache Manager module.

Parameters
[in]p_ble_evtThe SoftDevice event.
ret_code_t gcm_init ( gcm_evt_handler_t  evt_handler)

Function for initializing the GATT Cache Manager module.

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

Function for manually informing that the local database has changed.

This causes a service changed notification to be sent to all bonded peers that subscribe to it.

ret_code_t gcm_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.

Note
This function is not needed for regular operation of the module.
Parameters
[in]peer_idPeer to get values for.
[out]p_local_dbDatabase values.
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 gcm_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.
This function is only needed when you want to override the regular functionality of the module.
The data in the pointer must be available until the GCM_EVT_LOCAL_DB_CACHE_SET 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.
ret_code_t gcm_local_db_cache_update ( uint16_t  conn_handle)

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

Note
This function is only needed when you want to override the regular functionality of the module, e.g. to immediately store to flash instead of waiting for the native logic to perform the update.
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, bonded connection.
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.
ret_code_t gcm_remote_db_retrieve ( pm_peer_id_t  peer_id,
pm_peer_data_remote_gatt_db_t p_remote_db 
)

Function for retrieving a persistently stored remote database.

Parameters
[in]peer_idPeer to retrieve data for.
[in,out]p_remote_dbCopied database values.
Return values
NRF_SUCCESSData retrieved successfully.
NRF_ERROR_NOT_FOUNDThe peer ID is invalid or unallocated.
NRF_ERROR_NULLp_remote_db is NULL.
NRF_ERROR_INVALID_STATEModule is not initialized.
ret_code_t gcm_remote_db_store ( pm_peer_id_t  peer_id,
pm_peer_data_remote_gatt_db_t p_remote_db 
)

Function for storing a discovered remote database persistently.

Parameters
[in]peer_idPeer to store the database for.
[in]p_remote_dbDatabase values to store. If NULL, values are cleared instead.
Return values
NRF_SUCCESSStore procedure successfully started.
NRF_ERROR_NOT_FOUNDThe peer id is invalid or unallocated.
NRF_ERROR_INVALID_STATEModule is not initialized.

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.