Wi-Fi: Bluetooth LE coexistence

The Bluetooth LE coexistence sample demonstrates coexistence between Wi-Fi® and Bluetooth LE radios in 2.4 GHz frequency. The sample documentation includes details of test setup used, build procedure, test procedure and the results obtained when the sample is run on the nRF7002 DK.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Board target

Shields

Thingy:53

PCA20053

thingy53

thingy53/nrf5340/cpuapp

nrf7002eb nrf7002eb_coex

nRF7002 DK (emulating nRF7001)

PCA10143

nrf7002dk

nrf7002dk/nrf5340/cpuapp/nrf7001

nRF7002 DK

PCA10143

nrf7002dk

nrf7002dk/nrf5340/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nrf7002ek_nrf7001_coex nrf7002ek_coex nrf7002ek_nrf7001 nrf7002ek

Overview

The sample demonstrates how the coexistence mechanism is implemented and enabled and disabled between Wi-Fi and Bluetooth® LE radios in 2.4 GHz band using Wi-Fi client’s throughput and Bluetooth LE central’s throughput.

Test setup

The following figure shows a reference test setup.

Wi-Fi Coex test setup

Wi-Fi coexistence reference test and evaluation setup

The reference test setup shows the connections between the following devices:

  • Device Under Test (DUT) (nRF7002 DK on which the coexistence sample runs)

  • Wi-Fi peer device (access point with test PC that runs iperf)

  • Bluetooth LE peer device (nRF5340 DK on which Bluetooth LE throughput sample runs)

This setup is kept in a shielded test enclosure box (for example, a Ramsey box). The following table provides more details on the sample or application that runs on DUT and peer devices:

Device

Application

Details

nRF7002 DK

Bluetooth LE coex sample

The sample runs Wi-Fi throughputs, Bluetooth LE throughputs or a combination of both based on configuration selections in the prj.conf file.

Test PC

iperf application

Wi-Fi iperf UDP server is run on the test PC, and this acts as a peer device to Wi-Fi UDP client that runs on the nRF7002 DK.

nRF5340 DK

Bluetooth LE throughput sample

Bluetooth LE throughput sample is run in peripheral mode on the nRF5340 DK, and this acts as a peer device to Bluetooth LE central that runs on the nRF7002 DK.

To trigger concurrent transmissions at RF level on both Wi-Fi and Bluetooth LE, the sample runs traffic on separate threads, one for each. The sample uses standard Zephyr threads. The threads are configured with non-negative priority (pre-emptible thread). For details on threads and scheduling, refer to Threads.

Configuration

See Configuring and building an application for information about how to permanently or temporarily change the configuration.

Configuration options

The following sample-specific Kconfig options are used in this sample (located in samples/wifi/ble_coex/Kconfig):

CONFIG_TEST_TYPE_WLAN_ONLY

(bool) WLAN only

Enable WLAN only

CONFIG_TEST_TYPE_BLE_ONLY

(bool) BLE only

Enable BLE only

CONFIG_TEST_TYPE_WLAN_BLE

(bool) WLAN and BLE

Enable WLAN and BLE

CONFIG_TEST_TYPE_WLAN

(bool) WLAN

Enable WLAN

CONFIG_TEST_TYPE_BLE

(bool) BLE

Enable BLE

CONFIG_NET_CONFIG_PEER_IPV4_ADDR

(string) Peer IPv4 address

None

CONFIG_NET_CONFIG_PEER_IPV4_PORT

(int) Peer IPv4 port

None

CONFIG_WIFI_THREAD_STACK_SIZE

(int) Wi-Fi thread stack size

None

CONFIG_WIFI_THREAD_PRIORITY

(int) Wi-Fi thread priority

None

CONFIG_WIFI_ZPERF_SERVER

(bool) Zperf role: server or client

None

CONFIG_WIFI_ZPERF_PROT_UDP

(bool) UDP or TCP

None

CONFIG_WIFI_ZPERF_PKT_SIZE

(int) packet size

None

CONFIG_WIFI_ZPERF_RATE

