EtherCard
Ardino interface library for the ENC28J60 Ethernet controller chip (GPL).
EtherCard Class Reference

This class provides the main interface to a ENC28J60 based network interface card and is the class most users will use. More...

#include <EtherCard.h>

Static Public Member Functions

static uint8_t begin (const uint16_t size, const uint8_t *macaddr, uint8_t csPin=SS)
 Initialise the network interface. More...
 
static bool staticSetup (const uint8_t *my_ip, const uint8_t *gw_ip=0, const uint8_t *dns_ip=0, const uint8_t *mask=0)
 Configure network interface with static IP. More...
 
static void makeUdpReply (const char *data, uint8_t len, uint16_t port)
 Sends a UDP packet to the IP address of last processed received packet. More...
 
static uint16_t packetLoop (uint16_t plen)
 Parse received data. More...
 
static uint16_t accept (uint16_t port, uint16_t plen)
 Accept a TCP/IP connection. More...
 
static void httpServerReply (uint16_t dlen)
 Send a response to a HTTP request. More...
 
static void httpServerReply_with_flags (uint16_t dlen, uint8_t flags)
 Send a response to a HTTP request. More...
 
static void httpServerReplyAck ()
 Acknowledge TCP message. More...
 
static void setGwIp (const uint8_t *gwipaddr)
 Set the gateway address. More...
 
static void updateBroadcastAddress ()
 Updates the broadcast address based on current IP address and subnet mask.
 
static uint8_t clientWaitingGw ()
 Check if got gateway hardware address (ARP lookup) More...
 
static uint8_t clientWaitingDns ()
 Check if got gateway DNS address (ARP lookup) More...
 
static uint8_t clientTcpReq (uint8_t(*result_cb)(uint8_t, uint8_t, uint16_t, uint16_t), uint16_t(*datafill_cb)(uint8_t), uint16_t port)
 Prepare a TCP request. More...
 
static void browseUrl (const char *urlbuf, const char *urlbuf_varpart, const char *hoststr, const char *additionalheaderline, void(*callback)(uint8_t, uint16_t, uint16_t))
 Prepare HTTP request. More...
 
static void browseUrl (const char *urlbuf, const char *urlbuf_varpart, const char *hoststr, void(*callback)(uint8_t, uint16_t, uint16_t))
 Prepare HTTP request. More...
 
static void httpPost (const char *urlbuf, const char *hoststr, const char *additionalheaderline, const char *postval, void(*callback)(uint8_t, uint16_t, uint16_t))
 Prepare HTTP post message. More...
 
static void ntpRequest (uint8_t *ntpip, uint8_t srcport)
 Send NTP request. More...
 
static uint8_t ntpProcessAnswer (uint32_t *time, uint8_t dstport_l)
 Process network time protocol response. More...
 
static void udpPrepare (uint16_t sport, const uint8_t *dip, uint16_t dport)
 Prepare a UDP message for transmission. More...
 
static void udpTransmit (uint16_t len)
 Transmit UDP packet. More...
 
static void sendUdp (const char *data, uint8_t len, uint16_t sport, const uint8_t *dip, uint16_t dport)
 Sends a UDP packet. More...
 
static void registerPingCallback (void(*cb)(uint8_t *))
 Resister the function to handle ping events. More...
 
static void clientIcmpRequest (const uint8_t *destip)
 Send ping. More...
 
static uint8_t packetLoopIcmpCheckReply (const uint8_t *ip_monitoredhost)
 Check for ping response. More...
 
static void sendWol (uint8_t *wolmac)
 Send a wake on lan message. More...
 
static uint8_t tcpSend ()
 Send TCP request.
 
static const char * tcpReply (uint8_t fd)
 Get TCP reply. More...
 
static void persistTcpConnection (bool persist)
 Configure TCP connections to be persistent or not. More...
 
static void udpServerListenOnPort (UdpServerCallback callback, uint16_t port)
 Register function to handle incoming UDP events. More...
 
static void udpServerPauseListenOnPort (uint16_t port)
 Pause listing on UDP port. More...
 
static void udpServerResumeListenOnPort (uint16_t port)
 Resume listing on UDP port. More...
 
