1| Supported Targets | ESP32 | 2| ----------------- | ----- | 3 4# Example of BLE Mesh and TCP Server/Client Coexistence 5 6This example introduces how to test the basic functions of `BLE Mesh data interface` and `TCP Server/Client Coexistence`. `BLE Mesh data interface` is GAP scanning and advertising. 7 8There are two working modes here: 9 10 * In automatic mode, the program coordinates three development boards working through a synchronization mechanism. 11 12 * In manual mode, you will work with three development boards via commands 13 14 15## Test Preparation 16 17* Before running the test, you need to prepare a router and three ESP32 development boards. This Example of BLE Mesh and TCP Server/Client Coexistence has the following three items, and any of the three development boards is for running one specific item. 18 19 * ble_dev : Run only the BLE program. 20 * coex_dev: Run BLE and Wi-Fi program. 21 * wifi_dev: Run only the Wi-Fi program. 22 23``Note: If you want better performance in BLE and WiFi coexistence, you should use a development board with PSRAM that could run a coexistence program. Such as ESP32_LyraT, ESP32-WROVER-B and etc.`` 24 25* The following structure shows the parameters you need to configure. And usually, there are two methods for configuration, i.e. configuring during initialization or configuring with the command `env`. 26 27```c 28coex_test_env_t test_env = { 29#if defined(CONFIG_EXAMPLE_MANAUL) 30 .ap_ssid = CONFIG_EXAMPLE_WIFI_SSID, 31 .ap_password = CONFIG_EXAMPLE_WIFI_PASSWORD, 32#endif 33#if defined(CONFIG_EXAMPLE_COEX_ROLE) 34 .ap_ssid = CONFIG_EXAMPLE_WIFI_SSID, 35 .ap_password = CONFIG_EXAMPLE_WIFI_PASSWORD, 36#endif 37 .test_port = "8080", 38 .server_ip = "192.168.3.32", 39 .duration = "120000", 40 .is_start = false, 41}; 42``` 43 44 45## Run Test Case Manually 46Configure to Manual Mode via `Example Configuration --->run mode (manual) ` 47 48The meaning of the numeric argument of the command `run_tc` is as follows: 49 50| id | case name | description | 51|:-:|:-|:-| 52| 0 | wifi_tcp_tx_throughput| Test the case of Wi-Fi tcp tx, which will create a tcp client that will continuously send data to the tcp server. | 53| 1 |wifi_tcp_rx_throughput| Test the case of Wi-Fi tcp rx, which will create a tcp server that will continuously receive data from the tcp client. | 54| 2 | ble_adv | Test the case of BLE advertising. | 55| 3 | ble_scan| Test the case of BLE Scan.| 56 57 58### Case 1: tcp tx + scan 591. wifi_dev: run_tc -w 1 602. coex_dev: env -s -k server_ip -v 192.168.3.34 run_tc -w 0 -b 3 613. ble_dev : run_tc -b 2 62 63 64### Case 2: tcp rx + scan 651. coex_dev: run_tc -w 1 -b 3 662. wifi_dev: env -s -k server_ip -v 192.168.3.34 run_tc -w 0 673. ble_dev : run_tc -b 2 68 69### Case 3: tcp tx + adv 701. wifi_dev: run_tc -w 1 712. coex_dev: env -s -k server_ip -v 192.168.3.13 run_tc -w 0 -b 2 723. ble_dev : run_tc -b 3 73 74 75### Case 4: tcp rx + adv 761. coex_dev: run_tc -w 1 -b 2 772. wifi_dev: env -s -k server_ip -v 192.168.3.34 run_tc -w 0 783. ble_dev : run_tc -b 3 79 80## Run Test Case By Automation 81Configure to Automatic Mode via `Example Configuration --->run mode (auto) ` 82 83### Coexistence device configuration 841. Select a development board as coexistence role by `Example Configuration --->select role (run device as coex role) ` 852. Select a test case by `Example Configuration --->select case `. 86* There are four types of cases: 87 * TCP TX and BLE ADV: The TCP client will be created on the coexistence device, and bluetooth will start advertising when the Wi-Fi is running tx throughput program. 88 * TCP RX and BLE ADV: The TCP server will be created on the coexistence device, and bluetooth will start advertising when the Wi-Fi is running rx throughput program. 89 * TCP TX and BLE SCAN: The TCP client will be created on the coexistence device, and bluetooth will start scanning when the Wi-Fi is running tx throughput program. 90 * TCP RX and BLE SCAN: The TCP server will be created on the coexistence device, and bluetooth will start scanning when the Wi-Fi is running rx throughput program. 91 92### Bluetooth device configuration 931. Select a development board as bluetooth role by `select role (run device as bluetooth role) ` 94 95### Wi-Fi device configuration 961. Select a development board as bluetooth role by `select role (run device as wifi role) ` 97 98 99## Coexistence Configuration 100In theory, the performance of BLE and Wi-Fi coexistence will drop to half of the performance in BLE Only mode or Wi-Fi Only mode. 101 102* ESP32 working frequency: 103 * Component config ---> ESP32-specific ---> CPU frequency (240 MHz) 104 105* ESP32 external PSRAM 106 * Component config ---> ESP32-specific ---> Support for external, SPI-connected RAM 107 * Devices that do not support PSRAM cannot open this option! 108 109* ESP32 coexistence mode 110 * Component config ---> Wi-Fi ---> WiFi/Bluetooth coexistence performance preference (Balance) 111