Skip to content

Commit

Permalink
Telnet: (optional) buffered output for AsyncTcp server (#1929)
Browse files Browse the repository at this point in the history
* telnet: buffered output for async server

* telnet: make async buffer an option

* just use the queue containers directly

* try with simpler list

* exhaust buffers as much as possible in a single try

* don't forget to destroy the client object

* naming

* kill the connection earlier

* fix merge issues
  • Loading branch information
mcspr authored Oct 9, 2019
1 parent f3b3556 commit 1949bc8
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 95 deletions.
2 changes: 2 additions & 0 deletions code/espurna/config/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/

#include <core_version.h>

#ifdef USE_CUSTOM_H
#include "custom.h"
#endif
Expand Down
5 changes: 5 additions & 0 deletions code/espurna/config/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@
#undef MDNS_CLIENT_SUPPORT
#define MDNS_CLIENT_SUPPORT 0 // default resolver already handles this
#endif

#if not defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef TELNET_SERVER_ASYNC_BUFFERED
#define TELNET_SERVER_ASYNC_BUFFERED 1 // enable buffered telnet by default on latest Cores
#endif
5 changes: 5 additions & 0 deletions code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
#define TELNET_SERVER TELNET_SERVER_ASYNC // Can be either TELNET_SERVER_ASYNC (using ESPAsyncTCP) or TELNET_SERVER_WIFISERVER (using WiFiServer)
#endif

#ifndef TELNET_SERVER_ASYNC_BUFFERED
#define TELNET_SERVER_ASYNC_BUFFERED 0 // Enable buffered output for telnet server (+1Kb)
// Helps to avoid lost data with lwip2 TCP_MSS=536 option
#endif

// Enable this flag to add support for reverse telnet (+800 bytes)
// This is useful to telnet to a device behind a NAT or firewall
// To use this feature, start a listen server on a publicly reachable host with e.g. "ncat -vlp <port>" and use the MQTT reverse telnet command to connect
Expand Down
7 changes: 6 additions & 1 deletion code/espurna/config/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <functional>
#include <vector>
#include <memory>
#include <core_version.h>

extern "C" {
#include "user_interface.h"
Expand Down Expand Up @@ -32,6 +31,12 @@ extern "C" {
#include <lwip/init.h> // LWIP_VERSION_MAJOR
}

// ref: https://github.com/me-no-dev/ESPAsyncTCP/pull/115/files#diff-e2e636049095cc1ff920c1bfabf6dcacR8
// This is missing with Core 2.3.0 and is sometimes missing from the build flags. Assume HIGH_BANDWIDTH version.
#ifndef TCP_MSS
#define TCP_MSS (1460)
#endif

uint32_t systemResetReason();
uint8_t systemStabilityCounter();
void systemStabilityCounter(uint8_t);
Expand Down
Loading

0 comments on commit 1949bc8

Please sign in to comment.