STM32Ethernet
Arduino Ethernet library for STM32 boards
Loading...
Searching...
No Matches
EthernetClass Class Reference

#include <STM32Ethernet.h>

Public Member Functions

int begin (unsigned long timeout=60000, unsigned long responseTimeout=4000)
 Initialises Ethernet with the built-in MAC address and gets the network configuration from a DHCP server.
 
EthernetLinkStatus linkStatus ()
 Returns the Ethernet link status.
 
void begin (IPAddress local_ip)
 Initialises Ethernet with a static IP address.
 
void begin (IPAddress local_ip, IPAddress subnet)
 Initialises Ethernet with a static IP address and subnet mask.
 
void begin (IPAddress local_ip, IPAddress subnet, IPAddress gateway)
 Initialises Ethernet with static IP, subnet mask and gateway.
 
void begin (IPAddress local_ip, IPAddress subnet, IPAddress gateway, IPAddress dns_server)
 Initialises Ethernet with a fully static network configuration.
 
int begin (uint8_t *mac_address, unsigned long timeout=60000, unsigned long responseTimeout=4000)
 Initialises Ethernet with the given MAC address and gets the network configuration from a DHCP server.
 
void begin (uint8_t *mac_address, IPAddress local_ip)
 Initialises Ethernet with a MAC address and a static IP address.
 
void begin (uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server)
 Initialises Ethernet with a MAC address, static IP and DNS server.
 
