Binding issues

SDK is NCS2.9.2,My device supports master-slave integration. As a slave, it can pair and bind with a mobile phone. As a master, it can scan and connect to two slave devices without needing to pair and bind with them.

Currently, I'm enabling broadcast connection to a mobile phone. After a successful connection, I call `bt_conn_set_security(connection, BT_SECURITY_L2)` to trigger pairing and binding. However, if I enable `CONFIG_BT_CENTRAL=y` in the `prj.conf` file, triggering pairing returns a security level error code `BT_SECURITY_ERR_AUTH_FAIL` (BT_SECURITY_L1). But if I disable `CONFIG_BT_CENTRAL=n` and enable broadcast connection, pairing and binding with the mobile phone succeeds. What could be the reason for this?

1.Before each connection, I clear the binding information, so there is not Stale bond information

2.Below is the configuration of my prj.conf file.

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_GPIO=y

# Use Internal 32K xtal
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n

CONFIG_BT=y
CONFIG_BT_GATT_DM=y
CONFIG_BT_GATT_CLIENT=y
#CONFIG_BT_GATT_DM_MAX_ATTRS=10 
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="AURA150"
#CONFIG_BT_MAX_CONN=1
#CONFIG_BT_MAX_PAIRED=1
CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y

# Include the Bluetooth LE stack in the project.

# Add,This allows the device to proactively initiate MTU negotiation after connection, without waiting for a request from the peer.
CONFIG_BT_GATT_AUTO_UPDATE_MTU=y 
CONFIG_BT_GATT_DM_MAX_ATTRS=50
# support for the peripheral role from the Bluetooth LE stack

CONFIG_BT_DEVICE_APPEARANCE=1152
CONFIG_BT_MAX_CONN=4
CONFIG_BT_BUF_ACL_RX_COUNT=6
CONFIG_BT_MAX_PAIRED=2

CONFIG_BT_SMP_SC_PAIR_ONLY=n
CONFIG_BT_SMP_SC_ONLY=n
CONFIG_BT_SMP=y
CONFIG_BT_ID_MAX=1
CONFIG_BT_GATT_AUTO_SEC_REQ=y

CONFIG_BT_FILTER_ACCEPT_LIST=y
CONFIG_BT_PRIVACY=n

CONFIG_BT_CENTRAL=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=2
CONFIG_BT_SCAN_ADDRESS_CNT=2
CONFIG_BT_SCAN_MANUFACTURER_DATA_CNT=1
#If it is not enabled,scanning must be disabled before calling bt_conn_le_create(); otherwise, error code -11 (-EAGAIN) will be returned.
CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL=y

# DIS information
CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_RETENTION_BOOTLOADER_INFO_OUTPUT_SETTINGS=y
CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=38
CONFIG_BT_DIS_SERIAL_NUMBER_STR="003F0000005800000000FFFFFFFFFFFF"
CONFIG_BT_DIS_FW_REV_STR="1.00"
CONFIG_BT_DIS_HW_REV_STR="1.10"

# Enable the Battery Service
CONFIG_BT_BAS=y

# Enable the NUS service
CONFIG_BT_NUS=y
# Enable the BLE modules from NCS
CONFIG_BT_NUS_CLIENT=y

# Enable bonding
#CONFIG_SETTINGS_NONE=y
CONFIG_BT_SETTINGS=y
#CONFIG_BT_GATT_CACHING=n
# Enable bonding
CONFIG_SETTINGS_NONE=n
CONFIG_SETTINGS_RUNTIME=y
CONFIG_BT_GATT_CACHING=n

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y


# This example requires more stack
CONFIG_MAIN_STACK_SIZE=1152
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_ATT_TX_COUNT=10

#Enable FOTA over Bluetooth LE
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
# Make sure printk is printing to the UART console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_PRINTK=y

CONFIG_ASSERT=y
############### peripheral config ###############
CONFIG_NEWLIB_LIBC=y
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_PM_DEVICE=y
CONFIG_REBOOT=y
CONFIG_POWEROFF=y
CONFIG_NFCT_PINS_AS_GPIOS=y
CONFIG_ADC=y
CONFIG_PWM=y

############### Add bonding support to the application ###############
CONFIG_SETTINGS=y
CONFIG_BT_SETTINGS=y
## flash config ##
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_ZMS=y

I currently have no idea why enabling CONFIG_BT_CENTRAL=y causes pairing/binding to fail.Please provide some ideas for solving this problem.

Related