This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

temporary store bonding information on peripheral

Hello,

which functions should I use to implement following scenario:

Peripheral is bonded with Central. All nessesary bonding information are stored on periphal.
User is able to erase peripherals bonding information by pressing a specified key >5 sec. After that, the peripheral should start sending advertising packets automatically. If there is no central device with initiats conenction with the peripheral (within 30 sec), then the old bonding information should be restored to the peripheral.

So in my way of thinking, I have to store bonding information (read gapBondCharCfg_t, gapBondRec_t, gapBondLTK_t) from NV to RAM. Then I have to erase bondings via gapbondmgr, otherwise I won't be able to start advertising right? In case that there is no new connection / pairing within 30 sec, I restore the bonding information stored in RAM.

Are there any functions in the BLE Stack which help me to do so? (storing / restoring bonding information?)

greetings,

Elias

  • Hi Elias,

    If I understood your question correctly you can try following :

    1. Change "GAP_BONDINGS_MAX" to 1. This macro specified how many bonding information can be saved in NV.

    2. Now, when user presses key for >5 seconds, start advertising.

    3. And now if new central device bonds with your peripheral device it will automatically overwrites the previously stored bonding information. And if no one connects, the previously stored information is still intact.

    Hope this helps.

    Thanks,

    Dhaval

  • Hi Dhaval,

    thank you for this advice, it seems to be the easiest way!

    Unfortuantly the Bond Manager (gapBondMgrFindEmpty() ) returns an invalid value, if no empty entries are available.

    /*********************************************************************
     * @fn      gapBondMgrFindEmpty
     *
     * @brief   Look through the bonding NV entries to find an empty.
     *
     * @param   none
     *
     * @return  index to empty bonding (0 - (GAP_BONDINGS_MAX-1),
     *          GAP_BONDINGS_MAX if no empty entries
     */

    following change in the gapbondmgr.c file (gapBondMgrFindEmpty( void) ) finally helps:

    return (0x00);
    //return ( GAP_BONDINGS_MAX );

    This is a pretty dirty solution, but would perfectly fit to my requirement.