From 26bfeccef6ddabc03f41502c941911199c7351f1 Mon Sep 17 00:00:00 2001 From: davidchatting-bot Date: Wed, 5 Aug 2026 16:56:27 +0000 Subject: [PATCH] Migrate ESP32 client-list code from removed tcpip_adapter_* to esp_netif_* Fixes #61. tcpip_adapter_get_sta_list()/tcpip_adapter_sta_list_t were removed from current ESP-IDF (the tcpip_adapter component was deprecated in favour of esp_netif years ago) - the arduino-esp32 core CI pulls no longer has them, so the ESP32 build failed outright: YoYoWiFiManager.h:183:5: error: 'tcpip_adapter_sta_list_t' does not name a type; did you mean 'tcpip_adapter_if_t'? esp_netif_get_sta_list()/esp_netif_sta_list_t is ESP-IDF's documented 1:1 replacement - same field shape (.num, .sta[].mac, .sta[].ip), just under the esp_netif_* namespace, so this is a straight migration rather than a redesign. ESP8266 is untouched and unaffected: it never used real ESP-IDF tcpip_adapter types in the first place - wifi_sta.h is this library's own hand-rolled shim providing tcpip_adapter_sta_info_t/ tcpip_adapter_sta_list_t independently of ESP-IDF, only compiled into the ESP8266 build. Also removed three now-dead tcpip_adapter_sta_info_t local variable declarations (getPeerN(), countPeers(), getClientsAsJson()) that only existed to hold a copy of an adapter_sta_list.sta[] element - replaced the two that were actually used with `auto` so they pick up whichever platform's element type applies, and removed the one in getClientsAsJson() outright since it was already unused dead code before this change. Not hardware/toolchain-tested here (no ESP32 SDK available in this environment - not enough disk space for the full arduino-esp32 toolchain) - based on ESP-IDF's documented tcpip_adapter -> esp_netif migration path. Relying on CI to confirm. Co-Authored-By: Claude Sonnet 5 --- src/YoYoWiFiManager.cpp | 9 +++------ src/YoYoWiFiManager.h | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/YoYoWiFiManager.cpp b/src/YoYoWiFiManager.cpp index e17ae49..df83310 100644 --- a/src/YoYoWiFiManager.cpp +++ b/src/YoYoWiFiManager.cpp @@ -1274,11 +1274,10 @@ bool YoYoWiFiManager::getPeerN(int n, IPAddress *ipAddress, uint8_t *macAddress) //TODO: implement break; case YY_MODE_PEER_SERVER: - tcpip_adapter_sta_info_t station; int clientCount = countClients(); int peerCount = 0; for(int i = 0; i < clientCount && !success; ++i) { - station = adapter_sta_list.sta[i]; + auto station = adapter_sta_list.sta[i]; if(isEspressif(station.mac)) { success = (peerCount == n); if(success) { @@ -1326,10 +1325,9 @@ int YoYoWiFiManager::countPeers() { if(currentStatus == YY_CONNECTED_PEER_CLIENT) count = 1; //is connected to the server break; case YY_MODE_PEER_SERVER: - tcpip_adapter_sta_info_t station; int clientCount = countClients(); for(int n = 0; n < clientCount; ++n) { - station = adapter_sta_list.sta[n]; + auto station = adapter_sta_list.sta[n]; if(isEspressif(station.mac)) count++; } break; @@ -1361,7 +1359,6 @@ void YoYoWiFiManager::getClientsAsJson(JsonDocument& jsonDoc) { if(currentMode == YY_MODE_PEER_SERVER) { char *ipAddress = new char[17]; char *macAddress = new char[18]; - tcpip_adapter_sta_info_t station; int clientCount = updateClientList(); for(int n = 0; n < clientCount; ++n) { @@ -1410,7 +1407,7 @@ int YoYoWiFiManager::updateClientList() { #elif defined(ESP32) esp_wifi_ap_get_sta_list(&wifi_sta_list); - tcpip_adapter_get_sta_list(&wifi_sta_list, &adapter_sta_list); + esp_netif_get_sta_list(&wifi_sta_list, &adapter_sta_list); //tcpip_adapter_get_sta_list() was removed from current ESP-IDF - this is its documented esp_netif replacement count = adapter_sta_list.num; #endif } diff --git a/src/YoYoWiFiManager.h b/src/YoYoWiFiManager.h index f0c6e21..0a34a47 100644 --- a/src/YoYoWiFiManager.h +++ b/src/YoYoWiFiManager.h @@ -17,6 +17,7 @@ #include #include #include + #include //esp_netif_get_sta_list()/esp_netif_sta_list_t - replaces the removed tcpip_adapter_get_sta_list()/tcpip_adapter_sta_list_t #include #include #endif @@ -179,8 +180,10 @@ class YoYoWiFiManager : public AsyncWebHandler { #if defined(ESP32) wifi_sta_list_t wifi_sta_list; + esp_netif_sta_list_t adapter_sta_list; + #elif defined(ESP8266) + tcpip_adapter_sta_list_t adapter_sta_list; #endif - tcpip_adapter_sta_list_t adapter_sta_list; int POST(const char *server, const char *path, const char *payload, char *contentType, char *response = NULL); int GET(const char *server, const char *path, char *response);