Go to the documentation of this file.
31 #ifndef _ECHO_SERVER_H
32 #define _ECHO_SERVER_H
39 #ifndef ECHO_SERVER_SUPPORT
40 #define ECHO_SERVER_SUPPORT DISABLED
41 #elif (ECHO_SERVER_SUPPORT != ENABLED && ECHO_SERVER_SUPPORT != DISABLED)
42 #error ECHO_SERVER_SUPPORT parameter is not valid
46 #ifndef ECHO_SERVER_STACK_SIZE
47 #define ECHO_SERVER_STACK_SIZE 500
48 #elif (ECHO_SERVER_STACK_SIZE < 1)
49 #error ECHO_SERVER_STACK_SIZE parameter is not valid
53 #ifndef ECHO_SERVER_PRIORITY
54 #define ECHO_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
58 #ifndef ECHO_SERVER_TCP_SUPPORT
59 #define ECHO_SERVER_TCP_SUPPORT ENABLED
60 #elif (ECHO_SERVER_TCP_SUPPORT != ENABLED && ECHO_SERVER_TCP_SUPPORT != DISABLED)
61 #error ECHO_SERVER_TCP_SUPPORT parameter is not valid
65 #ifndef ECHO_SERVER_MAX_TCP_CONNECTIONS
66 #define ECHO_SERVER_MAX_TCP_CONNECTIONS 2
67 #elif (ECHO_SERVER_MAX_TCP_CONNECTIONS < 1)
68 #error ECHO_SERVER_MAX_TCP_CONNECTIONS parameter is not valid
72 #ifndef ECHO_SERVER_TCP_BUFFER_SIZE
73 #define ECHO_SERVER_TCP_BUFFER_SIZE 512
74 #elif (ECHO_SERVER_TCP_BUFFER_SIZE < 1)
75 #error ECHO_SERVER_TCP_BUFFER_SIZE parameter is not valid
79 #ifndef ECHO_SERVER_UDP_SUPPORT
80 #define ECHO_SERVER_UDP_SUPPORT ENABLED
81 #elif (ECHO_SERVER_UDP_SUPPORT != ENABLED && ECHO_SERVER_UDP_SUPPORT != DISABLED)
82 #error ECHO_SERVER_UDP_SUPPORT parameter is not valid
86 #ifndef ECHO_SERVER_UDP_BUFFER_SIZE
87 #define ECHO_SERVER_UDP_BUFFER_SIZE 1472
88 #elif (ECHO_SERVER_UDP_BUFFER_SIZE < 1)
89 #error ECHO_SERVER_UDP_BUFFER_SIZE parameter is not valid
93 #ifndef ECHO_SERVER_TIMEOUT
94 #define ECHO_SERVER_TIMEOUT 30000
95 #elif (ECHO_SERVER_TIMEOUT < 1)
96 #error ECHO_SERVER_TIMEOUT parameter is not valid
100 #ifndef ECHO_SERVER_TICK_INTERVAL
101 #define ECHO_SERVER_TICK_INTERVAL 1000
102 #elif (ECHO_SERVER_TICK_INTERVAL < 100)
103 #error ECHO_SERVER_TICK_INTERVAL parameter is not valid
107 #ifndef ECHO_SERVER_PRIVATE_CONTEXT
108 #define ECHO_SERVER_PRIVATE_CONTEXT
170 #if (ECHO_SERVER_TCP_SUPPORT == ENABLED)
174 #if (ECHO_SERVER_UDP_SUPPORT == ENABLED)
#define ECHO_SERVER_UDP_BUFFER_SIZE
error_t echoServerStart(EchoServerContext *context)
Start Echo server.
void echoServerTask(EchoServerContext *context)
Echo server task.
error_t echoServerInit(EchoServerContext *context, const EchoServerSettings *settings)
Initialize Echo server context.
OsTaskParameters task
Task parameters.
void echoServerDeinit(EchoServerContext *context)
Release Echo server context.
error_t echoServerStop(EchoServerContext *context)
Stop Echo server.
Socket * socket
Underlying TCP socket.
@ ECHO_TCP_CONNECTION_STATE_CLOSED
@ ECHO_TCP_CONNECTION_STATE_OPEN
NetInterface * interface
Underlying network interface.
EchoTcpConnectionState
TCP connection state.
size_t bufferPos
Current position in the buffer.
Socket * tcpSocket
Listening TCP socket.
#define ECHO_SERVER_PRIVATE_CONTEXT
#define ECHO_SERVER_MAX_TCP_CONNECTIONS
void echoServerGetDefaultSettings(EchoServerSettings *settings)
Initialize settings with default values.
bool_t running
Operational state of the Echo server.
uint16_t port
Echo server port number.
uint32_t systime_t
System time.
Socket * udpSocket
UDP socket.
#define ECHO_SERVER_TCP_BUFFER_SIZE
OsTaskId taskId
Task identifier.
OsEvent event
Event object used to poll the sockets.
thread_t * OsTaskId
Task identifier.
EchoServerSettings settings
User settings.
systime_t timestamp
Time stamp.
EchoTcpConnectionState state
Connection state.
size_t bufferLen
Length of the buffer, in bytes.
OsTaskParameters taskParams
Task parameters.