Peripheral disconnects immediately with reason 0x2A when RealMe Note 50 (Android 13) connects to

Hi,

My custom board nRF52840 works as a Peripheral, which advertises itself for connection from a Central.

The project is built based on peripheral_hr sample project. In the project, I increase the L2CAP TX MTU size to 247 (please refer to my prj.conf below). It works perfectly with iOS and our ESP32 embedded system running BLE 4.0.

However, when an Android phone (RealMe Note 50, Android 13) connects to it, my `on_disconnected()` callback is fired immediately with reason: `0x2a`. 

Below is my `prj.conf`:

# Increased stack due to settings API usage
#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 => default value

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
# CONFIG_BT_SMP=n ## Security Manager Protocol: pair, bond, encrypt
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
#CONFIG_BT_PERIPHERAL_PREF_LATENCY=0 # by default
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_DIS=y
# CONFIG_BT_DIS_PNP=n # ??
CONFIG_BT_DIS_MODEL="ECG sensor V2"
CONFIG_BT_DIS_MANUF="NousLogic"
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_FW_REV_STR="1.7.5"
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_HW_REV_STR="2.0.0"
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_BAS=y
#CONFIG_BT_HRS=y
#CONFIG_BT_IAS=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="NousLogic ECG"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=65

CONFIG_SETTINGS_NONE=y
CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=21

#CONFIG_BT_GATT_CLIENT=y => to bt_gatt_exchange_mtu()

#CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y => many debug logs, which are not helpful

# HCI ACL buffers size
# BT_L2CAP_RX_MTU = CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE
CONFIG_BT_BUF_ACL_RX_SIZE=251

# L2CAP SDU/PDU TX MTU
CONFIG_BT_L2CAP_TX_MTU=247

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

CONFIG_SPI=y

# Enable Edge Impulse dependencies
CONFIG_CPP=y
CONFIG_STD_CPP11=y
CONFIG_FP16=n

# Enable Edge Impulse
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

CONFIG_EDGE_IMPULSE=y
CONFIG_EDGE_IMPULSE_URI="D:/ECG/impl/peripheral1/ecg-v11.zip"
CONFIG_EI_WRAPPER=y
CONFIG_NFCT_PINS_AS_GPIOS=y
# Battery read
CONFIG_ADC=y
#CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048 => default value

CONFIG_RESET_ON_FATAL_ERROR=y

# Power optimization in Power optimization on nRF52840.pdf
CONFIG_USE_SEGGER_RTT=y
CONFIG_SHELL=y
CONFIG_ASSERT=y
CONFIG_ASSERT_VERBOSE=y
CONFIG_ASSERT_NO_FILE_INFO=y # 
CONFIG_THREAD_NAME=y
## to printout for debugging: turn these to y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_PRINTK_SYNC=y

# OTA
CONFIG_BOOTLOADER_MCUBOOT=y
#Include MCUMGR and the dependencies in the build
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
CONFIG_SETTINGS_NVS=y
CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=n
CONFIG_SETTINGS_DYNAMIC_HANDLERS=n
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_SETTINGS_RUNTIME=y
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

Log of the events since connected:

mtu_updated: Updated MTU: TX: 20 RX: 23 bytes => 23
on_connected: Connected

on_connected: Connection params: interval 36*1.25ms, latency 0, timeout 500*10ms
on_disconnected: Disconnected (reason 0x2a)

Trying to search around in this community, I can't find a clear description about this reason 0x2a. What is it actually?

Since the connection is dropped immediately after established, I have no idea which side drops/fails: my device (acting as a Peripheral) or the Android phone. What other events should my device listen to in order to capture this crash event?

How should I troubleshoot this problem?

Best regards.

Related