Extended advertising stops after connection gets established in nRF Connect SDK

Hello..

I tried implementing a simple application using nRF Connect SDK, which sends data in a connection event using notifications. This is the base code for a test application which requires the peripheral to operate in the connectable (and non-scannable) undirected advertising mode. According to the BLE specs, this is only achievable using advertising extensions. 

The connection gets established successfully and I am also able to see the notification data using nRF Connect App for Android. However, once the peripheral enters connection, it stops advertising, and does not re-start advertising even after getting disconnected. The only way it starts advertising again is resetting the peripheral. After a lot of struggle, this is the current status:

  •  Inside the connection disconnected callback function, I called the extended advertising start function, and this worked perfectly. Once the peripheral gets disconnected, it resumes extended advertising.
  • However, this is not the desired behavior. I want the peripheral to keep advertising once it enters the connection mode so that it is also visible to other devices. I searched and came across the following GitHub link and few other links referenced in this discussion that pointed out the exactly same issue:

    https://github.com/zephyrproject-rtos/zephyr/issues/33897

    The suggested workaround in this discussion is to call the extended advertising start function inside the advertising connected callback (using the bt_le_ext_adv_cb callback struct) inside the bt_le_ext_adv_create() function. I tried doing this, exactly the same way as I called the extended advertising start function inside the disconnected callback function earlier.

    But this does not seem to work. I keep on getting either the ENOMEM error (error -12), or the error log shown in the picture:

The same method works with the disconnected callback but fails with the advertising connected callback. Is there anything that I might have missed?

The proj.config file looks like this:

# Increased stack due to settings API usage
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_NAME="Zephyr Peripheral Sample Long Name"
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=65
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_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6
CONFIG_BT_MAX_CONN=20

nRF52840 has been used as the peripheral. Could you please look into this once and suggest a suitable workaround? 

Related