(int) rate in kbps

None

CONFIG_INTERVAL_MIN

(int) BLE min connection interval. Each unit 1.25milliseconds

None

CONFIG_INTERVAL_MAX

(int) BLE max connection interval. Each unit 1.25milliseconds

None

CONFIG_COEX_ENABLE

(bool) Control if coexistence HW is enable

None

CONFIG_COEX_WLAN_2PT4G

(bool) Indicates if WLAN operating band is 2.4GHz or 5GHz

None

CONFIG_WIFI_TEST_DURATION

(int) test duration in milliseconds

None

CONFIG_BLE_TEST_DURATION

(int) test duration in milliseconds

None

CONFIG_COEX_BT_CENTRAL

(bool) BT device role

None

CONFIG_COEX_SEP_ANTENNAS

(bool) Control if the antennas are shared/separate for BT and WLAN

None

CONFIG_SR_PROTOCOL_BLE

(bool) Indicates if the Short Range protocol is Bluetooth LE or not

None

Additional configuration

To enable different test modes, set up the following configuration parameters in the prj.conf file:

  • Antenna configuration: Use the CONFIG_COEX_SEP_ANTENNAS Kconfig option to select the antenna configuration. Set it to y to enable separate antennas and n to enable shared antenna.

  • Test modes: Use the following Kconfig options to select the required test case:

    • CONFIG_TEST_TYPE_WLAN_ONLY for Wi-Fi only test

    • CONFIG_TEST_TYPE_BLE_ONLY for Bluetooth LE only test

    • CONFIG_TEST_TYPE_WLAN_BLE for concurrent Wi-Fi and Bluetooth LE test.

    Based on the required test, set only one of these to y.

  • Test duration: Use the CONFIG_WIFI_TEST_DURATION Kconfig option to set the duration of the Wi-Fi test and CONFIG_BLE_TEST_DURATION for the Bluetooth LE test. The units are in milliseconds. For example, to set the tests for 20 seconds, set the respective values to 20000. For the concurrent Wi-Fi and Bluetooth LE test, make sure that both are set to the same duration to ensure maximum overlap.

  • Bluetooth LE configuration: Set the Bluetooth LE connection interval limits using the CONFIG_INTERVAL_MIN and CONFIG_INTERVAL_MAX Kconfig options. The units are 1.25 milliseconds. For example, CONFIG_INTERVAL_MIN=80 corresponds to an interval of 100 ms (80 x 1.25).

  • Wi-Fi connection: Use the CONFIG_NET_CONFIG_PEER_IPV4_ADDR Kconfig option to establish a connection to a peer host.

You must configure the following Wi-Fi credentials in the prj.conf file:

Wi-Fi static credential options

If you want to configure the credentials statically, set the CONFIG_WIFI_CREDENTIALS_STATIC Kconfig option to y.

Important

Do not use static credentials in production environments.

Other options for statically configuring your Wi-Fi credentials:

Note

You can also use menuconfig to configure Wi-Fi credentials.

See Interactive Kconfig interfaces in the Zephyr documentation for instructions on how to run menuconfig.

Set up the following configuration parameters in the prj_nrf5340dk_nrf5340_cpuapp.conf file:

  • File or time-based throughput: Use CONFIG_BT_THROUGHPUT_FILE to select file or time-based throughput test. Set it to n to enable time-based throughput test only when running Bluetooth LE throughput in central role.

  • Test duration: Use CONFIG_BT_THROUGHPUT_DURATION to set the duration of the Bluetooth LE throughput test only when running Bluetooth LE throughput in central role. The units are in milliseconds.

Note

Use the same test duration value for CONFIG_WIFI_TEST_DURATION, CONFIG_BLE_TEST_DURATION, and CONFIG_BT_THROUGHPUT_DURATION.

Building and running

This sample can be found under samples/wifi/ble_coex in the nRF Connect SDK folder structure.

When built as firmware image for a board target with the */ns variant, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE). Because of this, it automatically includes the Trusted Firmware-M (TF-M). To read more about CMSE, see Processing environments.

