This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Peer manager rewrites peer data to flash on every connection, when using BLE privacy mode

Hi,

environment is
nRF5_SDK_16.0.0_98a08e2
windows
SES

target is nrf52840. I am using the nordic dev board.
The final product is a wearable, which will connect to a smartphone app.

Taking the BLE template example, I have made modifications for the purposes of security:
Bonding enabled
LE Secure Connections enabled
Random Private Resolvable address (I set the period to 300 seconds)

After programming the dev board, I am seeing the following behavior (I use nRF connect on an android phone for the purposes of testing):

After a boot, I see this debug output:
<info> app_timer: RTC: initialized.
<info> app: Template example started.
<info> app: Fast advertising.

1. I scan with nrf connect, and I can see the device, with an address 50:04:6C:4C:4F:4B


2. I connect to the device, which seems to work:
<info> app: Connected.

3. I bond with the device, which seems to work:
<info> nrf_ble_lesc: Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 0
<info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Bonding
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Central address resolution, action: Update
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update

4. I disconnect, by pressing disconnect on the nrfconnect app:
<info> app: Fast advertising.
<info> app: Disconnected.

5. Now I connect again, but I see from the debug that the 'peer data updated in flash':
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
<info> app: Connected.
<info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
<info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
<info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update

It concerns me that every time the phone disconnects/reconnects, the flash is written, as this will happen a great deal, and I have been made to understand that flash write cycles should be minimised. I really dont want to wear out the internal device flash just because of this.

Do you think I am doing anything silly here, which is causing flash to be written on every connection, or is that just how it works? Is it satisfactory, or should I worry?

Related