bt_adv: Controller cannot resume connectable advertising

After update to SDK 2.4.0 I'm seeing this error:

 [00:01:37.116,943] <inf> ble_nus: Central Disconnected: 70:23:B7:FE:65:27 (random) (reason 8)
00> [00:01:37.117,309] <wrn> bt_hci_core: opcode 0x2005 status 0x0c
00> [00:01:37.117,340] <err> bt_adv: Controller cannot resume connectable advertising (-5)

After the error advertising does not resume any more and I have to reset the device. I didn't see this problem using the sdk 2.1.1 for the same code.

I am utilizing both the central and peripheral roles in my project. The issue arises when the central device (my phone) disconnects from the board (which is acting as the peripheral role) due to being out of range. However, I haven't encountered the same problem when manually connecting and disconnecting the devices (reason 9). Here is the configuration for my project:

CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PINCTRL=y
CONFIG_EVENTS=y

# Enable the UART driver
#CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_CONSOLE=y
#CONFIG_UART_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
#fpu
CONFIG_FPU=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y

# Enable the BLE stack with GATT Client configuration
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_PRIVACY=n
CONFIG_BT_MAX_CONN=20
CONFIG_BT_MAX_PAIRED=20
CONFIG_BT_DEVICE_NAME="CB"
CONFIG_BT_DEVICE_APPEARANCE=832
CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT=1
# Enable the BLE modules from NCS
CONFIG_BT_NUS_CLIENT=y
CONFIG_BT_NUS=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_BT_GATT_DM=y
CONFIG_HEAP_MEM_POOL_SIZE=8096

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=3072
CONFIG_MAIN_STACK_SIZE=5120

#memory
CONFIG_STDOUT_CONSOLE=y
CONFIG_SPI=y
CONFIG_NORDIC_QSPI_NOR=y

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Enable ADC
CONFIG_ADC=y
CONFIG_MODULE_BATTERY=y

# Config logger
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n

CONFIG_GPIO_AS_PINRESET=y
CONFIG_ASSERT=y

#FIRMWARE config
CONFIG_APP_WAIT_REQUEST=y
CONFIG_APP_DISABLE_LTE_AUTOMATIC_SWITCH=y


CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y

CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_PRIVACY=n

CONFIG_NFCT_PINS_AS_GPIOS=y
CONFIG_PWM=y

Could you help me to understand what is happening?

Parents Reply Children
  • Hi !

    Should I restart advertising? Shouldn't it happen automatically? I didn't observe it in the peer example.

    I'm currently initiating the advertising process during initialization. I will try your suggestion and I will be back with the results.

    void ble_peer_nus_init(void)
    {
        if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED))
        {
            bt_conn_auth_cb_register(&conn_auth_callbacks);
        }

        int err = bt_nus_init(&nus_cb);
        if (err)
        {
            LOG_ERR("Failed to initialize UART service (err: %d)", err);
            return;
        }

        err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd,
                              ARRAY_SIZE(sd));
        if (err)
        {
            LOG_ERR("Advertising failed to start (err %d)", err);
            return;
        }
    }

    void bluetooth_ready(int err)
    {
        if (err)
        {
            LOG_ERR("Bluetooth init error %d", err);
            return;
        }

        LOG_INF("Bluetooth initialized");

       
        if (IS_ENABLED(CONFIG_SETTINGS))
        {
            settings_load();
        }

        ble_peer_nus_init();

        bt_nus_multi_setup();

        scan_init();

    }

    From main:

        err = bt_enable(bluetooth_ready);
        if (err)
        {
            LOG_ERR("Bluetooth init failed (err %d)", err);
            return;
        }
  • Hi Mariano, 


    Sorry I thought you were using BT_LE_ADV_OPT_ONE_TIME and would require to restart advertising manually. 

    Please let me know if you still see the issue if you don't scan. 
    I suspect it may have something to do with this: https://github.com/zephyrproject-rtos/zephyr/issues/13629

    It's the same error 0x0C. 

  • Hi , thank you for your help. What you proposed have worked, despite is not the most beautiful solution. Best regards,

    Mariano

Related