This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr issues with limited advertising events on nRF52840

I've previously successfully done interval advertisements using a SoftDevice with Nordic's previous (non-Zephyr) sdk, but I'm having issues replicating it on Zephyr.

Our desired goal is as follows: we want to be able to send exactly 3 advertising events, 200 ms apart, and then stop advertising until the next event, in which case we want to send exactly 3 different advertising events, so on and so forth.

However, I'm having several issues on Zephyr:

First and foremost, it appears that BLE advertisements continue to be sent, rather than stopping at 3 events (though my sent callback does fire after 3 events are sent). I'm using the nRF Connect bluetooth app on my tablet to confirm this is the case, and the signal strength and interval numbers continue to update.

Secondly, the interval doesn't seem to change even when I increase the intervals from the default minimum of 100 ms (BT_GAP_ADV_FAST_INT_MIN_2) to the appropriate hex value for 200ms.

Finally, and most problematic, is that after the first advertisement set gets sent I see the following errors when I call the function to start advertising again:

<wrn> bt_hci_core: opcode 0x2039 status 0x0c
<err> bt_hci_core: Failed to start advertiser

I found the following issue in git: https://github.com/zephyrproject-rtos/zephyr/issues/31254

But, in our application we are not connectable and not scannable so it would seem as though this shouldn't be an issue in this case.

My code for initialization of the extended advertising is as follows (with my modified code to support intervals of 200ms), ignoring my var initialization for beacon_packet and adv:

#define BLE_INT                         (0x140) // N * 0.625. corresponds to dec. 320; 320*0.625 = 200ms
#define BLE_ADV_TIMEOUT                 (80)  // N * 10ms for advertiser timeout
#define BLE_ADV_EVENTS                  (3)

bt_le_ext_adv_create(BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV, BLE_INT, BLE_INT, NULL), &conn_callbacks, &adv);
bt_le_ext_adv_set_data(adv,beacon_packet, ARRAY_SIZE(beacon_packet), NULL, 0);
bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_PARAM(BLE_ADV_TIMEOUT, BLE_ADV_EVENTS));

My attempt at subsequent advertisements after the initialization is as follows:

bt_le_ext_adv_set_data(adv,beacon_packet, ARRAY_SIZE(beacon_packet), NULL, 0);
bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_PARAM(BLE_ADV_TIMEOUT, BLE_ADV_EVENTS));

Any help pointing me in the right direction would be appreciated! Again, this all worked well on the Nordic SDK using SoftDevices and I would really love to achieve the same functionality in Zephyr.

Parents Reply Children
  • Hi Sigurd,

    Thanks for the response! 

    Correct, I'm using NCS v1.5.0. I'm using the default bluetooth settings in NCS, so the SoftDevice Bluetooth Controller.

    For reference, my prj.conf file is as follows:

    CONFIG_ASSERT=y
    CONFIG_LOG=y
    
    CONFIG_BT=y
    CONFIG_BT_EXT_ADV=y
    
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_LOG_IMMEDIATE=y
    
    # Support for battery measurement using ADC
    CONFIG_ADC=y
    
    # Support for strtok
    CONFIG_NEWLIB_LIBC=y
    
    # Sensors
    CONFIG_SENSOR=y
    CONFIG_I2C=y
    
    # LED support
    CONFIG_GPIO=y
    
    # NVS - support for configuration data storage
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_NVS_LOG_LEVEL_DBG=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # Support reboot/soft reset
    CONFIG_REBOOT=y
    
    # BT Settings for NUS
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH_MAP=y
    CONFIG_SETTINGS=y

  • Hi Sigurd,

    Were you able to look into this?

    Thanks!

Related