atMETEO
An ATmega based weather station
Files | Classes

Utilities for Ethernet communication interfaces. More...

Collaboration diagram for Ethernet module:

Files

file  ethernet.h
 Utilities for Ethernet communication interfaces.
 

Classes

class  Avr::MacAddress
 Represents an Ethernet MAC address. More...
 
class  Avr::IpAddress
 Represents an IPv4 address. More...
 
class  Avr::Ethernet< TDriver >
 A C++ wrapper for accessing Ethernet communication interfaces. More...
 

Detailed Description

Utilities for Ethernet communication interfaces.

Avr::Ethernet is a class implementing a C++ wrapper for accessing Ethernet communication interfaces.


Class Documentation

◆ Avr::MacAddress

class Avr::MacAddress

Represents an Ethernet MAC address.

Public Member Functions

 MacAddress (uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet, uint8_t fifth_octet, uint8_t sixth_octet)
 Initializes a MAC address from octets. More...
 

Constructor & Destructor Documentation

◆ MacAddress()

Avr::MacAddress::MacAddress ( uint8_t  first_octet,
uint8_t  second_octet,
uint8_t  third_octet,
uint8_t  fourth_octet,
uint8_t  fifth_octet,
uint8_t  sixth_octet 
)
inline

Initializes a MAC address from octets.

Parameters
first_octetThe first octet of the MAC address.
second_octetThe second octet of the MAC address.
third_octetThe third octet of the MAC address.
fourth_octetThe fourth octet of the MAC address.
fifth_octetThe fifth octet of the MAC address.
sixth_octetThe sixth octet of the MAC address.

◆ Avr::IpAddress

class Avr::IpAddress

Represents an IPv4 address.

Public Member Functions

 IpAddress ()
 Initializes an IP address to 0.0.0.0. More...
 
 IpAddress (uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
 Initializes an IP address from octets. More...
 

Constructor & Destructor Documentation

◆ IpAddress() [1/2]

Avr::IpAddress::IpAddress ( )
inline

Initializes an IP address to 0.0.0.0.

◆ IpAddress() [2/2]

Avr::IpAddress::IpAddress ( uint8_t  first_octet,
uint8_t  second_octet,
uint8_t  third_octet,
uint8_t  fourth_octet 
)
inline

Initializes an IP address from octets.

Parameters
first_octetThe first octet of the IP address.
second_octetThe second octet of the IP address.
third_octetThe third octet of the IP address.
fourth_octetThe fourth octet of the IP address.

◆ Avr::Ethernet

class Avr::Ethernet

template<typename TDriver>
class Avr::Ethernet< TDriver >

A C++ wrapper for accessing Ethernet communication interfaces.

Usage:

Avr::MacAddress(0x00, 0x16, 0x36, 0xDE, 0x58, 0xF6),
Avr::IpAddress(192.168, 0, 200),
Avr::IpAddress(255, 255, 0, 0));
auto dest = Avr::IpAddress(192, 168, 0, 100);
ethernet.sendUdpMessage("TEST\n", dest, 8600);
Template Parameters
TDriverThe driver for the Ethernet module to use.
Note
Avr::Ethernet is currently limited to the sending of UDP messages.

Public Member Functions

 Ethernet (MacAddress mac, IpAddress ip, IpAddress subnet)
 Initializes the Ethernet driver. More...
 
bool sendUdpMessage (IpAddress dest, uint16_t port, const char *message)
 Sends an UDP message to the specified destination. More...
 

Constructor & Destructor Documentation

◆ Ethernet()

template<typename TDriver>
Avr::Ethernet< TDriver >::Ethernet ( MacAddress  mac,
IpAddress  ip,
IpAddress  subnet 
)
inline

Initializes the Ethernet driver.

After initialization, the Ethernet module replies to ICMP echo requests.

Parameters
macThe local Avr::MacAddress. This must be unique withing the local network.
ipThe local Avr::IpAddress.
subnetThe local subnet configuration.

Member Function Documentation

◆ sendUdpMessage()

template<typename TDriver>
bool Avr::Ethernet< TDriver >::sendUdpMessage ( IpAddress  dest,
uint16_t  port,
const char *  message 
)
inline

Sends an UDP message to the specified destination.

Parameters
destThe destination Avr::IpAddress to transmit the message to.
portThe destination UDP port number to transmit the message to.
messageThe message to transmit.
Returns
true if the message was sent successfully, false if the driver reported an error during transmission. Since UDP is connectionless, there is no guarantee that the message has been delivered even if this message reports success.