Wi-Fi: Bluetooth LE coexistence
The Bluetooth LE coexistence sample demonstrates coexistence between Wi-Fi® and Bluetooth® LE radios in 2.4 GHz frequency.
Requirements
The sample supports the following development kit:
Hardware platforms |
PCA |
Board name |
Board target |
Shields |
---|---|---|---|---|
PCA20053 |
|
|
||
PCA10143 |
|
|||
PCA10143 |
|
|||
PCA10095 |
|
|
Running test cases for this sample requires additional software, such as the Wi-Fi iPerf application. Use iPerf version 2.0.5. For more details, see Network Traffic Generator.
Overview
The sample demonstrates how the coexistence mechanism is implemented, and how it can be enabled and disabled between Wi-Fi and Bluetooth LE radios in the 2.4 GHz band. This is done by using the throughput of the Wi-Fi client and the Bluetooth LE central.
Test setup
The following figure shows a reference test 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)
The following table provides more details on the sample or application that runs on DUT and peer devices:
Device |
Application |
Details |
---|---|---|
nRF7002 DK (DUT) |
Bluetooth LE coexistence sample |
The sample runs Wi-Fi throughput only, Bluetooth LE throughput only,
or a combination of both based on configuration selections in the
|
Test PC |
iPerf application |
Wi-Fi iPerf UDP server is run on the test PC, and this acts as a peer device to the Wi-Fi UDP client that runs on the nRF7002 DK. |
nRF5340 DK (peer) |
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. |
Configuration
See Configuring and building 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:
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 andCONFIG_BLE_TEST_DURATION
for the Bluetooth LE test. The units are in milliseconds. For example, to set the test for 20 seconds, set these values to20000
. 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
andCONFIG_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: Configure the following Wi-Fi credentials in the
prj.conf
: appropriately as per the credentials of the access point used for this testing:
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:
CONFIG_WIFI_CREDENTIALS_STATIC
- This option enables static Wi-Fi configuration.CONFIG_WIFI_CREDENTIALS_STATIC_SSID
- Wi-Fi SSID.CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD
- Wi-Fi password.CONFIG_WIFI_CREDENTIALS_STATIC_TYPE_OPEN
- Wi-Fi network uses no password.CONFIG_WIFI_CREDENTIALS_STATIC_TYPE_PSK
- Wi-Fi network uses a password and PSK security (default).CONFIG_WIFI_CREDENTIALS_STATIC_TYPE_PSK_SHA256
- Wi-Fi network uses a password and PSK-256 security.CONFIG_WIFI_CREDENTIALS_STATIC_TYPE_SAE
- Wi-Fi network uses a password and SAE security.
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
.
Wi-Fi throughput test: Set the
CONFIG_NET_CONFIG_PEER_IPV4_ADDR
Kconfig option appropriately as per the Wi-Fi interface IP address of the test PC on which iPerf is run.
Set up the following configuration parameters in the Kconfig.conf
file of the Bluetooth throughput sample from the nrf/samples/bluetooth/throughput
folder.
File or time-based throughput: Use
CONFIG_BT_THROUGHPUT_FILE
to select file or time-based throughput test. Set it ton
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 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.
You can build the coexistence sample 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
.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.
Connect to the kit with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.
Run the following command to check the available devices:
nrfjprog --com
This command returned the following output in the setup used to run the coexistence tests.
1050043161 /dev/ttyACM0 VCOM0 1050043161 /dev/ttyACM1 VCOM1 1050724225 /dev/ttyACM2 VCOM0 1050724225 /dev/ttyACM3 VCOM1
In this example,
1050043161
is the serial number of the nRF5340 DK and1050724225
is the serial number of the nRF7002 DK.While connecting to a particular device, use the
/dev/ttyACM
corresponding to VCOM1. In the example, use/dev/ttyACM1
to connect to the device with the serial number1050043161
. Similarly, use/dev/ttyACM3
to connect to the device with the serial number1050724225
.Run the following commands to connect to the desired devices:
minicom -D /dev/ttyACM1 -b 115200 minicom -D /dev/ttyACM3 -b 115200
Programming DKs
Complete the following steps to program the DKs:
Start the toolchain environment in a terminal window.
Navigate to the
<ncs code>/nrf/samples/bluetooth/throughput/
folder.Run the following command:
west flash --dev-id <device-id> --hex-file build/merged.hex
Start the toolchain environment in a terminal window.
Navigate to the
<ncs code>/nrf/samples/wifi/ble_coex/
folder.Run the following command:
west flash --dev-id <device-id> --hex-file build/merged.hex
Test procedure
The following table provides the procedure to run Wi-Fi only, Bluetooth LE-only, and combined throughput.
Test case |
Coexistence |
Test procedure |
---|---|---|
Wi-Fi-only throughput |
N.A. |
Run Wi-Fi iPerf in server mode on the test PC. Build the coexistence sample for Wi-Fi-only throughput and program the application on the nRF7002 DK. |
Bluetooth LE -only throughput |
N.A. |
Program the Bluetooth LE throughput application on the nRF5340 DK and select role as peripheral. Build the coexistence sample for Bluetooth LE-only and program the 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 the Bluetooth LE throughput application on the nRF5340 DK and select role as peripheral. Build the coexistence sample for concurrent Wi-Fi and Bluetooth LE throughput and program the application on the nRF7002 DK. |
When the sample is executed, the Wi-Fi UDP throughput operates with the Device Under Test (DUT) in client mode. To run the UDP throughput in server mode on the peer device (test PC), use the following command.
iperf -s -i 1 -u
Observe that 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 (802.11n mode) in 2.4 GHz
Separate antennas:
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:
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 |
Wi-Fi (802.11b mode) in 2.4 GHz
Separate antennas:
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:
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 (802.11n mode) in 5 GHz
Separate antennas:
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:
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.
The results show that coexistence harmonizes airtime 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: