[helpers] Add get_mac_address_into_buffer() (#11700)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user