From ebd381eab92a889b27da4aecff074c9fc57bfbd7 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 4 Mar 2022 20:45:51 -0300 Subject: [PATCH 1/3] Fixes Arduino IPAddress object INADDR_NONE in Azure IoT, Matter (connectedhomeip) and AWS projects --- cores/esp32/IPAddress.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cores/esp32/IPAddress.h b/cores/esp32/IPAddress.h index aa1d10cee29..a07cb19945f 100644 --- a/cores/esp32/IPAddress.h +++ b/cores/esp32/IPAddress.h @@ -91,6 +91,9 @@ class IPAddress: public Printable friend class DNSClient; }; +// avoids some conflict in some AWS, Microsoft Azure and MATTER projects +#ifndef INADDR_NONE const IPAddress INADDR_NONE(0, 0, 0, 0); +#endif #endif From 3512ad3e2894350e19179c96b6218efb94fbf8c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Thu, 28 Apr 2022 22:44:31 -0300 Subject: [PATCH 2/3] Fixes INADDR_NONE in all networking Arduino Libs --- cores/esp32/IPAddress.cpp | 3 +++ cores/esp32/IPAddress.h | 9 +++------ libraries/AsyncUDP/src/AsyncUDP.h | 1 - libraries/WiFi/src/WiFiServer.h | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cores/esp32/IPAddress.cpp b/cores/esp32/IPAddress.cpp index cabfdf32d26..f2b9ef642bd 100644 --- a/cores/esp32/IPAddress.cpp +++ b/cores/esp32/IPAddress.cpp @@ -120,3 +120,6 @@ bool IPAddress::fromString(const char *address) _address.bytes[3] = acc; return true; } + +// declared one time - as external in IPAddress.h +IPAddress INADDR_NONE(0, 0, 0, 0); \ No newline at end of file diff --git a/cores/esp32/IPAddress.h b/cores/esp32/IPAddress.h index a07cb19945f..ff9e846408d 100644 --- a/cores/esp32/IPAddress.h +++ b/cores/esp32/IPAddress.h @@ -91,9 +91,6 @@ class IPAddress: public Printable friend class DNSClient; }; -// avoids some conflict in some AWS, Microsoft Azure and MATTER projects -#ifndef INADDR_NONE -const IPAddress INADDR_NONE(0, 0, 0, 0); -#endif - -#endif +// changed to extern because const declaration creates copies in BSS of INADDR_NONE for each CPP unit that includes it +extern IPAddress INADDR_NONE; +#endif \ No newline at end of file diff --git a/libraries/AsyncUDP/src/AsyncUDP.h b/libraries/AsyncUDP/src/AsyncUDP.h index 95e0b8c1358..be04c01ffaa 100644 --- a/libraries/AsyncUDP/src/AsyncUDP.h +++ b/libraries/AsyncUDP/src/AsyncUDP.h @@ -7,7 +7,6 @@ #include "Stream.h" #include extern "C" { -#include "lwip/ip_addr.h" #include "esp_netif.h" #include "freertos/queue.h" #include "freertos/semphr.h" diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index f5b7eaa7bf3..346986abad5 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -22,7 +22,6 @@ #include "Arduino.h" #include "Server.h" #include "WiFiClient.h" -#include "arpa/inet.h" #include "IPAddress.h" class WiFiServer : public Server { @@ -38,7 +37,8 @@ class WiFiServer : public Server { public: void listenOnLocalhost(){} - WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(INADDR_ANY),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { + // _addr(INADDR_ANY) is the same as _addr() ==> 0.0.0.0 + WiFiServer(uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { log_v("WiFiServer::WiFiServer(port=%d, ...)", port); } WiFiServer(const IPAddress& addr, uint16_t port=80, uint8_t max_clients=4):sockfd(-1),_accepted_sockfd(-1),_addr(addr),_port(port),_max_clients(max_clients),_listening(false),_noDelay(false) { From f2ad887216026a0c0072e0c6679fb9b43e6efc20 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Thu, 28 Apr 2022 23:12:20 -0300 Subject: [PATCH 3/3] fixes wifi_config.h for all SoCs --- cores/esp32/IPAddress.cpp | 2 +- cores/esp32/IPAddress.h | 2 +- .../wifi_provisioning/include/wifi_provisioning/wifi_config.h | 2 +- .../wifi_provisioning/include/wifi_provisioning/wifi_config.h | 2 +- .../wifi_provisioning/include/wifi_provisioning/wifi_config.h | 2 +- .../wifi_provisioning/include/wifi_provisioning/wifi_config.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cores/esp32/IPAddress.cpp b/cores/esp32/IPAddress.cpp index f2b9ef642bd..0575363f254 100644 --- a/cores/esp32/IPAddress.cpp +++ b/cores/esp32/IPAddress.cpp @@ -122,4 +122,4 @@ bool IPAddress::fromString(const char *address) } // declared one time - as external in IPAddress.h -IPAddress INADDR_NONE(0, 0, 0, 0); \ No newline at end of file +IPAddress INADDR_NONE(0, 0, 0, 0); diff --git a/cores/esp32/IPAddress.h b/cores/esp32/IPAddress.h index ff9e846408d..3bedd4f8749 100644 --- a/cores/esp32/IPAddress.h +++ b/cores/esp32/IPAddress.h @@ -93,4 +93,4 @@ class IPAddress: public Printable // changed to extern because const declaration creates copies in BSS of INADDR_NONE for each CPP unit that includes it extern IPAddress INADDR_NONE; -#endif \ No newline at end of file +#endif diff --git a/tools/sdk/esp32/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/tools/sdk/esp32/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h index 2fa64448d49..d477580fa99 100644 --- a/tools/sdk/esp32/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ b/tools/sdk/esp32/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h @@ -15,7 +15,7 @@ #ifndef _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h index 2fa64448d49..d477580fa99 100644 --- a/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ b/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h @@ -15,7 +15,7 @@ #ifndef _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32s2/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/tools/sdk/esp32s2/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h index 2fa64448d49..d477580fa99 100644 --- a/tools/sdk/esp32s2/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ b/tools/sdk/esp32s2/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h @@ -15,7 +15,7 @@ #ifndef _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_ -#include +#include #ifdef __cplusplus extern "C" { diff --git a/tools/sdk/esp32s3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/tools/sdk/esp32s3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h index 2fa64448d49..d477580fa99 100644 --- a/tools/sdk/esp32s3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ b/tools/sdk/esp32s3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h @@ -15,7 +15,7 @@ #ifndef _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_ -#include +#include #ifdef __cplusplus extern "C" {