32 #include <FlowScanner.h>
42 static const uint8_t
CS_PIN = 10;
65 ACTRACE(
"on connect");
66 Serial.print(F(
"Time is:"));
75 void onReceive(uint16_t len,
const byte* data)
77 ACTRACE(
"onReceive: %d bytes", len);
78 Serial.write(data, len);
88 if (identification == DNSid && status==0)
90 ACINFO(
"resolved. IP=%d.%d.%d.%d", resolvedIP.
b[0], resolvedIP.
b[1], resolvedIP.
b[2], resolvedIP.
b[3]);
91 remoteIP = resolvedIP;
103 Serial.begin(115200);
106 Serial.println(F(
"TCP Client EtherDune example"));
107 Serial.print(F(
"Free RAM: ")); Serial.println(ACross::getFreeRam());
108 Serial.println(F(
"Press any key to start..."));
110 while (!Serial.available());
120 ACERROR(
"failed to start EtherDune");
122 ACINFO(
"waiting for link...");
126 ACINFO(
"link is up");
130 Serial.println(F(
"connecting..."));
#define IPAddress_P
helper macro to store an IP address in PROGMEM
uint8_t b[4]
byte-wise access to IP address
static DNSClient & DNS()
Obtains access to the DNS service singleton instance.
virtual void onConnect()
Fires when the socket connection is established.
static IPAddress_P gatewayIP
virtual void onDNSResolve(uint8_t status, uint16_t identification, const IPAddress &ip)
Called on each network service every time a DNS response is received.
static bool begin(uint8_t cspin)
Initializes EtherDune and the underlying hardware
represents an IP address in memory
static IPAddress netmask
Subnet mask.
static IPAddress gatewayIP
IP address of the gateway in this network.
static const uint8_t CS_PIN
#define IPADDR_P(b0, b1, b2, b3)
defines an IP address as stored in PROGMEM
static MACAddress_P mymac
void connect()
Initiates a TCP connection to remoteIP and remotePort.
static bool isLinkUp()
Determines whether the network link is ready
Implements the TCP protocol.
static IPAddress dnsIP
IP address of the DNS server to use.
static MACAddress localMAC
Ethernet MAC address.
uint16_t resolve(const char *name)
Resolves a host name to an IP address
static void loop()
Gives processing time to EtherDune so that it can check for incoming packets or send queued packets...
static IPAddress localIP
IP address of this application.
void close()
Attempts to gracefully close a connection.
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...