Skip to content

Commit e05656b

Browse files
authored
Add support WiFiClientSecure TCP KeepAlive (#8940)
* Add support WiFiClientSecure TCP KeepAlive * Make TCP keepalive and related functions virtual. * Make TCP keepalive and related functions override. Fixes #8939
1 parent 57fa6cd commit e05656b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

libraries/ESP8266WiFi/src/WiFiClient.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ class WiFiClient : public Client, public SList<WiFiClient> {
107107
static void stopAll();
108108
static void stopAllExcept(WiFiClient * c);
109109

110-
void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT);
111-
bool isKeepAliveEnabled () const;
112-
uint16_t getKeepAliveIdle () const;
113-
uint16_t getKeepAliveInterval () const;
114-
uint8_t getKeepAliveCount () const;
115-
void disableKeepAlive () { keepAlive(0, 0, 0); }
110+
virtual void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT);
111+
virtual bool isKeepAliveEnabled () const;
112+
virtual uint16_t getKeepAliveIdle () const;
113+
virtual uint16_t getKeepAliveInterval () const;
114+
virtual uint8_t getKeepAliveCount () const;
115+
virtual void disableKeepAlive () { keepAlive(0, 0, 0); }
116116

117117
// default NoDelay=False (Nagle=True=!NoDelay)
118118
// Nagle is for shortly delaying outgoing data, to send less/bigger packets

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

+15
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,21 @@ class WiFiClientSecure : public WiFiClient {
357357

358358
// consume bytes after use (see peekBuffer)
359359
virtual void peekConsume (size_t consume) override { return _ctx->peekConsume(consume); }
360+
361+
void keepAlive(uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT) override
362+
{
363+
_ctx->keepAlive(idle_sec, intv_sec, count);
364+
}
365+
366+
bool isKeepAliveEnabled() const override { return _ctx->isKeepAliveEnabled(); };
367+
368+
uint16_t getKeepAliveIdle() const override { return _ctx->getKeepAliveIdle(); };
369+
370+
uint16_t getKeepAliveInterval() const override { return _ctx->getKeepAliveInterval(); };
371+
372+
uint8_t getKeepAliveCount() const override { return _ctx->getKeepAliveCount(); };
373+
374+
void disableKeepAlive() override { _ctx->disableKeepAlive(); };
360375

361376
private:
362377
std::shared_ptr<WiFiClientSecureCtx> _ctx;

0 commit comments

Comments
 (0)