Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it safe to use Peer Manager's Peer IDs for other FDS files?

I'm developing a database with FDS that stores application-level data that must be able to be matched to bond data. After looking at the files for Peer Manager, ID Manager, and Peer Data Storage, I want to check with someone else who knows the SDK code better than me to make sure that a couple assumptions behind my use of the Peer ID are valid.

Noticing the macros at the top of peer_data_storage.h, is it safe to assume that Peer IDs will always fall within the range 0x0-0x3FFE?  Also,  although the documentation says that the Peer IDs identify persistently stored peer data, do the IDs themselves stay the same for the lifetime of the peer (i.e. until pm_peer_delete() is called)?

Parents
  • The peer ID is locked for the lifetime until deleted yes. Also I noticed your related thread on the topic that may be of interest for others:

    https://devzone.nordicsemi.com/f/nordic-q-a/34793/how-do-i-use-pm_peer_data_app_store 

    The peer ID in code is between 0 and 0x3FFF (in reality between 0 and  255 because of PM_PEER_ID_N_AVAILABLE_IDS in peer_manager_types), but peer ID is "converted" to file ID n + 0xC000 before it is stored in FDS. See below.

    // Function to convert peer IDs to file IDs.
    static uint16_t peer_id_to_file_id(pm_peer_id_t peer_id)
    {
        return (uint16_t)(peer_id + PEER_ID_TO_FILE_ID);
    }
    
    
    // Function to convert peer data id to type id.
    static pm_peer_id_t file_id_to_peer_id(uint16_t file_id)
    {
        return (pm_peer_id_t)(file_id + FILE_ID_TO_PEER_ID);
    }
    
    
    // Function to convert peer data IDs to record keys.
    static uint16_t peer_data_id_to_record_key(pm_peer_data_id_t peer_data_id)
    {
        return (uint16_t)(peer_data_id + DATA_ID_TO_RECORD_KEY);
    }
    
    
    // Function to convert record keys to peer data IDs.
    static pm_peer_data_id_t record_key_to_peer_data_id(uint16_t record_key)
    {
        return (pm_peer_data_id_t)(record_key + RECORD_KEY_TO_DATA_ID);
    } 

Reply
  • The peer ID is locked for the lifetime until deleted yes. Also I noticed your related thread on the topic that may be of interest for others:

    https://devzone.nordicsemi.com/f/nordic-q-a/34793/how-do-i-use-pm_peer_data_app_store 

    The peer ID in code is between 0 and 0x3FFF (in reality between 0 and  255 because of PM_PEER_ID_N_AVAILABLE_IDS in peer_manager_types), but peer ID is "converted" to file ID n + 0xC000 before it is stored in FDS. See below.

    // Function to convert peer IDs to file IDs.
    static uint16_t peer_id_to_file_id(pm_peer_id_t peer_id)
    {
        return (uint16_t)(peer_id + PEER_ID_TO_FILE_ID);
    }
    
    
    // Function to convert peer data id to type id.
    static pm_peer_id_t file_id_to_peer_id(uint16_t file_id)
    {
        return (pm_peer_id_t)(file_id + FILE_ID_TO_PEER_ID);
    }
    
    
    // Function to convert peer data IDs to record keys.
    static uint16_t peer_data_id_to_record_key(pm_peer_data_id_t peer_data_id)
    {
        return (uint16_t)(peer_data_id + DATA_ID_TO_RECORD_KEY);
    }
    
    
    // Function to convert record keys to peer data IDs.
    static pm_peer_data_id_t record_key_to_peer_data_id(uint16_t record_key)
    {
        return (pm_peer_data_id_t)(record_key + RECORD_KEY_TO_DATA_ID);
    } 

Children
No Data
Related