Skip to content

Commit

Permalink
Add support WiFiClientSecure TCP KeepAlive (#8940)
Browse files Browse the repository at this point in the history
* Add support WiFiClientSecure TCP KeepAlive
* Make TCP keepalive and related functions virtual.
* Make TCP keepalive and related functions override.

Fixes #8939
  • Loading branch information
mobizt authored Jun 11, 2023
1 parent 57fa6cd commit e05656b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libraries/ESP8266WiFi/src/WiFiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ class WiFiClient : public Client, public SList<WiFiClient> {
static void stopAll();
static void stopAllExcept(WiFiClient * c);

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);
bool isKeepAliveEnabled () const;
uint16_t getKeepAliveIdle () const;
uint16_t getKeepAliveInterval () const;
uint8_t getKeepAliveCount () const;
void disableKeepAlive () { keepAlive(0, 0, 0); }
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);
virtual bool isKeepAliveEnabled () const;
virtual uint16_t getKeepAliveIdle () const;
virtual uint16_t getKeepAliveInterval () const;
virtual uint8_t getKeepAliveCount () const;
virtual void disableKeepAlive () { keepAlive(0, 0, 0); }

// default NoDelay=False (Nagle=True=!NoDelay)
// Nagle is for shortly delaying outgoing data, to send less/bigger packets
Expand Down
15 changes: 15 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,21 @@ class WiFiClientSecure : public WiFiClient {

// consume bytes after use (see peekBuffer)
virtual void peekConsume (size_t consume) override { return _ctx->peekConsume(consume); }

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
{
_ctx->keepAlive(idle_sec, intv_sec, count);
}

bool isKeepAliveEnabled() const override { return _ctx->isKeepAliveEnabled(); };

uint16_t getKeepAliveIdle() const override { return _ctx->getKeepAliveIdle(); };

uint16_t getKeepAliveInterval() const override { return _ctx->getKeepAliveInterval(); };

uint8_t getKeepAliveCount() const override { return _ctx->getKeepAliveCount(); };

void disableKeepAlive() override { _ctx->disableKeepAlive(); };

private:
std::shared_ptr<WiFiClientSecureCtx> _ctx;
Expand Down

0 comments on commit e05656b

Please sign in to comment.