Arduino WiFi AP API coexistence with esp-matter ConnectivityManager Implementation (original) (raw)

Board

ESP32-S3-DevKitC-1-N8R2

Device Description

.

Hardware Configuration

..

Version

v3.0.4

IDE Name

PlatformIO

Operating System

Windows 11

Flash frequency

80MHz

PSRAM enabled

yes

Upload speed

.

Description

I'm building a custom project which coexists esp-matter and Arduino in one project.

Such that the WiFi management is went through Arduino library (WiFi), and to inform CHIP's core that the application controls the WiFi. through:

auto &connMgr = chip::DeviceLayer::ConnectivityMgrImpl(); connMgr.SetWiFiStationMode(chip::DeviceLayer::ConnectivityManager::WiFiStationMode::kWiFiStationMode_ApplicationControlled); connMgr.SetWiFiAPMode(chip::DeviceLayer::ConnectivityManager::WiFiAPMode::kWiFiAPMode_ApplicationControlled);

All up to here is okay, but when engaging with WiFi.enableAP(true) API an error happens, which is a result of incompatibility with esp-matter's code regarding WiFi.

Both stacks initializes the netif`'s (Arduino)(esp-matter[1][2]). While there should be exactly one netif initialized, the program crashes in the second call of.

A suggestion of using the name keys, and the same pattern of code in esp-matter's start(), such that to ask for the netif by name, and if not existed to create it:

  if ((esp_netifs[ESP_IF_WIFI_AP] = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF")) == NULL) {
    esp_netifs[ESP_IF_WIFI_AP] = esp_netif_create_default_wifi_ap();
  }
  if ((esp_netifs[ESP_IF_WIFI_STA] = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")) == NULL) {
    esp_netifs[ESP_IF_WIFI_STA] = esp_netif_create_default_wifi_sta();
  }

Which worked well in my setup.

Sketch

Debug Message

E (4666) esp_netif_lwip: esp_netif_new_api: Failed to configure netif with config=0x3fccabf0 (config or if_key is NULL or duplicate key)

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide