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...
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 void(* gscm_evt_handler_t)(gscm_evt_t const *p_event) |
Event handler for events from the GATT Server Cache Manager module.
- Parameters
-
[in] | event | The event that has happened. |
[in] | peer | The id of the peer the event pertains to. |
[in] | flags | The data the event pertains to. |
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 for initializing the GATT Server Cache Manager module.
- Parameters
-
[in] | evt_handler | Callback for events from the GATT Server Cache Manager module. |
- Return values
-
NRF_SUCCESS | Initialization was successful. |
NRF_ERROR_NULL | evt_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_handle | Connection handle to apply values to. |
- Return values
-
NRF_SUCCESS | Store operation started. |
BLE_ERROR_INVALID_CONN_HANDLE | conn_handle does not refer to an active connection with a bonded peer. |
NRF_ERROR_INVALID_DATA | The 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_BUSY | Unable to perform operation at this time. Reattempt later. |
NRF_ERROR_INVALID_STATE | Module is not initialized. |
- Returns
- An unexpected return value from an internal function call.
Function for retrieving values in the local database cache.
- Parameters
-
[in] | peer_id | Peer to get values for. |
[in,out] | p_local_db | Where 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_SUCCESS | Values retrieved successfully. |
NRF_ERROR_NOT_FOUND | The peer ID was invalid or unallocated. |
NRF_ERROR_NULL | p_local_db was NULL. |
NRF_ERROR_INVALID_STATE | Module is not initialized. |
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_id | Peer to set values for. |
[in] | p_local_db | Database values to apply. If NULL, the values will instead be cleared. |
- Return values
-
NRF_SUCCESS | Operation started, and values were applied (if connected). |
NRF_ERROR_NOT_FOUND | The peer ID was invalid or unallocated. |
NRF_ERROR_INVALID_STATE | Module 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_handle | Connection handle to perform update on. |
- Return values
-
NRF_SUCCESS | Store operation started. |
BLE_ERROR_INVALID_CONN_HANDLE | conn_handle does not refer to an active connection with a bonded peer. |
NRF_ERROR_BUSY | Unable to perform operation at this time. Reattempt later. |
NRF_ERROR_DATA_SIZE | Write buffer not large enough. Call will never work with this GATT database. |
NRF_ERROR_NO_MEM | No room in persistent_storage. Free up space; the operation will be automatically reattempted after the next compression procedure |
NRF_ERROR_INVALID_STATE | Module 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_id | The 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_handle | The 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_handle | The connection to send the indication on. |
- Return values
-
NRF_SUCCESS | Indication sent or not needed. |
BLE_ERROR_INVALID_CONN_HANDLE | conn_handle does not refer to an active connection. |
NRF_ERROR_BUSY | Unable to send indication at this time. Reattempt later. |
BLE_ERROR_GATTS_SYS_ATTR_MISSING | Information missing. Apply local cache, then reattempt. |
NRF_ERROR_INVALID_PARAM | From sd_ble_gatts_service_changed. Unexpected. |