19 #ifndef UUID_TELNET_H_
20 #define UUID_TELNET_H_
23 #ifdef ARDUINO_ARCH_ESP8266
24 # include <ESP8266WiFi.h>
36 #include <uuid/console.h>
103 size_t write(uint8_t data)
override;
114 size_t write(
const uint8_t *buffer,
size_t size)
override;
125 void flush()
override;
128 static constexpr
const unsigned char NUL = 0;
129 static constexpr
const unsigned char BEL = 7;
130 static constexpr
const unsigned char BS = 8;
131 static constexpr
const unsigned char HT = 9;
132 static constexpr
const unsigned char LF = 10;
133 static constexpr
const unsigned char VT = 11;
134 static constexpr
const unsigned char FF = 12;
135 static constexpr
const unsigned char CR = 13;
136 static constexpr
const unsigned char SE = 240;
137 static constexpr
const unsigned char NOP = 241;
138 static constexpr
const unsigned char DM = 242;
139 static constexpr
const unsigned char BRK = 243;
140 static constexpr
const unsigned char IP = 244;
141 static constexpr
const unsigned char AO = 245;
142 static constexpr
const unsigned char AYT = 246;
143 static constexpr
const unsigned char EC = 247;
144 static constexpr
const unsigned char EL = 248;
145 static constexpr
const unsigned char GA = 249;
146 static constexpr
const unsigned char SB = 250;
147 static constexpr
const unsigned char WILL = 251;
148 static constexpr
const unsigned char WONT = 252;
149 static constexpr
const unsigned char DO = 253;
150 static constexpr
const unsigned char DONT = 254;
151 static constexpr
const unsigned char IAC = 255;
155 static constexpr
const unsigned char OPT_SGA = 3;
203 size_t raw_write(
const std::vector<unsigned char> &data);
214 size_t raw_write(
const uint8_t *buffer,
size_t size);
245 using shell_factory_function = std::function<std::shared_ptr<uuid::console::Shell>(Stream &stream,
const IPAddress &addr, uint16_t port)>;
255 TelnetService(std::shared_ptr<uuid::console::Commands> commands,
unsigned int context = 0,
unsigned int flags = 0);
266 TelnetService(uint16_t port, std::shared_ptr<uuid::console::Commands> commands,
unsigned int context = 0,
unsigned int flags = 0);
413 std::weak_ptr<uuid::console::Shell>
shell_;
unsigned long initial_idle_timeout() const
Get the initial idle timeout for new connections.
static constexpr const unsigned char HT
Logger instance used to make log messages.
static constexpr const unsigned char VT
static constexpr const unsigned char IAC
TelnetService(std::shared_ptr< uuid::console::Commands > commands, unsigned int context=0, unsigned int flags=0)
Create a new telnet service listening on the default port.
static uuid::log::Logger logger_
void close_all()
Close all connections.
int raw_read()
Read one byte directly from the available input.
static constexpr const unsigned char IP
void stop()
Stop listening for connections.
void start()
Start listening for connections on the configured port.
static constexpr const unsigned char OPT_SGA
unsigned long initial_idle_timeout_
static constexpr size_t MAX_CONNECTIONS
unsigned char previous_raw_in_
size_t raw_write(unsigned char data)
Write one byte directly to the output stream.
static constexpr const unsigned char NOP
unsigned long default_write_timeout() const
Get the default socket write timeout for new connections.
static constexpr const unsigned char LF
static constexpr const unsigned char WILL
static constexpr const unsigned char AYT
size_t write(uint8_t data) override
Write one byte to the output stream.
static constexpr const unsigned char DM
size_t maximum_connections_
static constexpr const unsigned char CR
Provides access to a console shell as a telnet server.
std::list< Connection > connections_
static constexpr unsigned long DEFAULT_IDLE_TIMEOUT
Stream wrapper that performs telnet protocol handling, option negotiation and output buffering.
static constexpr const unsigned char SB
unsigned char previous_in_
static constexpr uint16_t DEFAULT_PORT
static constexpr const unsigned char FF
static constexpr const unsigned char BS
size_t maximum_connections() const
Get the maximum number of concurrent open connections.
static constexpr const unsigned char DONT
int available() override
Check for available input.
static constexpr const unsigned char GA
int read() override
Read one byte from the available input.
void buffer_flush()
Flush output stream buffer.
static constexpr const unsigned char BEL
TelnetStream(WiFiClient &client)
Create a new telnet stream wrapper.
static constexpr const unsigned char BRK
static constexpr const unsigned char WONT
unsigned long write_timeout_
static constexpr const unsigned char NUL
static constexpr const unsigned char EC
std::vector< char > output_buffer_
std::function< std::shared_ptr< uuid::console::Shell >(Stream &stream, const IPAddress &addr, uint16_t port)> shell_factory_function
Function to handle the creation of a shell.
static constexpr const unsigned char OPT_ECHO
static constexpr const unsigned char OPT_BINARY
void flush() override
Does nothing.
int raw_available()
Directly check for available input.
bool stop()
Stop the shell.
static constexpr unsigned long DEFAULT_WRITE_TIMEOUT
int peek() override
Read one byte from the available input without advancing to the next one.
static constexpr const size_t BUFFER_SIZE
shell_factory_function shell_factory_
unsigned char previous_out_
static constexpr const unsigned char DO
static constexpr const unsigned char AO
static constexpr const unsigned char SE
static constexpr const unsigned char EL
std::weak_ptr< uuid::console::Shell > shell_
void start()
Perform initial negotiation.
Connection(shell_factory_function &shell_factory, WiFiClient &&client, unsigned long idle_timeout, unsigned long write_timeout)
Create a telnet connection shell.
void loop()
Accept new connections.
bool loop()
Stop the shell if the client is not connected.