Skip to content

Commit

Permalink
samples: wifi: Add Wi-Fi and Thread coexistence sample
Browse files Browse the repository at this point in the history
Initial version of the Wi-Fi and Thread coexistence sample.

This sample is to run Wi-Fi and Thread throughputs simultaneously
to show how they coexist.

Wi-Fi in station mode connects to Wi-Fi AP and runs Zperf.
Thread in child mode connects to leader and runs Zperf.

Signed-off-by: Murali Thokala <[email protected]>
  • Loading branch information
muraliThokala committed May 17, 2024
1 parent f8b6fea commit e7fc6bd
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 120 deletions.
Empty file modified samples/wifi/thread_coex/CMakeLists.txt
100755 → 100644
Empty file.
Empty file modified samples/wifi/thread_coex/Kconfig
100755 → 100644
Empty file.
59 changes: 25 additions & 34 deletions samples/wifi/thread_coex/README.rst
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ Configuration options

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

.. _CONFIG_COEX_SEP_ANTENNAS:

CONFIG_COEX_SEP_ANTENNAS
This option specifies whether the antennas are shared or separate for Wi-Fi and Thread.

.. _CONFIG_TEST_TYPE_WLAN_ONLY:

Expand Down Expand Up @@ -110,9 +106,6 @@ Configuration files

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

* Antenna configuration: Use the :ref:`CONFIG_COEX_SEP_ANTENNAS <CONFIG_COEX_SEP_ANTENNAS>` Kconfig option to select the antenna configuration.
Always set it to ``y`` to enable separate antennas mode. Thread doesn't support shared antenna configuration as it is in "idle listening" mode when not active.

* Test modes: Use the following Kconfig options to select the required test case:
* :ref:`CONFIG_TEST_TYPE_WLAN_ONLY <CONFIG_TEST_TYPE_WLAN_ONLY>` for Wi-Fi only test
* :ref:`CONFIG_TEST_TYPE_OT_ONLY <CONFIG_TEST_TYPE_OT_ONLY>` for Thread only test
Expand All @@ -125,16 +118,14 @@ To enable different test modes, set up the following configuration parameters in

* Wi-Fi connection: Set the following options appropriately as per the credentials of the access point used for this testing:

* :ref:`CONFIG_STA_SSID <CONFIG_STA_SSID>`
* :ref:`CONFIG_STA_PASSWORD <CONFIG_STA_PASSWORD>`
* :ref:`CONFIG_STA_KEY_MGMT_* <CONFIG_STA_KEY_MGMT_*>`
.. include:: /includes/wifi_credentials_static.txt

.. note::
``menuconfig`` can also be used to configure ``Wi-Fi credentials``

* Wi-Fi throughput test: Set the following option appropriately as per the IP address of the test PC on which iperf is run:
* :kconfig:option:`CONFIG_NET_CONFIG_PEER_IPV4_ADDR`

.. note::
``menuconfig`` can also be used to enable the ``Key management`` option.

See :ref:`zephyr:menuconfig` in the Zephyr documentation for instructions on how to run ``menuconfig``.

Building and running
Expand Down Expand Up @@ -308,9 +299,7 @@ The Thread throughput result appears on the minicom terminal connected to the nR
Results
=======

The following tables collect a summary of results obtained when coexistence tests are run for different Wi-Fi operating bands with
Wi-Fi and Thread data rates set to 10Mbps and 65kbps respectively.
The results are representative and might change based on the RSSI and the level of external interference.
The following tables collect a summary of results obtained when coexistence tests are run for different Wi-Fi operating bands with Wi-Fi and Thread data rates set to 10Mbps and 65kbps respectively in a clean RF environment. The results are representative and might vary based on the RSSI and the level of external interference.

Wi-Fi in 2.4 GHz
----------------
Expand All @@ -321,16 +310,16 @@ Separate antennas, Wi-Fi in 802.11n mode, Thread in client role:
| Test case | Wi-Fi UDP Tx | Thread |
| | throughput in Mbps | throughput in kbps |
+========================+====================+====================+
| Wi-Fi only, | 9.5 | N.A |
| client (UDP Tx) | | |
| Wi-Fi only, | 9.6 | N.A |
| client | | |
+------------------------+--------------------+--------------------+
| Thread only, | N.A | 63 |
| client (UDP Tx) | | |
| client | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.5 | 10 |
| Wi-Fi and Thread, | 9.5 | 14 |
| coexistence disabled | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.3 | 55 |
| Wi-Fi and Thread, | 9.3 | 59 |
| coexistence enabled | | |
+------------------------+--------------------+--------------------+