static bool udpServerListening ()
 Check if UDP server is listening on any ports. More...
 
static bool udpServerHasProcessedPacket (uint16_t len)
 Passes packet to UDP Server. More...
 
static void DhcpStateMachine (uint16_t len)
 Update DHCP state. More...
 
static uint32_t dhcpStartTime ()
 Not implemented. More...
 
static uint32_t dhcpLeaseTime ()
 Not implemented. More...
 
static bool dhcpLease ()
 Not implemented. More...
 
static bool dhcpSetup (const char *hname=NULL, bool fromRam=false)
 Configure network interface with DHCP. More...
 
static void dhcpAddOptionCallback (uint8_t option, DhcpOptionCallback callback)
 Register a callback for a specific DHCP option number. More...
 
static bool dnsLookup (const char *name, bool fromRam=false)
 Perform DNS lookup. More...
 
static void copyIp (uint8_t *dst, const uint8_t *src)
 Copies an IP address. More...
 
static void copyMac (uint8_t *dst, const uint8_t *src)
 Copies a hardware address. More...
 
static void printIp (const uint8_t *buf)
 Output to serial port in dotted decimal IP format. More...
 
static void printIp (const char *msg, const uint8_t *buf)
 Output message and IP address to serial port in dotted decimal IP format. More...
 
static void printIp (const __FlashStringHelper *ifsh, const uint8_t *buf)
 Output Flash String Helper and IP address to serial port in dotted decimal IP format. More...
 
static uint8_t findKeyVal (const char *str, char *strbuf, uint8_t maxlen, const char *key)
 Search for a string of the form key=value in a string that looks like q?xyz=abc&uvw=defgh HTTP/1.1\r\n. More...
 
static void urlDecode (char *urlbuf)
 Decode a URL string e.g "hello%20joe" or "hello+joe" becomes "hello joe". More...
 
static void urlEncode (char *str, char *urlbuf)
 Encode a URL, replacing illegal characters like ' '. More...
 
static uint8_t parseIp (uint8_t *bytestr, char *str)
 Convert an IP address from dotted decimal formated string to 4 bytes. More...
 
static void makeNetStr (char *resultstr, uint8_t *bytestr, uint8_t len, char separator, uint8_t base)
 Convert a byte array to a human readable display string. More...
 
static uint32_t getSequenceNumber ()
 Return the sequence number of the current TCP package.
 
static uint16_t getTcpPayloadLength ()
 Return the payload length of the current Tcp package.
 
- Static Public Member Functions inherited from ENC28J60
static uint8_t * tcpOffset ()
 Pointer to the start of TCP payload.
 
static void initSPI ()
 Initialise SPI interface. More...
 
static uint8_t initialize (const uint16_t size, const uint8_t *macaddr, uint8_t csPin=8)
 Initialise network interface. More...
 
static bool isLinkUp ()
 Check if network link is connected. More...
 
static void packetSend (uint16_t len)
 Sends data to network interface. More...
 
static uint16_t packetReceive ()
 Copy received packets to data buffer. More...
 
static void copyout (uint8_t page, const uint8_t *data)
 Copy data from ENC28J60 memory. More...
 
static void copyin (uint8_t page, uint8_t *data)
 Copy data to ENC28J60 memory. More...
 
static uint8_t peekin (uint8_t page, uint8_t off)
 Get single byte of data from ENC28J60 memory. More...
 
static void powerDown ()
 Put ENC28J60 in sleep mode.
 
static void powerUp ()
 Wake ENC28J60 from sleep mode.
 
static void enableBroadcast (bool temporary=false)
 Enable reception of broadcast messages. More...
 
static void disableBroadcast (bool temporary=false)
 Disable reception of broadcast messages. More...
 
static void enableMulticast ()
 Enables reception of multicast messages. More...
 
static void enablePromiscuous (bool temporary=false)
 Enables reception of all messages. More...
 
static void disablePromiscuous (bool temporary=false)
 Disable reception of all messages and go back to default mode. More...
 
static void disableMulticast ()
 Disable reception of multicast messages. More...
 
static uint8_t doBIST (uint8_t csPin=8)
 Reset and fully initialise ENC28J60. More...
 
static uint16_t readPacketSlice (char *dest, int16_t maxlength, int16_t packetOffset)
 Copies a slice from the current packet to RAM. More...
 
static uint16_t enc_malloc (uint16_t size)
 reserves a block of RAM in the memory of the enc chip More...
 
static uint16_t enc_freemem ()
 returns the amount of memory within the enc28j60 chip that is still available for malloc. More...
 
static void memcpy_to_enc (uint16_t dest, void *source, int16_t num)
 copies a block of data from SRAM to the enc memory More...
 
static void memcpy_from_enc (void *dest, uint16_t source, int16_t num)
 copies a block of data from the enc memory to SRAM More...
 

Static Public Attributes

static uint8_t mymac [ETH_LEN]
 MAC address.
 
static uint8_t myip [IP_LEN]
 IP address.
 
static uint8_t netmask [IP_LEN]
 Netmask.
 
static uint8_t broadcastip [IP_LEN]
 Subnet broadcast address.
 
static uint8_t gwip [IP_LEN]
 Gateway.
 
static uint8_t dhcpip [IP_LEN]
 DHCP server IP address.
 
static uint8_t dnsip [IP_LEN]
 DNS server IP address.
 
static uint8_t hisip [IP_LEN]
 DNS lookup result.
 
static uint16_t hisport = HTTP_PORT
 TCP port to connect to (default 80)
 
static bool using_dhcp = false
 True if using DHCP.
 
static bool persist_tcp_connection = false
 False to break connections on first packet received.
 
static uint16_t delaycnt = 0
 Counts number of cycles of packetLoop when no packet received - used to trigger periodic gateway ARP request.
 
- Static Public Attributes inherited from ENC28J60
static uint8_t buffer []
 Data buffer (shared by receive and transmit)
 
static uint16_t bufferSize
 Size of data buffer.
 
static bool broadcast_enabled = false
 True if broadcasts enabled (used to allow temporary disable of broadcast for DHCP or other internal functions)
 
static bool promiscuous_enabled = false
 True if promiscuous mode enabled (used to allow temporary disable of promiscuous mode)
 

Detailed Description

This class provides the main interface to a ENC28J60 based network interface card and is the class most users will use.

Note
All TCP/IP client (outgoing) connections are made from source port in range 2816-3071. Do not use these source ports for other purposes.

Member Function Documentation

◆ accept()

uint16_t EtherCard::accept ( uint16_t  port,
uint16_t  plen 
)
static

Accept a TCP/IP connection.

Parameters
portIP port to accept on - do nothing if wrong port
plenNumber of bytes in packet
Returns
uint16_t Offset within packet of TCP payload. Zero for no data.
Todo:
no idea what this check pos<=plen-8 does; changed this to pos<=plen as otw. perfectly valid tcp packets are ignored; still if anybody has any idea please leave a comment

◆ begin()

uint8_t EtherCard::begin ( const uint16_t  size,
const uint8_t *  macaddr,
uint8_t  csPin = SS 
)
static

Initialise the network interface.

Parameters
sizeSize of data buffer
macaddrHardware address to assign to the network interface (6 bytes)
csPinArduino pin number connected to chip select. Default = 8
Returns
uint8_t Firmware version or zero on failure.
Examples:
backSoon.ino, etherNode.ino, getDHCPandDNS.ino, getStaticIP.ino, getViaDNS.ino, JeeUdp.ino, multipacket.ino, multipacketSD.ino, nanether.ino, noipClient.ino, notifyMyAndroid.ino, ntpClient.ino, persistence.ino, pings.ino, rbbb_server.ino, SSDP.ino, stashTest.ino, testDHCP.ino, thingspeak.ino, twitter.ino, udpClientSendOnly.ino, udpListener.ino, webClient.ino, and xively.ino.

◆ browseUrl() [1/2]

void EtherCard::browseUrl ( const char *  urlbuf,
const char *  urlbuf_varpart,
const char *  hoststr,
const char *  additionalheaderline,
void(*)(uint8_t, uint16_t, uint16_t)  callback 
)
static

Prepare HTTP request.

