Bluetooth Low Energy (BLE) and Wi-Fi operate in the same band, and in some devices, share a single radio. This can cause data transmission on one interface to interfere with the other. Such interference can impact the performance of both Wi-Fi and BLE. In order to avoid such interference, coexistence (coex) configurations and algorithms are introduced in the underlying WLAN and BT stacks. These configurations can be tuned from the application to test and improve the performance of the underlying Wi-Fi and BLE traffic when they are operated simultaneously.
This library provides an API that allows the user to configure the coex parameters for WLAN and BLE.
Features and Functionality
- Supports Wi-Fi BT coex configuration based on BLE Scan priority. User can set the LE Scan priority, with one of three options - high, medium and low. Based on the priority, the different LE scan parameters are configured.
Supported Framework(s)
Supported Platform(s)
AnyCloud
Dependent Libraries
AnyCloud
Quick Start
A set of pre-defined configuration files have been bundled with the wifi-mw-core library for FreeRTOS, lwIP, and mbed TLS. Review the configuration and make the required adjustments. See the "Quick Start" section in README.md.
- Define the following COMPONENTS in the application's Makefile for the Smart Coex library.
COMPONENTS=FREERTOS MBEDTLS LWIP WCM WICED_BLE
- Add the following compiler directives to the
DEFINES
section in the application's Makefile: DEFINES+=CYBSP_WIFI_CAPABLE
- By default, log messages are disabled by the Smart Coex library. To enable log messages, the application must perform the following:
- Add the
ENABLE_SMARTCOEX_LOGS
macro to the DEFINES
in the code example's Makefile. The Makefile entry would look like this: DEFINES+=ENABLE_SMARTCOEX_LOGS
- Call the
cy_log_init()
function provided by the cy-log module. cy-log is part of the connectivity-utilities library. See connectivity-utilities library API documentation for cy-log details.
Code Snippets
This section provides code snippet for this library on AnyCloud framework.
Smart Coex Config on AnyCloud
The following snippet demonstrates the usage of the Smart Coex library API, in AnyCloud, to configure the WiFi and BT parameters for operating in coexistence.
#include "cy_smartcoex.h"
#include "cy_wcm.h"
#define APP_INFO( x ) printf x
#define APP_DEBUG( x ) //printf x
#define APP_ERROR( x ) printf x
#ifndef BT_CONFIG_SCAN_PRIORITY
#define BT_CONFIG_SCAN_PRIORITY CY_SMARTCOEX_LESCAN_PRIORITY_MEDIUM
#endif
#ifndef BT_CONFIG_SCAN_INTERVAL
#define BT_CONFIG_SCAN_INTERVAL 2
#endif
#ifndef BT_CONFIG_SCAN_WINDOW
#define BT_CONFIG_SCAN_WINDOW 1
#endif
int bt_on()
{
return 0;
}
cy_rslt_t smartcoex_config()
{
cy_rslt_t res;
int result;
cy_wcm_config_t config;
config.interface = CY_WCM_INTERFACE_TYPE_STA;
res = cy_wcm_init(&config);
if(res != CY_RSLT_SUCCESS)
{
APP_ERROR(("cy_wcm_init failed with error:[0x%X]\n", (unsigned int)res));
return res;
}
result = bt_on();
if(result == -1)
{
APP_ERROR(("Failed to initialize BT stack.\n"));
return CY_RSLT_MW_ERROR;
}
bt_config.
scan_int = BT_CONFIG_SCAN_INTERVAL;
bt_config.
scan_win = BT_CONFIG_SCAN_WINDOW;
if(res != CY_RSLT_SUCCESS)
{
APP_ERROR(("cy_smartcoex_config failed with error:0x%X\n", (unsigned int)res));
return res;
}
APP_INFO(("smart coex config completed.\n"));
}