Expand All @@ -340,16 +329,16 @@ Separate antennas, Wi-Fi in 802.11n mode, Thread in server role:
| Test case | Wi-Fi UDP Tx | Thread |
| | throughput in Mbps | throughput in kbps |
+========================+====================+====================+
| Wi-Fi only, | 9.8 | N.A |
| client (UDP Tx) | | |
| Wi-Fi only, | 9.6 | N.A |
| client | | |
+------------------------+--------------------+--------------------+
| Thread only, | N.A | 63 |
| server (UDP Rx) | | |
| server | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.1 | 13 |
| Wi-Fi and Thread, | 9.4 | 14 |
| coexistence disabled | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.0 | 63 |
| Wi-Fi and Thread, | 8.8 | 63 |
| coexistence enabled | | |
+------------------------+--------------------+--------------------+

Expand All @@ -364,12 +353,12 @@ Separate antennas, Wi-Fi in 802.11n mode, Thread in client role:
| | throughput in Mbps | throughput in kbps |
+========================+====================+====================+
| Wi-Fi only, | 9.6 | N.A |
| client (UDP Tx) | | |
| client | | |
+------------------------+--------------------+--------------------+
| Thread only, | N.A | 63 |
| client (UDP Tx) | | |
| client | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.1 | 63 |
| Wi-Fi and Thread, | 9.2 | 63 |
| coexistence disabled | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.1 | 63 |
Expand All @@ -382,19 +371,21 @@ Separate antennas, Wi-Fi in 802.11n mode, Thread in server role:
| Test case | Wi-Fi UDP Tx | Thread |
| | throughput in Mbps | throughput in kbps |
+========================+====================+====================+
| Wi-Fi only, | 9.9 | N.A |
| client (UDP Tx) | | |
| Wi-Fi only, | 9.6 | N.A |
| client | | |
+------------------------+--------------------+--------------------+
| Thread only, | N.A | 63 |
| server (UDP Rx) | | |
| server | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.7 | 63 |
| Wi-Fi and Thread, | 8.6 | 63 |
| coexistence disabled | | |
+------------------------+--------------------+--------------------+
| Wi-Fi and Thread, | 9.7 | 63 |
| Wi-Fi and Thread, | 8.5 | 63 |
| coexistence enabled | | |
+------------------------+--------------------+--------------------+

Thread doesn't support shared antenna configuration as it is in "idle listening" mode when not active.

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

Expand Down
Empty file modified samples/wifi/thread_coex/child_image/802154_rpmsg.conf
100755 → 100644
Empty file.
Empty file modified samples/wifi/thread_coex/dts.overlay
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion samples/wifi/thread_coex/overlay-logging.conf
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ CONFIG_LOG_BACKEND_RTT=y
# Disable UART logging backend
# CONFIG_LOG_BACKEND_UART=n
CONFIG_SHELL_LOG_BACKEND=n

Empty file modified samples/wifi/thread_coex/overlay-openthread.conf
100755 → 100644
Empty file.
Empty file.
Empty file.
6 changes: 1 addition & 5 deletions samples/wifi/thread_coex/prj.conf
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CONFIG_NET_BUF_DATA_SIZE=1100
CONFIG_WIFI_MGMT_EXT=y
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="wifi_sr_coex_5"
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="Myssid"
CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="Mypassword"
CONFIG_WIFI_CREDENTIALS_STATIC_TYPE_OPEN=y

Expand Down Expand Up @@ -99,8 +99,4 @@ CONFIG_NET_CONFIG_AUTO_INIT=n
# test duration in milliseconds
CONFIG_COEX_TEST_DURATION=30000

CONFIG_NET_TCP_ISN_RFC6528=n
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_MBEDTLS_MD=y

CONFIG_NET_SOCKETS_POLL_MAX=10
2 changes: 1 addition & 1 deletion samples/wifi/thread_coex/sample.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tests:
CONFIG_MPSL_CX=y 802154_rpmsg_CONFIG_MPSL_CX=y
CONFIG_COEX_SEP_ANTENNAS=y OVERLAY_CONFIG="overlay-openthread.conf overlay-wifi-udp-client-thread-udp-client.conf"
platform_allow: nrf5340dk/nrf5340/cpuapp

tags: ci_build
sample.nrf7002_eb.thingy53.thread_coex:
build_only: true
extra_args: SHIELD=nrf7002eb 802154_rpmsg_SHIELD=nrf7002eb_coex
Expand Down
Empty file modified samples/wifi/thread_coex/src/main.c
100755 → 100644
Empty file.
Empty file modified samples/wifi/thread_coex/src/main.h
100755 → 100644
Empty file.
31 changes: 16 additions & 15 deletions samples/wifi/thread_coex/src/ot_coex_functions.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ void tcp_download_results_cb(enum zperf_status status, struct zperf_results *res
}