Parameters
urlbufPointer to c-string URL folder
urlbuf_varpartPointer to c-string URL file
hoststrPointer to c-string hostname
additionalheaderlinePointer to c-string with additional HTTP header info
callbackPointer to callback function to handle response
Note
Request sent in main packetloop
Examples:
getDHCPandDNS.ino, getStaticIP.ino, getViaDNS.ino, persistence.ino, and webClient.ino.

◆ browseUrl() [2/2]

void EtherCard::browseUrl ( const char *  urlbuf,
const char *  urlbuf_varpart,
const char *  hoststr,
void(*)(uint8_t, uint16_t, uint16_t)  callback 
)
static

Prepare HTTP request.

Parameters
urlbufPointer to c-string URL folder
urlbuf_varpartPointer to c-string URL file
hoststrPointer to c-string hostname
callbackPointer to callback function to handle response
Note
Request sent in main packetloop

◆ clientIcmpRequest()

void EtherCard::clientIcmpRequest ( const uint8_t *  destip)
static

Send ping.

Parameters
destipPointer to 4 byte destination IP address
Examples:
pings.ino.

◆ clientTcpReq()

uint8_t EtherCard::clientTcpReq ( uint8_t(*)(uint8_t, uint8_t, uint16_t, uint16_t)  result_cb,
uint16_t(*)(uint8_t)  datafill_cb,
uint16_t  port 
)
static

Prepare a TCP request.

Parameters
result_cbPointer to callback function that handles TCP result
datafill_cbPointer to callback function that handles TCP data payload
portRemote TCP/IP port to connect to
Returns
unit8_t ID of TCP/IP session (0-7)
Note
Return value provides id of the request to allow up to 7 concurrent requests

◆ clientWaitingDns()

uint8_t EtherCard::clientWaitingDns ( )
static

Check if got gateway DNS address (ARP lookup)

Returns
unit8_t True if DNS found

◆ clientWaitingGw()

uint8_t EtherCard::clientWaitingGw ( )
static

Check if got gateway hardware address (ARP lookup)

Returns
unit8_t True if gateway found
Examples:
getStaticIP.ino.

◆ copyIp()

void EtherCard::copyIp ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copies an IP address.

Parameters
dstPointer to the 4 byte destination
srcPointer to the 4 byte source
Note
There is no check of source or destination size. Ensure both are 4 bytes
Examples:
getStaticIP.ino, noipClient.ino, ntpClient.ino, and webClient.ino.

◆ copyMac()

void EtherCard::copyMac ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copies a hardware address.

Parameters
dstPointer to the 6 byte destination
srcPointer to the 6 byte destination
Note
There is no check of source or destination size. Ensure both are 6 bytes

◆ dhcpAddOptionCallback()

void EtherCard::dhcpAddOptionCallback ( uint8_t  option,
DhcpOptionCallback  callback 
)
static

Register a callback for a specific DHCP option number.

Parameters
optionThe option number to request from the DHCP server
callbackThe function to be call when the option is received

◆ dhcpLease()

static bool EtherCard::dhcpLease ( )
static

Not implemented.

Todo:
Implement dhcpLease or remove declaration

◆ dhcpLeaseTime()

static uint32_t EtherCard::dhcpLeaseTime ( )
static

Not implemented.

Todo:
Implement dhcpLeaseTime or remove declaration

◆ dhcpSetup()

bool EtherCard::dhcpSetup ( const char *  hname = NULL,
bool  fromRam = false 
)
static

Configure network interface with DHCP.

Parameters
hnameThe hostname to pass to the DHCP server
fromRamSet true to indicate whether hname is in RAM or in program space. Default = false
Returns
bool True if DHCP successful
Note
Blocks until DHCP complete or timeout after 60 seconds
Examples:
backSoon.ino, etherNode.ino, getDHCPandDNS.ino, JeeUdp.ino, nanether.ino, noipClient.ino, notifyMyAndroid.ino, ntpClient.ino, persistence.ino, pings.ino, testDHCP.ino, thingspeak.ino, twitter.ino, udpClientSendOnly.ino, udpListener.ino, webClient.ino, and xively.ino.

◆ dhcpStartTime()

static uint32_t EtherCard::dhcpStartTime ( )
static

