Skip to content

Commit c9f2741

Browse files
authored
Fix NO_GLOBAL_INSTANCES for Serial ports (#8184)
1 parent 09c4e33 commit c9f2741

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

cores/esp8266/HardwareSerial.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535

3636
// SerialEvent functions are weak, so when the user doesn't define them,
3737
// the linker just sets their address to 0 (which is checked below).
38-
// The Serialx_available is just a wrapper around Serialx.available(),
39-
// but we can refer to it weakly so we don't pull in the entire
40-
// HardwareSerial instance if the user doesn't also refer to it.
4138
void serialEvent() __attribute__((weak));
4239

4340
HardwareSerial::HardwareSerial(int uart_nr)

cores/esp8266/HardwareSerial.h

+4
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,12 @@ class HardwareSerial: public Stream
233233
size_t _rx_size;
234234
};
235235

236+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
236237
extern HardwareSerial Serial;
238+
#endif
239+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL1)
237240
extern HardwareSerial Serial1;
241+
#endif
238242

239243
extern void serialEventRun(void) __attribute__((weak));
240244

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,10 @@ bool HTTPClient::connect(void)
849849
{
850850
if(_reuse && _canReuse && connected()) {
851851
DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, reusing connection\n");
852+
853+
#if defined(NO_GLOBAL_INSTANCES) || defined(NO_GLOBAL_STREAMDEV)
854+
StreamNull devnull;
855+
#endif
852856
_client->sendAvailable(devnull); // clear _client's output (all of it, no timeout)
853857
return true;
854858
}

0 commit comments

Comments
 (0)