To build the sample, follow the instructions in Configuring and building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

The sample can be built for the following configurations:

  • Wi-Fi throughput only

  • Bluetooth LE throughput only

  • Concurrent Wi-Fi and Bluetooth LE throughput (with coexistence enabled and disabled modes)

To build for the nRF7002 DK, use the nrf7002dk/nrf5340/cpuapp board target. The following are examples of the CLI commands:

  • Build with coexistence disabled:

    west build -p -b nrf7002dk/nrf5340/cpuapp -- -DCONFIG_MPSL_CX=n -Dipc_radio_CONFIG_MPSL_CX=n
    

Use this command for Wi-Fi throughput only, Bluetooth LE throughput only, or concurrent Wi-Fi and Bluetooth LE throughput with coexistence disabled tests.

  • Build with coexistence enabled:

    west build -p -b nrf7002dk/nrf5340/cpuapp -- -DCONFIG_MPSL_CX=y -Dipc_radio_CONFIG_MPSL_CX=y
    

Use this command for concurrent Wi-Fi and Bluetooth LE throughput with coexistence enabled test.

Change the board target as given below for the nRF7001 DK, nRF7002 EK, and nRF7001 EK.

  • Board target for nRF7001 DK:

    nrf7002dk/nrf5340/cpuapp/nrf7001
    
  • Board target for nRF7002 EK and nRF7001 EK:

    nrf5340dk/nrf5340/cpuapp
    

Add the following SHIELD options for the nRF7002 EK and nRF7001 EK.

  • For nRF7002 EK:

    -DSHIELD=nrf7002ek -Dipc_radio_SHIELD=nrf7002ek_coex
    
  • For nRF7001 EK:

    -DSHIELD=nrf7002ek_nrf7001 -Dipc_radio_SHIELD=nrf7002ek_nrf7001_coex
    

The generated HEX file to be used is ble_coex/build/merged.hex.

Use the Bluetooth throughput sample from the nrf/samples/bluetooth/throughput folder on the peer nRF5340 DK device.

Build for the nRF5340 DK:

west build -p -b nrf5340dk/nrf5340/cpuapp

The generated HEX file to be used is throughput/build/merged.hex.

Connecting to DKs

After the DKs are connected to the test PC through USB connectors and powered on, open a suitable terminal, and run the following command:

$ nrfjprog --com
1050043161         /dev/ttyACM0    VCOM0
1050043161         /dev/ttyACM1    VCOM1
1050724225         /dev/ttyACM2    VCOM0
1050724225         /dev/ttyACM3    VCOM1
$

In this example, 1050043161 is the device ID of the nRF5340 DK and 1050724225 is device ID of the nRF7002 DK.

While connecting to a particular board, use the ttyACMx corresponding to VCOM1. In the example, use ttyACM1 to connect to the board with device ID 1050043161. Similarly, use ttyACM3 to connect to the board with device ID 1050724225.

$ minicom -D /dev/ttyACM1 -b 115200
$ minicom -D /dev/ttyACM3 -b 115200

Programming DKs

To program the nRF5340 DK:

  1. Open a new terminal in the test PC.

  2. Navigate to <ncs code>/nrf/samples/bluetooth/throughput/.

  3. Run the following command:

    $ west flash --dev-id <device-id> --hex-file build/merged.hex
    

To program the nRF7002 DK:

  1. Open a new terminal in the test PC.

  2. Navigate to <ncs code>/nrf/samples/wifi/ble_coex/.

  3. Run the following command:

    $ west flash --dev-id <device-id> --hex-file build/merged.hex
    

Testing

Running coexistence sample test cases require additional software such as the Wi-Fi iperf application. When the sample runs Wi-Fi UDP throughput in client mode, a peer device runs UDP throughput in server mode using the following command:

$ iperf -s -i 1 -u

Use iperf version 2.0.5. For more details, see Network Traffic Generator.

Test case

Coexistence

Test procedure

Wi-Fi only throughput

NA

Run Wi-Fi iperf in server mode on the test PC. Program the coexistence sample application on the nRF7002 DK.