Not implemented.

Todo:
Implement dhcpStartTime or remove declaration

◆ DhcpStateMachine()

void EtherCard::DhcpStateMachine ( uint16_t  len)
static

Update DHCP state.

Parameters
lenLength of received data packet
Todo:
Due to millis() wrap-around, DHCP renewal may not work if leaseTime is larger than 49days

◆ dnsLookup()

bool EtherCard::dnsLookup ( const char *  name,
bool  fromRam = false 
)
static

Perform DNS lookup.

Parameters
nameHost name to lookup
fromRamSet true to indicate whether name is in RAM or in program space. Default = false
Returns
bool True on success.
Note
Result is stored in hisip member
Examples:
getDHCPandDNS.ino, getViaDNS.ino, noipClient.ino, notifyMyAndroid.ino, ntpClient.ino, persistence.ino, pings.ino, thingspeak.ino, twitter.ino, udpClientSendOnly.ino, webClient.ino, and xively.ino.

◆ findKeyVal()

uint8_t EtherCard::findKeyVal ( const char *  str,
char *  strbuf,
uint8_t  maxlen,
const char *  key 
)
static

Search for a string of the form key=value in a string that looks like q?xyz=abc&uvw=defgh HTTP/1.1\r\n.

Parameters
strPointer to the null terminated string to search
strbufPointer to buffer to hold null terminated result string
maxlenMaximum length of result
keyPointer to null terminated string holding the key to search for
Returns
unit_t Length of the value. 0 if not found
Note
Ensure strbuf has memory allocated of at least maxlen + 1 (to accommodate result plus terminating null)
Examples:
etherNode.ino, and JeeUdp.ino.

◆ httpPost()

void EtherCard::httpPost ( const char *  urlbuf,
const char *  hoststr,
const char *  additionalheaderline,
const char *  postval,
void(*)(uint8_t, uint16_t, uint16_t)  callback 
)
static

Prepare HTTP post message.

Parameters
urlbufPointer to c-string URL folder
hoststrPointer to c-string hostname
additionalheaderlinePointer to c-string with additional HTTP header info
postvalPointer to c-string HTML Post value
callbackPointer to callback function to handle response
Note
Request sent in main packetloop

◆ httpServerReply()

void EtherCard::httpServerReply ( uint16_t  dlen)
static

Send a response to a HTTP request.

Parameters
dlenSize of the HTTP (TCP) payload
Examples:
backSoon.ino, etherNode.ino, JeeUdp.ino, and rbbb_server.ino.

◆ httpServerReply_with_flags()

void EtherCard::httpServerReply_with_flags ( uint16_t  dlen,
uint8_t  flags 
)
static

Send a response to a HTTP request.

Parameters
dlenSize of the HTTP (TCP) payload
flagsTCP flags
Examples:
multipacket.ino, multipacketSD.ino, and SSDP.ino.

◆ httpServerReplyAck()

void EtherCard::httpServerReplyAck ( )
static

Acknowledge TCP message.

Todo:
Is this / should this be private?
Examples:
multipacket.ino, multipacketSD.ino, and SSDP.ino.

◆ makeNetStr()

void EtherCard::makeNetStr ( char *  resultstr,
uint8_t *  bytestr,
uint8_t  len,
char  separator,
uint8_t  base 
)
static

Convert a byte array to a human readable display string.

