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

◆ pm_peer_rank_highest()

uint32_t pm_peer_rank_highest ( uint16_t peer_id)

#include <peer_manager.h>

Update the rank of a peer to be the highest among all stored peers.

If this function returns NRF_SUCCESS, either a PM_EVT_PEER_DATA_UPDATE_SUCCEEDED or a PM_EVT_PEER_DATA_UPDATE_FAILED event is sent with a PM_STORE_TOKEN_INVALID store token when the operation is complete. Until the operation is complete, this function returns NRF_ERROR_BUSY.

When the operation is complete, the peer is the highest ranked peer as reported by pm_peer_ranks_get.

Note
The PM_EVT_PEER_DATA_UPDATE_SUCCEEDED event can arrive before the function returns if the peer is already ranked highest. In this case, the flash_changed flag in the pm_peer_data_update_succeeded_evt event will be false.
Parameters
[in]peer_idThe peer to rank highest.
Return values
NRF_SUCCESSIf the peer's rank is, or will be, updated to be highest.
NRF_ERROR_INVALID_PARAMIf peer_id is invalid, or doesn't exist in non-volatile storage.
NRF_ERROR_RESOURCESIf there is not enough space in non-volatile storage.
NRF_ERROR_BUSYIf the underlying storage handler is busy with other storage operations, or if a previous call to this function has not completed. Try again after receiving a Peer Manager event.
NRF_ERROR_INVALID_STATEIf the Peer Manager is not initialized.
NRF_ERROR_DATA_SIZEIf the highest rank is UINT32_MAX, so the new rank would wrap around to 0. To fix this, manually update all ranks to smaller values, while still keeping their order.
NRF_ERROR_INTERNALIf an internal error occurred.
NRF_ERROR_NOT_SUPPORTEDIf peer rank functionality has been disabled via the CONFIG_PM_PEER_RANKS Kconfig option.