LOG_INF("Wi-Fi: TCP session ended\n");
/* LOG_INF("%u bytes in %u ms:", result->total_len,
result->time_in_us/USEC_PER_MSEC); */
/** LOG_INF("%u bytes in %u ms:", result->total_len,
* result->time_in_us/USEC_PER_MSEC);
*/
LOG_INF("\nThroughput:%u kbps", rate_in_kbps);
LOG_INF("");
k_sem_give(&udp_tcp_callback);
Expand Down Expand Up @@ -515,10 +516,9 @@ int run_wifi_traffic_udp(bool is_wifi_server)
params.duration_ms = CONFIG_COEX_TEST_DURATION;
params.rate_kbps = CONFIG_WIFI_ZPERF_RATE;
params.packet_size = CONFIG_WIFI_ZPERF_PKT_SIZE;

parse_ipv4_addr(CONFIG_NET_CONFIG_PEER_IPV4_ADDR, &in4_addr_my);
net_sprint_ipv4_addr(&in4_addr_my.sin_addr);


memcpy(&params.peer_addr, &in4_addr_my, sizeof(in4_addr_my));
ret = zperf_udp_upload_async(&params, udp_upload_results_cb, NULL);
Expand All @@ -537,9 +537,9 @@ void check_wifi_traffic(void)
LOG_ERR("Wi-Fi: Results are not ready");
} else {
#ifdef CONFIG_WIFI_ZPERF_PROT_UDP
LOG_INF("Wi-Fi UDP session finished");
LOG_INF("Wi-Fi UDP session finished");
#else
LOG_INF("Wi-Fi TCP session finished");
LOG_INF("Wi-Fi TCP session finished");
#endif
}
}
Expand All @@ -554,7 +554,7 @@ int wifi_connection(void)
LOG_INF("Wi-Fi Connection timeout");
return -1;
}

if (wifi_wait_for_next_event("Wi-Fi DHCP", WIFI_DHCP_TIMEOUT_SEC)) {
LOG_INF("Wi-Fi DHCP timeout");
return -1;
Expand Down Expand Up @@ -736,31 +736,32 @@ int wifi_tput_ot_tput(bool test_wifi, bool is_ant_mode_sep, bool test_thread, bo
#endif/* CONFIG_NRF700X_SR_COEX */
}
if (test_thread) {
LOG_INF("Thread operating channel = %d",CONFIG_OT_CHANNEL);
LOG_INF("Thread operating channel = %d", CONFIG_OT_CHANNEL);
}
if (test_thread) {
if (!is_ot_client) {
LOG_INF("Make sure peer Thread role is client");
k_sleep(K_SECONDS(3));
}

ret = ot_throughput_test_init(is_ot_client, is_ot_zperf_udp);
k_sleep(K_SECONDS(3));
if (ret != 0) {
LOG_ERR("Thread throughput init failed: %d", ret);
return ret;
}
}

if (is_ot_client) {
/* nothing */
} else {
/* wait until the peer client joins the network */
uint32_t print_wait_on_ping_reply = 1;

while (ot_wait4_ping_reply_from_peer == 0) {
if (print_wait_on_ping_reply) {
LOG_INF("Waiting on ping reply from peer");
print_wait_on_ping_reply = 0 ;
}
print_wait_on_ping_reply = 0;
}
ot_get_peer_address(5000);
k_sleep(K_SECONDS(1));
if (ot_wait4_ping_reply_from_peer) {
Expand Down Expand Up @@ -853,11 +854,11 @@ int wifi_tput_ot_tput(bool test_wifi, bool is_ant_mode_sep, bool test_thread, bo
/* otPlatRadioSetTransmitPower(ot_instance, -3); */
/* Get the current transmit power of OT device */
otPlatRadioGetTransmitPower(ot_instance, &ot_tx_power);
LOG_INF("OT device Tx power in dBm = %d", ot_tx_power);
/* LOG_INF("OT device Tx power in dBm = %d", ot_tx_power); */

/* The RSSI in dBm when it is valid. 127 when RSSI is invalid */
ot_rssi = otPlatRadioGetRssi(ot_instance);
LOG_INF("OT device RSSI in dBm = %d", ot_rssi);
/* LOG_INF("OT device RSSI in dBm = %d", ot_rssi); */
}

if (test_thread) {
Expand Down
3 changes: 1 addition & 2 deletions samples/wifi/thread_coex/src/ot_coex_functions.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LOG_MODULE_REGISTER(ot_coex_functions, CONFIG_LOG_DEFAULT_LEVEL);
#include "coex.h"
#include "coex_struct.h"
#include "fmac_main.h"
#include "ot_utils.h"
#include "ot_utils.h"

#define DEMARCATE_TEST_START

Expand All @@ -59,7 +59,6 @@ static struct {
K_SEM_DEFINE(wait_for_next, 0, 1);
K_SEM_DEFINE(udp_tcp_callback, 0, 1);


/**
* @brief configure PTA registers
*
Expand Down
Loading

0 comments on commit e7fc6bd

Please sign in to comment.