TinyTelnetServer
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
TinyTelnetServer< Server, Client > Class Template Reference

A simple telnet server for Arduino. Call the addCommand method to register your commands. More...

#include <TinyTelnetServer.h>

Inheritance diagram for TinyTelnetServer< Server, Client >:
TinySerialServer

Public Member Functions

 TinyTelnetServer (Server &server)
 Default Constructor that expects a class Server, class Client as template parameters.
 
virtual void addCommand (const char *cmd, bool(*cb)(telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &out, TinySerialServer *self), const char *parameter_help="")
 Add a new command.
 
bool begin () override
 Start the server.
 
int count ()
 provide number of clients
 
int countActive ()
 provide number of active clients
 
void end () override
 
void * getReference ()
 Returns the reference object which can be used in the callback.
 
bool processCommand () override
 proccess the next command: call in loop()
 
void setErrorCallback (bool(*cb)(telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &out, TinySerialServer *self))
 Defines an error callback.
 
void setMaxInputBufferSize (int size)
 Defines the input buffer size: default is MAX_INPUT_BUFFER_SIZE (256)
 
void setReference (void *reference)
 Defines a reference object which can be used in the callback.
 
void setStream (Stream &stream)
 Defines the stream to be used.
 

Static Public Member Functions

static bool cmd_bye (telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &out, TinySerialServer *self)
 close callback: you can register it with addCommand under different names
 

Protected Member Functions

void addClient (Client &client)
 Adds a new client to the list of clients.
 
void connectClients ()
 Acccepts new clients.
 
const char * controlStr (int cmd)
 Converts the telnet command to a string.
 
CommandfindCommand (const char *cmd)
 Finds a command by name.
 
bool parseCommand (const char *input, telnet::Str &cmd, telnet::Vector< telnet::Str > &parameters)
 
int parseTelnetCommands (char *cmds, int len, Print &client)
 Parse and process the telnet commands.
 
bool processCommand (const char *input, Client &result)
 
virtual bool processCommand (const char *input, Print &result)
 Processes the command and returns the result output via Client.
 
bool processCommand (telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &result)
 process the command
 
virtual bool processCommandUndefined (telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &result)
 Handle undefined commands.
 
void processTelnetCommand (char *cmd, int len, Print &client)
 Process telnet protocol command.
 
int readLine (Stream &in, char *str, int max)
 Reads a line delimited by '
' from the Stream.
 
void split (telnet::Str &str, telnet::Str &head, telnet::Str &tail, char sep=',')
 

Static Protected Member Functions

static bool cmd_help (telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &out, TinySerialServer *self)
 help callback
 

Protected Attributes

int active_clients = 0
 
telnet::Vector< Client > clients
 
telnet::Vector< Commandcommands
 
const char DO = 253
 
const char DONT = 254
 
bool(* error_callback )(telnet::Str &cmd, telnet::Vector< telnet::Str > parameters, Print &out, TinySerialServer *self) = nullptr
 
const char IAC = 255
 
bool is_active = false
 
const char LINEMODE = 34
 
int max_input_buffer_size = MAX_INPUT_BUFFER_SIZE
 
int no_connect_delay = NO_CONNECT_DELAY_MS
 
void * p_reference = nullptr
 
Server * p_server = nullptr
 
Stream * p_stream = nullptr
 
int port = 23
 
const char SB = 250
 
const char SE = 240
 
const char STATUS = 5
 
const char SUPPRESS_GA = 3
 
const char WILL = 251
 
const char WONT = 252
 

Detailed Description

template<class Server, class Client>
class telnet::TinyTelnetServer< Server, Client >

A simple telnet server for Arduino. Call the addCommand method to register your commands.

Author
Phil Schatzmann

Member Function Documentation

◆ end()

void end ( )
inlineoverridevirtual

End the processing: warning: this method does not call end on the server because this is not available for all server implementations

Reimplemented from TinySerialServer.

◆ parseCommand()

bool parseCommand ( const char *  input,
telnet::Str cmd,
telnet::Vector< telnet::Str > &  parameters 
)
inlineprotectedinherited

Parses the command and parameters: syntax: cmd(param1,param2,...) or cmd par1 par2 ...


The documentation for this class was generated from the following file: