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

nRF5340 + Zephyr bluetooth stack - scan duplicates filtering does not work

nRF5340 DK

ncs 1.4.2

Zephyr 2.4.0

zephyr/samples/bluetooth/central (with modifications)

When scanning, specifying scan option BT_LE_SCAN_OPT_FILTER_DUPLICATE has no effect for both passive and active scanning.

Specifying options explicitly:

static void start_scan(void)
{
	int err;
    struct bt_le_scan_param scan_param =
    {
        .type = BT_LE_SCAN_TYPE_ACTIVE,
        .options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
        .interval = BT_GAP_SCAN_FAST_INTERVAL,
        .window = BT_GAP_SCAN_FAST_WINDOW,
        .timeout = 0
    };

    //
	err = bt_le_scan_start(&san_param, device_found);
	if (err) {
		printk("Scanning failed to start (err %d)\n", err);
		return;
	}

	printk("Scanning successfully started\n");
}

or using the pre-supplied macro:

static void start_scan(void)
{
	int err;

    //
	err = bt_le_scan_start(BT_LE_SCAN_ACTIVE, device_found);
	if (err) {
		printk("Scanning failed to start (err %d)\n", err);
		return;
	}

	printk("Scanning successfully started\n");
}

still results in all advertisements being forwarded to device_found(...):

static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
			 struct net_buf_simple *ad)
{
    uint8_t base_addr[6] = { 0xb2, 0xfc, 0x69, 0x22, 0x91, 0xb0 };
	char addr_str[BT_ADDR_LE_STR_LEN] = {0};
	int err;

	if (default_conn) {
		return;
	}

    bt_addr_le_to_str(addr, addr_str, sizeof(addr_str));

    if (!memcmp(&addr->a, base_addr, 6))
    {
        if (type == 0)
        {
            printk("Device found: %s (RSSI %d), %s\n", addr_str, rssi, "ADV_INT");
        }
        if (type == 4)
        {
            printk("Device found: %s (RSSI %d), %s\n", addr_str, rssi, "SCAN_RSP");
        }
    }
}

Changing from active scanning to passive:

	err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, device_found);

and the same issue (except, of course, only ADV_INT PDU's are being captured):

There is some prior chat on this forum regarding an identical problem with nRF52840 and SoftDevice but this is a Zephyr build.

Regards,

AC

Parents Reply Children
  • Hi,

    The application is a copy of the central app built from .../ncs/zephyr/samples/bluetooth/central. As far as I know, both controller and host are therefore Zephyr software builds but I do not know how to check. Please advise.

    >> "...check if CONFIG_BT_LL_SW_SPLIT is set to y or not..."

    It is not. From the documentation, this appears to relate to Zephyr only and splits the Link Layer into two parts which is not what I want.  The Link Layer should be a single component running on the net core.

    >> "...By default, all samples except for the Bluetooth mesh samples are currently configured to use SoftDevice Controller..."

    Do you mean that if I build an application from .../ncs/zephyr/samples/bluetooth/..., I am not running a Zephyr controller?  I can find no documentation on the Nordic website regarding a softdevice for the nRF5340 device.  What is the device number?

    Regards,

    AC

  • skajam66 said:
    . As far as I know, both controller and host are therefore Zephyr software builds but I do not know how to check

     If you are using NCS, it will use the SoftDevice Controller as the default, this is also true even if the sample is from the zephyr folder. You can also check if you have CONFIG_BT_LL_SOFTDEVICE=y or not.

    skajam66 said:
    It is not. From the documentation, this appears to relate to Zephyr only and splits the Link Layer into two parts which is not what I want.  The Link Layer should be a single component running on the net core.

     It will still be a single component running on the net core. The "split link layer" is a version of the Zephyr BLE controller which is split into:

    • An upper, HW independent, LL (ULL)
    • A lower, thin, LL (LLL), which depends on the particular HW being used

    But you are not using the Zephyr Bluetooth Controller when CONFIG_BT_LL_SW_SPLIT is not set, then you are using the Nordic SoftDevice Controller.

    skajam66 said:
    Do you mean that if I build an application from .../ncs/zephyr/samples/bluetooth/..., I am not running a Zephyr controller?

     Correct. With NCS default Controller is the SoftDevice Controller.

    skajam66 said:
    I can find no documentation on the Nordic website regarding a softdevice for the nRF5340 device.  What is the device number?

    As documented in http://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/nrf/ug_ble_controller.html, The SoftDevice Controller is designed for nRF52 and nRF53 Series devices. It provides the same implementation of the Link Layer that is available as part of Nordic Semiconductor’s SoftDevices. The SoftDevice Controller is developed, tested, and supported by Nordic Semiconductor.

    More documentation can be found here: http://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/nrfxlib/softdevice_controller/README.html#softdevice-controller

Related