Bluetooth LE only throughput

NA

Program Bluetooth LE throughput application on the nRF5340 DK and select role as peripheral. Program the coexistence sample application on the nRF7002 DK.

Wi-Fi and Bluetooth LE combined throughput

Disabled/ Enabled

Run Wi-Fi iperf in server mode on the test PC. Program Bluetooth LE throughput application on the nRF5340 DK and select role as peripheral. Program the coexistence sample application on the nRF7002 DK.

The Wi-Fi throughput result appears on the test PC terminal on which iperf server is run. The Bluetooth LE throughput result appears on the minicom terminal connected to the nRF5340 DK.

Results

The following tables summarize the results obtained from coexistence tests conducted in a clean RF environment for different Wi-Fi operating bands, antenna configurations, and Wi-Fi modes. These results are representative and might vary based on the RSSI and the level of external interference.

Wi-Fi in 2.4 GHz

Separate antennas, Wi-Fi in 802.11n mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

10.2

N.A

Bluetooth LE only, central

N.A

1107

Wi-Fi and Bluetooth LE, coexistence disabled

9.9

145

Wi-Fi and Bluetooth LE, coexistence enabled

8.3

478

Shared antenna, Wi-Fi in 802.11n mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

10.2

N.A

Bluetooth LE only, central

N.A

1219

Wi-Fi and Bluetooth LE, coexistence disabled

10.2

29

Wi-Fi and Bluetooth LE, coexistence enabled

6.2

749

Separate antennas, Wi-Fi in 802.11b mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

3.5

N.A

Bluetooth LE only, central

N.A

1042

Wi-Fi and Bluetooth LE, coexistence disabled

3.3

110

Wi-Fi and Bluetooth LE, coexistence enabled

2.2

563

Shared antenna, Wi-Fi in 802.11b mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

3.5

N.A

Bluetooth LE only, central

N.A

1190

Wi-Fi and Bluetooth LE, coexistence disabled

3.4

59

Wi-Fi and Bluetooth LE, coexistence enabled

2.2

508

Wi-Fi in 5 GHz

Separate antennas, Wi-Fi in 802.11n mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

10.2

N.A

Bluetooth LE only, central

N.A

1139

Wi-Fi and Bluetooth LE, coexistence disabled

10.2

1188

Wi-Fi and Bluetooth LE, coexistence enabled

10.2

1208

Shared antenna, Wi-Fi in 802.11n mode:

Test case

Wi-Fi UDP Tx throughput in Mbps

Bluetooth LE throughput in kbps

Wi-Fi only, client (UDP Tx)

10.2

N.A

Bluetooth LE only, central

N.A

1180

Wi-Fi and Bluetooth LE, coexistence disabled

10.2

1177

Wi-Fi and Bluetooth LE, coexistence enabled

10.2

1191

Sample output

The following screenshots show coexistence test results obtained for separate antenna configuration with Wi-Fi mode set to 802.11n. These tests were run with WLAN connected to an AP in 2.4 GHz band. In the images, the top image result shows Wi-Fi throughput that appears on a test PC terminal in which Wi-Fi iperf server is run and the bottom image result shows Bluetooth LE throughput that appears on a minicom terminal in which the Bluetooth LE throughput sample is run.

Wi-Fi only throughput

Wi-Fi only throughput 10.2 Mbps

Bluetooth LE only throughput

Bluetooth LE only throughput: 1107 kbps

Wi-Fi and Bluetooth LE CD

Wi-Fi and Bluetooth LE throughput, coexistence disabled: Wi-Fi 9.9 Mbps and Bluetooth LE 145 kbps

Wi-Fi and Bluetooth LE CE

Wi-Fi and Bluetooth LE throughput, coexistence enabled: Wi-Fi 8.3 Mbps and Bluetooth LE 478 kbps

As is evident from the results of the sample execution, coexistence harmonizes air-time between Wi-Fi and Bluetooth LE rather than resulting in a higher combined throughput. This is consistent with the design intent.

Dependencies

This sample uses the following library: