nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches

◆ pm_peer_data_store()

uint32_t pm_peer_data_store ( uint16_t peer_id,
enum pm_peer_data_id data_id,
const void * data,
uint32_t len,
uint32_t * token )

#include <peer_manager.h>

Set or update stored data of a peer.

Note
Writing the data to non-volatile storage happens asynchronously. Therefore, the buffer that contains the data must be kept alive until the operation has completed.
The data written using this function might later be overwritten as a result of internal operations in the Peer Manager. A Peer Manager event is sent each time data is updated, regardless of whether the operation originated internally or from action by the user. Data with data_id PM_PEER_DATA_ID_GATT_REMOTE PM_PEER_DATA_ID_APPLICATION is never (over)written internally.
Parameters
[in]peer_idPeer ID to set data for.
[in]data_idThe type of data to set.
[in]dataNew value to set. The documentation for pm_peer_data_id specifies what data type each data ID should be stored as.
[in]lenThe length in bytes of data.
[out]tokenA token that identifies this particular store operation. The token can be used to identify events that pertain to this operation. This parameter can be NULL.
Return values
NRF_SUCCESSIf the data is scheduled to be written to persistent storage.
NRF_ERROR_NULLIf data is NULL.
NRF_ERROR_NOT_FOUNDIf no peer was found for the peer ID.
NRF_ERROR_INVALID_ADDRIf data is not word-aligned (4 bytes).
NRF_ERROR_BUSYIf the underlying storage handler is busy with other storage operations. Try again after receiving a Peer Manager event.
NRF_ERROR_RESOURCESIf there is not enough space in non-volatile storage.
NRF_ERROR_FORBIDDENIf data ID is PM_PEER_DATA_ID_BONDING and the new bonding data also corresponds to another bonded peer. No data is written so duplicate entries are avoided.
NRF_ERROR_INVALID_STATEIf the Peer Manager is not initialized.