The Bluetooth SDK 2.4 introduced a new bond replacement algorithm which makes bonding process smarter. There is only limited amount of flash reserved for storing bonds and the new algorithm uses it more efficiently in order to decrease unnecessary flash writes.
How it Works
Using the new algorithm, bonded devices are stored in a list which is divided into two parts: active bondings and inactive bondings. At the picture below active bondings are marked with green and inactive bondings are marked with red.
The working principle of new algorithm is shown in the picture above and it is based on three rules.
The new bond replacement algorithm does not require intervention from the application. The size of the inactive bondings list is 1/3 of the maximum number of bondable devices rounded up. The maximum number of bondable devices is configured with the max_bonding_count parameter in sm_store_bonding_configuration command.
How to enable
To enable this new algorithm, you need to use cmd_sm_store_bonding_configuration command and change policy_flags value to 2. Note that you need SDK version 2.4.0 or later. I added some explanation below.
gecko_cmd_sm_store_bonding_configuration(uint8 max_bondi ng_count, uint8 policy_flags);
Max_bonding_count is the maximum number of bonds saved in the peripheral storage storage and it can have values from 1-14. Policy_flags defines bonding mode. The following modes are available:
• 0: If database is full, new bonding attempts will fail
• 1: New bonding will overwrite the oldest existing bonding
• 2: New bonding will overwrite longest time ago used existing
bonding (This is The New Bond Replacement Algorithm)