Existing bonding data is unexpectedly cleared when disconnecting unbonded devices during security_changed callback

I am currently encountering an issue with BLE bonding logic in my application.

When a phone initiates a pairing request and triggers a pairing pop-up, I use the security_changed callback to filter the device. My logic is designed to automatically disconnect the peripheral if the device is identified as "unbonded."

However, I've observed an abnormal behavior: executing the disconnect command at this stage also causes the system to wipe the existing bonding data (Bonding Info) stored in flash.

Could you please explain why a disconnection triggered during the security level change would lead to the erasure of previously saved bonding records? Is there a specific state in the Peer Manager or security manager that causes this side effect?

Related