From 22ff1b8c41114a8781e0cb784a749b3beb0cd06f Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 20 Jun 2024 14:29:01 +0300 Subject: [PATCH 1/3] feat(net): Deprecate old WiFi APIs Deprecates WiFiClient, WiFiServer, WiFiUdp and WiFiClientSecure --- Kconfig.projbuild | 4 ++-- libraries/NetworkClientSecure/src/WiFiClientSecure.h | 1 + .../WebServer/examples/UploadHugeFile/UploadHugeFile.ino | 1 - libraries/WiFi/src/WiFi.h | 6 +++--- libraries/WiFi/src/WiFiClient.h | 1 + libraries/WiFi/src/WiFiServer.h | 1 + libraries/WiFi/src/WiFiUdp.h | 1 + 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Kconfig.projbuild b/Kconfig.projbuild index c1a9f4cb7bd..2085a11ea7d 100644 --- a/Kconfig.projbuild +++ b/Kconfig.projbuild @@ -355,7 +355,7 @@ config ARDUINO_SELECTIVE_ESPmDNS config ARDUINO_SELECTIVE_HTTPClient bool "Enable HTTPClient" depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Network - select ARDUINO_SELECTIVE_WiFiClientSecure + select ARDUINO_SELECTIVE_NetworkClientSecure default y config ARDUINO_SELECTIVE_NetBIOS @@ -375,7 +375,7 @@ config ARDUINO_SELECTIVE_WiFi default y config ARDUINO_SELECTIVE_NetworkClientSecure - bool "Enable WiFiClientSecure" + bool "Enable NetworkClientSecure" depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Network default y diff --git a/libraries/NetworkClientSecure/src/WiFiClientSecure.h b/libraries/NetworkClientSecure/src/WiFiClientSecure.h index b4d6962fb35..0d29a21ff37 100644 --- a/libraries/NetworkClientSecure/src/WiFiClientSecure.h +++ b/libraries/NetworkClientSecure/src/WiFiClientSecure.h @@ -1,3 +1,4 @@ #pragma once +#warning WiFiClientSecure has been deprecated, please use NetworkClientSecure instead. #include "NetworkClientSecure.h" #define WiFiClientSecure NetworkClientSecure diff --git a/libraries/WebServer/examples/UploadHugeFile/UploadHugeFile.ino b/libraries/WebServer/examples/UploadHugeFile/UploadHugeFile.ino index 030ac09d129..54c94ed61d8 100644 --- a/libraries/WebServer/examples/UploadHugeFile/UploadHugeFile.ino +++ b/libraries/WebServer/examples/UploadHugeFile/UploadHugeFile.ino @@ -1,5 +1,4 @@ #include -#include #include #include #include diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h index a823dabd864..3ef1617dceb 100644 --- a/libraries/WiFi/src/WiFi.h +++ b/libraries/WiFi/src/WiFi.h @@ -35,9 +35,9 @@ #include "WiFiScan.h" #include "WiFiGeneric.h" -#include "WiFiClient.h" -#include "WiFiServer.h" -#include "WiFiUdp.h" +#include "NetworkClient.h" +#include "NetworkServer.h" +#include "NetworkUdp.h" class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass { private: diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h index 30729e27923..1e8838b71e2 100644 --- a/libraries/WiFi/src/WiFiClient.h +++ b/libraries/WiFi/src/WiFiClient.h @@ -1,3 +1,4 @@ #pragma once +#warning WiFiClient has been deprecated, please use NetworkClient instead. #include "NetworkClient.h" #define WiFiClient NetworkClient diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index 39d984486cf..c34bf81592d 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -1,3 +1,4 @@ #pragma once +#warning WiFiServer has been deprecated, please use NetworkServer instead. #include "NetworkServer.h" #define WiFiServer NetworkServer diff --git a/libraries/WiFi/src/WiFiUdp.h b/libraries/WiFi/src/WiFiUdp.h index b0b11570fa6..b47f090a2b5 100644 --- a/libraries/WiFi/src/WiFiUdp.h +++ b/libraries/WiFi/src/WiFiUdp.h @@ -1,3 +1,4 @@ #pragma once +#warning WiFiUDP has been deprecated, please use NetworkUDP instead. #include "NetworkUdp.h" #define WiFiUDP NetworkUDP From 8f13096e4f052caae4f5b1cf4e7de95e5cbd55e9 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 20 Jun 2024 14:55:40 +0300 Subject: [PATCH 2/3] fix(net): add defines to WiFi.h Defines are added to not cause deprecation warnings. Will be removed in the future --- libraries/WiFi/src/WiFi.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h index 3ef1617dceb..081c3e89617 100644 --- a/libraries/WiFi/src/WiFi.h +++ b/libraries/WiFi/src/WiFi.h @@ -38,6 +38,11 @@ #include "NetworkClient.h" #include "NetworkServer.h" #include "NetworkUdp.h" +//defines are added here not to cause warnings +//to be removed in the future +#define WiFiClient NetworkClient +#define WiFiServer NetworkServer +#define WiFiUDP NetworkUDP class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass { private: From d9b88b615216fb3c74237785fd13b83701dd2640 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Thu, 20 Jun 2024 15:38:32 +0300 Subject: [PATCH 3/3] fix(net): Use typedefs instead to help with forward declarations Defines do not allow forward declarations --- libraries/NetworkClientSecure/src/WiFiClientSecure.h | 3 +-- libraries/WiFi/src/WiFi.h | 11 +++-------- libraries/WiFi/src/WiFiClient.h | 3 +-- libraries/WiFi/src/WiFiServer.h | 3 +-- libraries/WiFi/src/WiFiUdp.h | 3 +-- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/libraries/NetworkClientSecure/src/WiFiClientSecure.h b/libraries/NetworkClientSecure/src/WiFiClientSecure.h index 0d29a21ff37..56e7f28aa52 100644 --- a/libraries/NetworkClientSecure/src/WiFiClientSecure.h +++ b/libraries/NetworkClientSecure/src/WiFiClientSecure.h @@ -1,4 +1,3 @@ #pragma once -#warning WiFiClientSecure has been deprecated, please use NetworkClientSecure instead. #include "NetworkClientSecure.h" -#define WiFiClientSecure NetworkClientSecure +typedef NetworkClientSecure WiFiClientSecure; diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h index 081c3e89617..a823dabd864 100644 --- a/libraries/WiFi/src/WiFi.h +++ b/libraries/WiFi/src/WiFi.h @@ -35,14 +35,9 @@ #include "WiFiScan.h" #include "WiFiGeneric.h" -#include "NetworkClient.h" -#include "NetworkServer.h" -#include "NetworkUdp.h" -//defines are added here not to cause warnings -//to be removed in the future -#define WiFiClient NetworkClient -#define WiFiServer NetworkServer -#define WiFiUDP NetworkUDP +#include "WiFiClient.h" +#include "WiFiServer.h" +#include "WiFiUdp.h" class WiFiClass : public WiFiGenericClass, public WiFiSTAClass, public WiFiScanClass, public WiFiAPClass { private: diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h index 1e8838b71e2..4add805ca09 100644 --- a/libraries/WiFi/src/WiFiClient.h +++ b/libraries/WiFi/src/WiFiClient.h @@ -1,4 +1,3 @@ #pragma once -#warning WiFiClient has been deprecated, please use NetworkClient instead. #include "NetworkClient.h" -#define WiFiClient NetworkClient +typedef NetworkClient WiFiClient; diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index c34bf81592d..850bd98d9c8 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -1,4 +1,3 @@ #pragma once -#warning WiFiServer has been deprecated, please use NetworkServer instead. #include "NetworkServer.h" -#define WiFiServer NetworkServer +typedef NetworkServer WiFiServer; diff --git a/libraries/WiFi/src/WiFiUdp.h b/libraries/WiFi/src/WiFiUdp.h index b47f090a2b5..420d29b634b 100644 --- a/libraries/WiFi/src/WiFiUdp.h +++ b/libraries/WiFi/src/WiFiUdp.h @@ -1,4 +1,3 @@ #pragma once -#warning WiFiUDP has been deprecated, please use NetworkUDP instead. #include "NetworkUdp.h" -#define WiFiUDP NetworkUDP +typedef NetworkUDP WiFiUDP;