Parameters
resultstrPointer to a buffer to hold the resulting null terminated string
bytestrPointer to the byte array containing the address to convert
lenLength of the array (4 for IP address, 6 for hardware (MAC) address)
separatorDelimiter character (typically '.' for IP address and ':' for hardware (MAC) address)
baseBase for numerical representation (typically 10 for IP address and 16 for hardware (MAC) address

◆ makeUdpReply()

void EtherCard::makeUdpReply ( const char *  data,
uint8_t  len,
uint16_t  port 
)
static

Sends a UDP packet to the IP address of last processed received packet.

Parameters
dataPointer to data payload
lenSize of data payload (max 220)
portSource IP port

◆ ntpProcessAnswer()

uint8_t EtherCard::ntpProcessAnswer ( uint32_t *  time,
uint8_t  dstport_l 
)
static

Process network time protocol response.

Parameters
timePointer to integer to hold result
dstport_lDestination port to expect response. Set to zero to accept on any port
Returns
uint8_t True (1) on success

◆ ntpRequest()

void EtherCard::ntpRequest ( uint8_t *  ntpip,
uint8_t  srcport 
)
static

Send NTP request.

Parameters
ntpipIP address of NTP server
srcportIP port to send from

◆ packetLoop()

uint16_t EtherCard::packetLoop ( uint16_t  plen)
static

Parse received data.

Parameters
plenSize of data to parse (e.g. return value of packetReceive()).
Returns
uint16_t Offset of TCP payload data in data buffer or zero if packet processed
Note
Data buffer is shared by receive and transmit functions
Only handles ARP and IP
Todo:
this is trying to find mac only once. Need some timeout to make another call if first one doesn't succeed.
Todo:
this is trying to find mac only once. Need some timeout to make another call if first one doesn't succeed.
Todo:
Add other protocols (and make each optional at compile time)
Examples:
backSoon.ino, etherNode.ino, getDHCPandDNS.ino, getStaticIP.ino, getViaDNS.ino, JeeUdp.ino, multipacket.ino, multipacketSD.ino, nanether.ino, noipClient.ino, notifyMyAndroid.ino, ntpClient.ino, persistence.ino, pings.ino, rbbb_server.ino, SSDP.ino, testDHCP.ino, thingspeak.ino, twitter.ino, udpListener.ino, webClient.ino, and xively.ino.

◆ packetLoopIcmpCheckReply()

uint8_t EtherCard::packetLoopIcmpCheckReply ( const uint8_t *  ip_monitoredhost)
static

Check for ping response.

Parameters
ip_monitoredhostPointer to 4 byte IP address of host to check
Returns
uint8_t True (1) if ping response from specified host
Examples:
pings.ino.

◆ parseIp()

uint8_t EtherCard::parseIp ( uint8_t *  bytestr,
char *  str 
)
static

Convert an IP address from dotted decimal formated string to 4 bytes.

Parameters
bytestrPointer to the 4 byte array to store IP address
strPointer to string to parse
Returns
uint8_t 0 on success
Examples:
pings.ino, and webClient.ino.

◆ persistTcpConnection()

void EtherCard::persistTcpConnection ( bool  persist)
static

Configure TCP connections to be persistent or not.

Parameters
persistTrue to maintain TCP connection. False to finish TCP connection after first packet.
Examples:
persistence.ino.

◆ printIp() [1/3]

void EtherCard::printIp ( const uint8_t *  buf)
static

Output to serial port in dotted decimal IP format.

Parameters
bufPointer to 4 byte IP address
Note
There is no check of source or destination size. Ensure both are 4 bytes
Examples:
backSoon.ino, etherNode.ino, getDHCPandDNS.ino, getStaticIP.ino, getViaDNS.ino, JeeUdp.ino, nanether.ino, noipClient.ino, notifyMyAndroid.ino, ntpClient.ino, persistence.ino, pings.ino, testDHCP.ino, thingspeak.ino, twitter.ino, udpClientSendOnly.ino, udpListener.ino, webClient.ino, and xively.ino.

◆ printIp() [2/3]

void EtherCard::printIp ( const char *  msg,
const uint8_t *  buf 
)
static

Output message and IP address to serial port in dotted decimal IP format.

Parameters
msgPointer to null terminated string
bufPointer to 4 byte IP address
Note
There is no check of source or destination size. Ensure both are 4 bytes

◆ printIp() [3/3]

void EtherCard::printIp ( const __FlashStringHelper *  ifsh,
const uint8_t *  buf 
)
static

Output Flash String Helper and IP address to serial port in dotted decimal IP format.

Parameters
ifshPointer to Flash String Helper
bufPointer to 4 byte IP address
Note
There is no check of source or destination size. Ensure both are 4 bytes
Todo:
What is a FlashStringHelper?

◆ registerPingCallback()

void EtherCard::registerPingCallback ( void(*)(uint8_t *)  cb)
static

Resister the function to handle ping events.

Parameters
cbPointer to function
Examples:
pings.ino.

◆ sendUdp()

void EtherCard::sendUdp ( const char *  data,
uint8_t  len,
uint16_t  sport,
const uint8_t *  dip,
uint16_t  dport 
)
static

Sends a UDP packet.

Parameters
dataPointer to data
lenSize of payload (maximum 220 octets / bytes)
sportSource port
dipPointer to 4 byte destination IP address
dportDestination port
Examples:
JeeUdp.ino, ntpClient.ino, and udpClientSendOnly.ino.

◆ sendWol()

void EtherCard::sendWol ( uint8_t *  wolmac)
static

Send a wake on lan message.

Parameters
wolmacPointer to 6 byte hardware (MAC) address of host to send message to

◆ setGwIp()

void EtherCard::setGwIp ( const uint8_t *  gwipaddr)
static

Set the gateway address.

Parameters
gwipaddrGateway address (4 bytes)

◆ staticSetup()

bool EtherCard::staticSetup ( const uint8_t *  my_ip,
const uint8_t *  gw_ip = 0,
const uint8_t *  dns_ip = 0,
const uint8_t *  mask = 0 
)
static

Configure network interface with static IP.

Parameters
my_ipIP address (4 bytes). 0 for no change.
gw_ipGateway address (4 bytes). 0 for no change. Default = 0
dns_ipDNS address (4 bytes). 0 for no change. Default = 0
maskSubnet mask (4 bytes). 0 for no change. Default = 0
Returns
bool Returns true on success - actually always true
Examples:
backSoon.ino, getStaticIP.ino, getViaDNS.ino, multipacket.ino, multipacketSD.ino, nanether.ino, rbbb_server.ino, SSDP.ino, and udpListener.ino.

◆ tcpReply()

const char * EtherCard::tcpReply ( uint8_t  fd)
static

Get TCP reply.

Returns
char* Pointer to TCP reply payload. NULL if no data.
Examples:
noipClient.ino, notifyMyAndroid.ino, thingspeak.ino, twitter.ino, and xively.ino.

◆ udpPrepare()

void EtherCard::udpPrepare ( uint16_t  sport,
const uint8_t *  dip,
uint16_t  dport 
)
static

Prepare a UDP message for transmission.

Parameters
sportSource port
dipPointer to 4 byte destination IP address
dportDestination port
Examples:
SSDP.ino.

◆ udpServerHasProcessedPacket()

bool EtherCard::udpServerHasProcessedPacket ( uint16_t  len)
static

Passes packet to UDP Server.

Parameters
lenNot used
Returns
bool True if packet processed

◆ udpServerListening()

bool EtherCard::udpServerListening ( )
static

Check if UDP server is listening on any ports.

Returns
bool True if listening on any ports

◆ udpServerListenOnPort()

void EtherCard::udpServerListenOnPort ( UdpServerCallback  callback,
uint16_t  port 
)
static

Register function to handle incoming UDP events.

Parameters
callbackFunction to handle event
portPort to listen on
Examples:
ntpClient.ino, and udpListener.ino.

◆ udpServerPauseListenOnPort()

void EtherCard::udpServerPauseListenOnPort ( uint16_t  port)
static

Pause listing on UDP port.

port Port to pause

◆ udpServerResumeListenOnPort()

void EtherCard::udpServerResumeListenOnPort ( uint16_t  port)
static

Resume listing on UDP port.

port Port to pause

◆ udpTransmit()

void EtherCard::udpTransmit ( uint16_t  len)
static

Transmit UDP packet.

Parameters
lenSize of payload
Examples:
SSDP.ino.

◆ urlDecode()

void EtherCard::urlDecode ( char *  urlbuf)
static

Decode a URL string e.g "hello%20joe" or "hello+joe" becomes "hello joe".

Parameters
urlbufPointer to the null terminated URL
Note
urlbuf is modified

◆ urlEncode()

void EtherCard::urlEncode ( char *  str,
char *  urlbuf 
)
static

Encode a URL, replacing illegal characters like ' '.

Parameters
strPointer to the null terminated string to encode
urlbufPointer to a buffer to contain the null terminated encoded URL
Note
There must be enough space in urlbuf. In the worst case that is 3 times the length of str