Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to scan Bluetooth5 and Bluetooth4 advertisements at the same time?

Hello all,

I'm trying to do a "BLE scanner" in order to read non connectable advertisements. These advertisements can be PHY_CODED and PHY_1MBPS (classic BLE advertisements).

I'm using a nRF52840, nRF5 SDK v15.0.0 and S140 SoftDevice v6.0.0 API.

Currently, I have a code for reading PHY_1MBPS advertisements  and a code for reading PHY_CODED advertisements. But I am not able to read both kind of advertisements at same time.

I saw in documentation I can choose the type of advertisements scanned in the struct ble_gap_scan_params_t. So, I chose scan all of them:

.scan_phys		  = BLE_GAP_PHYS_SUPPORTED,

I'm trying it with this code:

static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_EXTENDED_MIN];

static ble_data_t m_scan_buffer =
{
    m_scan_buffer_data,
	BLE_GAP_SCAN_BUFFER_EXTENDED_MIN
};

static ble_gap_scan_params_t const m_scan_params =
{
	.active   = 0,
    .interval = SCAN_INTERVAL,
    .window   = SCAN_WINDOW,
    .timeout          = SCAN_DURATION,
	.scan_phys		  = BLE_GAP_PHYS_SUPPORTED,
    .filter_policy    = BLE_GAP_SCAN_FP_ACCEPT_ALL,
	.extended = 1,
};

static void scan_start(void)
{
    ret_code_t ret;
    ret = sd_ble_gap_scan_start(&m_scan_params, &m_scan_buffer);
    APP_ERROR_CHECK(ret);
}

But the function returns "invalid parameters error".

However, if I use 

.scan_phys        = BLE_GAP_PHY_1MBPS,

or 

.scan_phys        = BLE_GAP_PHY_CODED,

I can read PHY_1MBPS advertisements or PHY_CODED advertisements alternately.

Any idea?

Manuel Montenegro

Parents Reply Children
Related