31 #include <FlowScanner.h>
38 static const uint8_t
CS_PIN = 10;
44 static const uint16_t ECHO_SERVER_TCP_PORT = 2500;
51 void start(uint16_t port)
59 ACTRACE(
"onConnectRequest");
66 write(F(
"How about a nice game of chess?\n"));
67 Serial.println(F(
"Client connected"));
74 Serial.println(F(
"Client disconnected"));
77 void onReceive(uint16_t len,
const byte* data)
79 ACTRACE(
"onReceive: %d bytes",len);
96 Serial.println(F(
"EtherDune Echo TCP server sample"));
97 Serial.print(F(
"Free RAM: ")); Serial.println(ACross::getFreeRam());
98 Serial.println(F(
"Press any key to start..."));
100 while (!Serial.available());
110 ACERROR(
"failed to start EtherDune");
112 ACINFO(
"waiting for link...");
116 ACINFO(
"link is up");
118 echoServer.start(ECHO_SERVER_TCP_PORT);
120 Serial.println(F(
"Echo server is up"));
121 Serial.print(F(
"Listening on TCP port "));
122 Serial.println(echoServer.localPort);
virtual void onConnectRequest()
Called when a listening socket receives a connection request.
#define IPAddress_P
helper macro to store an IP address in PROGMEM
uint16_t write(uint16_t len, const byte *data)
In the case of TCP, writes the given data buffer to the socket.
virtual void onConnect()
Fires when the socket connection is established.
static IPAddress_P gatewayIP
void listen()
Starts listening on the local port indicated by the localPort property.
static bool begin(uint8_t cspin)
Initializes EtherDune and the underlying hardware
static IPAddress netmask
Subnet mask.
static IPAddress gatewayIP
IP address of the gateway in this network.
static const uint8_t CS_PIN
static MACAddress_P mymac
static bool isLinkUp()
Determines whether the network link is ready
Implements the TCP protocol.
static MACAddress localMAC
Ethernet MAC address.
static void loop()
Gives processing time to EtherDune so that it can check for incoming packets or send queued packets...
virtual void onTerminate()
Called when the socket is ready to be reused.
static IPAddress localIP
IP address of this application.
void close()
Attempts to gracefully close a connection.
void accept()
Accepts a connection request that has been received on the port this instance was listening on ...
virtual void onReceive(uint16_t len, const byte *data)
Called for each data packet received
static IPAddress_P netmask
virtual void onClose()
Fires when the other party closed the incoming end of the connection because it has no more data to s...