void begin (uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
 Initialises Ethernet with a MAC address, static IP, DNS and gateway.
 
void begin (uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
 Initialises Ethernet with a MAC address and a fully static network configuration.
 
int maintain ()
 Checks the DHCP lease and reports the result of a renew or rebind.
 
void schedule (void)
 Services the LwIP stack.
 
void MACAddress (uint8_t *mac_address)
 Copies the current MAC address of the Ethernet interface.
 
IPAddress localIP ()
 Returns the local IP address of the interface.
 
IPAddress subnetMask ()
 Returns the subnet mask of the interface.
 
IPAddress gatewayIP ()
 Returns the default gateway address of the interface.
 
IPAddress dnsServerIP ()
 Returns the DNS server address.
 
void setMACAddress (const uint8_t *mac_address)
 Sets the MAC address of the Ethernet interface.
 
void setDnsServerIP (const IPAddress dns_server)
 Stores the DNS server address returned by dnsServerIP().
 

Friends

class EthernetClient
 
class EthernetServer
 

Member Function Documentation

◆ begin() [1/10]

void EthernetClass::begin ( IPAddress  local_ip)

Initialises Ethernet with a static IP address.

Uses the built-in MAC address and a subnet mask of 255.255.255.0.

Parameters
local_ipStatic IP address of the board.

◆ begin() [2/10]

void EthernetClass::begin ( IPAddress  local_ip,
IPAddress  subnet 
)

Initialises Ethernet with a static IP address and subnet mask.

The gateway defaults to the .1 address of the local network.

Parameters
local_ipStatic IP address of the board.
subnetSubnet mask.

◆ begin() [3/10]

void EthernetClass::begin ( IPAddress  local_ip,
IPAddress  subnet,
IPAddress  gateway 
)

Initialises Ethernet with static IP, subnet mask and gateway.

The DNS server defaults to the gateway address.

Parameters
local_ipStatic IP address of the board.
subnetSubnet mask.
gatewayDefault gateway address.

◆ begin() [4/10]

void EthernetClass::begin ( IPAddress  local_ip,
IPAddress  subnet,
IPAddress  gateway,
IPAddress  dns_server 
)

Initialises Ethernet with a fully static network configuration.

Uses the built-in MAC address and informs any local DHCP server of the static configuration to avoid IP conflicts. The DNS server is only stored and returned by dnsServerIP().

Parameters
local_ipStatic IP address of the board.
subnetSubnet mask.
gatewayDefault gateway address.
dns_serverDNS server address.

◆ begin() [5/10]

void EthernetClass::begin ( uint8_t *  mac_address,
IPAddress  local_ip 
)

Initialises Ethernet with a MAC address and a static IP address.

Uses a subnet mask of 255.255.255.0. The DNS server and the gateway default to the .1 address of the local network.

Parameters
mac_addressSix-byte MAC address to use.
local_ipStatic IP address of the board.

◆ begin() [6/10]

void EthernetClass::begin ( uint8_t *  mac_address,
IPAddress  local_ip,
IPAddress  dns_server 
)

Initialises Ethernet with a MAC address, static IP and DNS server.

Uses a subnet mask of 255.255.255.0. The gateway defaults to the .1 address of the local network.

Parameters
mac_addressSix-byte MAC address to use.
local_ipStatic IP address of the board.
dns_serverDNS server address.

◆ begin() [7/10]

void EthernetClass::begin ( uint8_t *  mac_address,
IPAddress  local_ip,
IPAddress  dns_server,
IPAddress  gateway 
)

Initialises Ethernet with a MAC address, static IP, DNS and gateway.

Uses a subnet mask of 255.255.255.0.

Parameters
mac_addressSix-byte MAC address to use.
local_ipStatic IP address of the board.
dns_serverDNS server address.
gatewayDefault gateway address.

◆ begin() [8/10]

void EthernetClass::begin ( uint8_t *  mac_address,
IPAddress  local_ip,
IPAddress  dns_server,
IPAddress  gateway,
IPAddress  subnet 
)

Initialises Ethernet with a MAC address and a fully static network configuration.

Informs any local DHCP server of the static configuration to avoid IP conflicts. The DNS server is only stored and returned by dnsServerIP().

Parameters
mac_addressSix-byte MAC address to use.
local_ipStatic IP address of the board.
dns_serverDNS server address.
gatewayDefault gateway address.
subnetSubnet mask.

◆ begin() [9/10]

int EthernetClass::begin ( uint8_t *  mac_address,
unsigned long  timeout = 60000,
unsigned long  responseTimeout = 4000 
)

Initialises Ethernet with the given MAC address and gets the network configuration from a DHCP server.

The MAC address is only applied if the interface is not yet initialised. Blocks until a lease is obtained or the timeout expires. On success the DNS server is taken from DHCP.

Parameters
mac_addressSix-byte MAC address to use.
timeoutMaximum time to wait for the DHCP lease, in milliseconds.
responseTimeoutUnused; kept for compatibility.
Returns
1 if the DHCP configuration succeeded, 0 if it failed.

◆ begin() [10/10]

int EthernetClass::begin ( unsigned long  timeout = 60000,
unsigned long  responseTimeout = 4000 
)

Initialises Ethernet with the built-in MAC address and gets the network configuration from a DHCP server.

Blocks until a lease is obtained or the timeout expires. On success the DNS server is taken from DHCP.

Parameters
timeoutMaximum time to wait for the DHCP lease, in milliseconds.
responseTimeoutUnused; kept for compatibility.
Returns
1 if the DHCP configuration succeeded, 0 if it failed.

◆ dnsServerIP()

IPAddress EthernetClass::dnsServerIP ( )

Returns the DNS server address.

This is the value stored by begin() or setDnsServerIP().

Returns
The DNS server address.

◆ gatewayIP()

IPAddress EthernetClass::gatewayIP ( )

Returns the default gateway address of the interface.

Returns
The current gateway address.

◆ linkStatus()

EthernetLinkStatus EthernetClass::linkStatus ( )

Returns the Ethernet link status.

Returns
Unknown if the interface is not initialised, LinkON if the link is up, LinkOFF otherwise.

◆ localIP()

IPAddress EthernetClass::localIP ( )

Returns the local IP address of the interface.

Returns
The current IP address.

◆ MACAddress()

void EthernetClass::MACAddress ( uint8_t *  mac_address)

Copies the current MAC address of the Ethernet interface.

Parameters
mac_addressSix-byte buffer that receives the MAC address.

◆ maintain()

int EthernetClass::maintain ( )

Checks the DHCP lease and reports the result of a renew or rebind.

Does nothing and returns DHCP_CHECK_NONE if DHCP was never started. When a renew or rebind succeeds, the DNS server is updated from DHCP.

Returns
DHCP_CHECK_NONE (0) if nothing happened, DHCP_CHECK_RENEW_FAIL (1), DHCP_CHECK_RENEW_OK (2), DHCP_CHECK_REBIND_FAIL (3) or DHCP_CHECK_REBIND_OK (4).

◆ schedule()

void EthernetClass::schedule ( void  )

Services the LwIP stack.

Triggers the stack scheduler, which handles packet input, the link check, timeouts and DHCP processing. Useful in long loops where the stack would otherwise not be updated.

◆ setDnsServerIP()

void EthernetClass::setDnsServerIP ( const IPAddress  dns_server)

Stores the DNS server address returned by dnsServerIP().

Does not reconfigure the LwIP DNS resolver.

Parameters
dns_serverDNS server address.

◆ setMACAddress()

void EthernetClass::setMACAddress ( const uint8_t *  mac_address)

Sets the MAC address of the Ethernet interface.

The address is only applied while the interface is not yet initialised.

Parameters
mac_addressSix-byte MAC address to use.

◆ subnetMask()

IPAddress EthernetClass::subnetMask ( )

Returns the subnet mask of the interface.

Returns
The current subnet mask.

Friends And Related Symbol Documentation

◆ EthernetClient

friend class EthernetClient
friend

◆ EthernetServer

friend class EthernetServer
friend

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