[helpers] Add get_mac_address_into_buffer() (#11700)

This commit is contained in:
Keith Burzinski
2025-11-03 17:30:37 -06:00
committed by GitHub
parent 99d1a9cf6e
commit 266e4ae91f
2 changed files with 11 additions and 0 deletions

View File

@@ -643,6 +643,12 @@ std::string get_mac_address_pretty() {
return format_mac_address_pretty(mac);
}
void get_mac_address_into_buffer(std::span<char, 13> buf) {
uint8_t mac[6];
get_mac_address_raw(mac);
format_mac_addr_lower_no_sep(mac, buf.data());
}
#ifndef USE_ESP32
bool has_custom_mac_address() { return false; }
#endif

View File

@@ -8,6 +8,7 @@
#include <iterator>
#include <limits>
#include <memory>
#include <span>
#include <string>
#include <type_traits>
#include <vector>
@@ -1027,6 +1028,10 @@ std::string get_mac_address();
/// Get the device MAC address as a string, in colon-separated uppercase hex notation.
std::string get_mac_address_pretty();
/// Get the device MAC address into the given buffer, in lowercase hex notation.
/// Assumes buffer length is 13 (12 digits for hexadecimal representation followed by null terminator).
void get_mac_address_into_buffer(std::span<char, 13> buf);
#ifdef USE_ESP32
/// Set the MAC address to use from the provided byte array (6 bytes).
void set_mac_address(uint8_t *mac);