From ccccd4e6311875747f21a8f0b1c4b2c2c9c85655 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sat, 26 Jun 2021 22:27:08 -0300 Subject: [PATCH 1/9] Create devnull static if needed --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 4400414e65..00f338203d 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -847,6 +847,10 @@ bool HTTPClient::hasHeader(const char* name) */ bool HTTPClient::connect(void) { + #if defined(NO_GLOBAL_INSTANCES) + StreamNull devnull; + #endif + if(_reuse && _canReuse && connected()) { DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) From 9571f54e70ab51c9bc9b609944298146574c8ec8 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sat, 26 Jun 2021 22:33:50 -0300 Subject: [PATCH 2/9] Move location of stack variable --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 00f338203d..b72af51516 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -847,12 +847,12 @@ bool HTTPClient::hasHeader(const char* name) */ bool HTTPClient::connect(void) { - #if defined(NO_GLOBAL_INSTANCES) - StreamNull devnull; - #endif - if(_reuse && _canReuse && connected()) { DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); + + #if defined(NO_GLOBAL_INSTANCES) + StreamNull devnull; + #endif _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) return true; } From 7b594b0af7da3eb472097fe335644ada05891728 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sat, 26 Jun 2021 22:34:14 -0300 Subject: [PATCH 3/9] Fix formatting --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index b72af51516..7a74e41b43 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -850,9 +850,9 @@ bool HTTPClient::connect(void) if(_reuse && _canReuse && connected()) { DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); - #if defined(NO_GLOBAL_INSTANCES) +#if defined(NO_GLOBAL_INSTANCES) StreamNull devnull; - #endif +#endif _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) return true; } From aa40a10ae5bc3a750f9c6b959c85b7b25d55c437 Mon Sep 17 00:00:00 2001 From: Paulo Date: Sat, 26 Jun 2021 23:11:22 -0300 Subject: [PATCH 4/9] Make variable static --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 7a74e41b43..32af79055f 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -851,7 +851,7 @@ bool HTTPClient::connect(void) DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); #if defined(NO_GLOBAL_INSTANCES) - StreamNull devnull; + static StreamNull devnull; #endif _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) return true; From 6efc0e9d6a6740628518c9039f4aa19849efa60d Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 27 Jun 2021 01:51:45 -0300 Subject: [PATCH 5/9] Revert static addition, its optional and 1 byte --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 32af79055f..7a74e41b43 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -851,7 +851,7 @@ bool HTTPClient::connect(void) DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); #if defined(NO_GLOBAL_INSTANCES) - static StreamNull devnull; + StreamNull devnull; #endif _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) return true; From faa662e338a1c98b05ed3854dfe47d41af7a40cc Mon Sep 17 00:00:00 2001 From: Paulo Date: Sun, 4 Jul 2021 14:37:18 -0300 Subject: [PATCH 6/9] Remove Serial definition if not needed --- cores/esp8266/HardwareSerial.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/esp8266/HardwareSerial.h b/cores/esp8266/HardwareSerial.h index bdccae5ea9..ea17f60efa 100644 --- a/cores/esp8266/HardwareSerial.h +++ b/cores/esp8266/HardwareSerial.h @@ -233,8 +233,12 @@ class HardwareSerial: public Stream size_t _rx_size; }; +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) extern HardwareSerial Serial; +#endif +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1) extern HardwareSerial Serial1; +#endif extern void serialEventRun(void) __attribute__((weak)); From 5456e095721a832feb04894d96e2550de41ee6f4 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 8 Jul 2021 17:47:34 -0300 Subject: [PATCH 7/9] Undo serial changes --- cores/esp8266/HardwareSerial.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cores/esp8266/HardwareSerial.h b/cores/esp8266/HardwareSerial.h index ea17f60efa..bdccae5ea9 100644 --- a/cores/esp8266/HardwareSerial.h +++ b/cores/esp8266/HardwareSerial.h @@ -233,12 +233,8 @@ class HardwareSerial: public Stream size_t _rx_size; }; -#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) extern HardwareSerial Serial; -#endif -#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1) extern HardwareSerial Serial1; -#endif extern void serialEventRun(void) __attribute__((weak)); From 34d4325eb400812455dfb27d8a3edf1547e3bd63 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 8 Jul 2021 20:19:11 -0300 Subject: [PATCH 8/9] Create streamdev even if specifically unset --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 7a74e41b43..c933b5c21f 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -850,7 +850,7 @@ bool HTTPClient::connect(void) if(_reuse && _canReuse && connected()) { DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n"); -#if defined(NO_GLOBAL_INSTANCES) +#if defined(NO_GLOBAL_INSTANCES) || defined(NO_GLOBAL_STREAMDEV) StreamNull devnull; #endif _client->sendAvailable(devnull); // clear _client's output (all of it, no timeout) From d07566b016018a1834d8a5745d830a9097a867bc Mon Sep 17 00:00:00 2001 From: Paulo Date: Fri, 9 Jul 2021 10:34:23 -0300 Subject: [PATCH 9/9] Remove Serial declaration if not defined --- cores/esp8266/HardwareSerial.cpp | 3 --- cores/esp8266/HardwareSerial.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cores/esp8266/HardwareSerial.cpp b/cores/esp8266/HardwareSerial.cpp index 4f09d26f40..88b47b33f3 100644 --- a/cores/esp8266/HardwareSerial.cpp +++ b/cores/esp8266/HardwareSerial.cpp @@ -35,9 +35,6 @@ // SerialEvent functions are weak, so when the user doesn't define them, // the linker just sets their address to 0 (which is checked below). -// The Serialx_available is just a wrapper around Serialx.available(), -// but we can refer to it weakly so we don't pull in the entire -// HardwareSerial instance if the user doesn't also refer to it. void serialEvent() __attribute__((weak)); HardwareSerial::HardwareSerial(int uart_nr) diff --git a/cores/esp8266/HardwareSerial.h b/cores/esp8266/HardwareSerial.h index bdccae5ea9..ea17f60efa 100644 --- a/cores/esp8266/HardwareSerial.h +++ b/cores/esp8266/HardwareSerial.h @@ -233,8 +233,12 @@ class HardwareSerial: public Stream size_t _rx_size; }; +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) extern HardwareSerial Serial; +#endif +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1) extern HardwareSerial Serial1; +#endif extern void serialEventRun(void) __attribute__((weak));