idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::mac_address Class Reference

A MAC-48 (6-byte) hardware address. More...

Public Member Functions

constexpr mac_address () noexcept=default
 Constructs a zero-initialized MAC address (00:00:00:00:00:00).
 
constexpr mac_address (std::array< uint8_t, 6 > bytes) noexcept
 Constructs a MAC address from a byte array.
 
constexpr mac_address (uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5) noexcept
 Constructs a MAC address from individual bytes.
 
constexpr const std::array< uint8_t, 6 > & bytes () const noexcept
 Returns a reference to the underlying byte array.
 
constexpr const uint8_tdata () const noexcept
 Returns a pointer to the raw byte data.
 
constexpr uint8_tdata () noexcept
 Returns a mutable pointer to the raw byte data.
 
constexpr uint8_t operator[] (std::size_t i) const noexcept
 Accesses a byte by index.
 
constexpr bool operator== (const mac_address &) const noexcept=default
 Equality comparison.
 

Detailed Description

A MAC-48 (6-byte) hardware address.

Fixed-size value type for storing and comparing MAC addresses.

auto s = idfxx::to_string(mac); // "AA:BB:CC:DD:EE:FF"
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
Definition cpu.hpp:52
mac_address base_mac_address()
Returns the base MAC address.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

Definition at line 62 of file mac.hpp.

Constructor & Destructor Documentation

◆ mac_address() [1/3]

constexpr idfxx::mac_address::mac_address ( )
constexprdefaultnoexcept

Constructs a zero-initialized MAC address (00:00:00:00:00:00).

◆ mac_address() [2/3]

constexpr idfxx::mac_address::mac_address ( std::array< uint8_t, 6 >  bytes)
inlineexplicitconstexprnoexcept

Constructs a MAC address from a byte array.

Parameters
bytesThe 6-byte MAC address.

Definition at line 74 of file mac.hpp.

◆ mac_address() [3/3]

constexpr idfxx::mac_address::mac_address ( uint8_t  b0,
uint8_t  b1,
uint8_t  b2,
uint8_t  b3,
uint8_t  b4,
uint8_t  b5 
)
inlineconstexprnoexcept

Constructs a MAC address from individual bytes.

Parameters
b0First byte (most significant).
b1Second byte.
b2Third byte.
b3Fourth byte.
b4Fifth byte.
b5Sixth byte (least significant).

Definition at line 87 of file mac.hpp.

Member Function Documentation

◆ bytes()

constexpr const std::array< uint8_t, 6 > & idfxx::mac_address::bytes ( ) const
inlineconstexprnoexcept

Returns a reference to the underlying byte array.

Returns
The 6-byte array.

Definition at line 95 of file mac.hpp.

◆ data() [1/2]

constexpr const uint8_t * idfxx::mac_address::data ( ) const
inlineconstexprnoexcept

Returns a pointer to the raw byte data.

Returns
Pointer to the first byte.

Definition at line 102 of file mac.hpp.

◆ data() [2/2]

constexpr uint8_t * idfxx::mac_address::data ( )
inlineconstexprnoexcept

Returns a mutable pointer to the raw byte data.

Returns
Pointer to the first byte.

Definition at line 109 of file mac.hpp.

◆ operator==()

constexpr bool idfxx::mac_address::operator== ( const mac_address ) const
constexprdefaultnoexcept

Equality comparison.

Returns
True if both MAC addresses have the same bytes.

◆ operator[]()

constexpr uint8_t idfxx::mac_address::operator[] ( std::size_t  i) const
inlineconstexprnoexcept

Accesses a byte by index.

Parameters
iByte index (0-5).
Returns
The byte at the given index.

Definition at line 117 of file mac.hpp.


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