Delete/overwrite old bond keys when a new pair happens

Hi,

I am using nRF54L15, SDK & Toolchain as 3.0.2 version
This is for Hid Keyboard, the problem I'm facing is once connected to one device, manually disconnecting & connecting to a new device, not properly getting connected, facing automatic disconnection immediately, reason 0x05.
The solution I need is to delete/overwrite the old bond keys whenever device is pairing with a new one, so this will solve the issue, I'm implemented on my code, but still it's not properly working. Check my code what's the issue/what I need to add.
Below I have attached the main file & prj.config file, kindly check it & do the grateful

Thanks,

# Enable Bluetooth Low Energy stack
CONFIG_BT=y
# Maximum 1 simultaneous connection (HID keyboard)
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1
# Device acts as peripheral (server)
CONFIG_BT_PERIPHERAL=y
# Device name shown in Bluetooth scans
CONFIG_BT_DEVICE_NAME="HID Keyboard"
# Device appears as keyboard (0x03C1 = 961)
CONFIG_BT_DEVICE_APPEARANCE=961
# Enable connection context (required by HID service)
CONFIG_BT_CONN_CTX=y
# Memory buffer alignment for connection context
CONFIG_BT_CONN_CTX_MEM_BUF_ALIGN=4

# Enable HID Service (Human Interface Device)
CONFIG_BT_HIDS=y
# Maximum 1 HID client (single host connection)
CONFIG_BT_HIDS_MAX_CLIENT_COUNT=1

# Enable Security Manager Protocol (pairing)
CONFIG_BT_SMP=y
# Allow device to be paired/bonded
CONFIG_BT_BONDABLE=y
# Allow overwriting unauthenticated bonds
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

# Enable settings subsystem
CONFIG_SETTINGS=y
# Store Bluetooth settings in flash
CONFIG_BT_SETTINGS=y
# Enable flash memory support
CONFIG_FLASH=y
# Enable flash page layout
CONFIG_FLASH_PAGE_LAYOUT=y
# Enable flash memory mapping
CONFIG_FLASH_MAP=y
# Enable Non-Volatile Storage
CONFIG_NVS=y
# Use NVS for settings storage
CONFIG_SETTINGS_NVS=y

# Enable DK button/LED functions
CONFIG_DK_LIBRARY=y

# Set TX power to +8 dBm (maximum for nRF54L15)
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
# Below is the link to Nordic's documentation for TX power settings for maximum transmission power.
#https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/protocols/matter/getting_started/transmission_power.html

# Enable TX Power Service (advertising data)
CONFIG_BT_TPS=y

# Disable default HID encryption (use custom security)
CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=n

# Use public Bluetooth addresses (simpler)
CONFIG_BT_PRIVACY=n

CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y

# Disable Bluetooth debug messages
CONFIG_BT_LOG_LEVEL_OFF=y
# Disable NVS debug messages
CONFIG_NVS_LOG_LEVEL_OFF=y
//output

Starting advertising
Connected
Security level 1 requested
Going to sleep
Security (encryption) established, level 2
Pairing completed, bonded=1
Disconnected reason 0x13, waking up to restart advertising
Starting advertising
Connected
Security level 1 requested
Disconnected reason 0x05, waking up to restart advertising
Starting advertising
Connected
Security level 1 requested
Disconnected reason 0x05, waking up to restart advertising
Starting advertising
Connected
Security level 1 requested
Going to sleep
Disconnected reason 0x05, waking up to restart advertising
Starting advertising
Connected
Security level 1 requested
Disconnected reason 0x05, waking up to restart advertising
Starting advertising

Parents Reply Children
No Data
Related