Added get_mac_addr()
This commit is contained in:
@@ -847,6 +847,18 @@ tl::expected<wifi_ap_record_t, std::string> get_sta_ap_info()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mac_or_error get_mac_addr(wifi_interface_t ifx)
|
||||||
|
{
|
||||||
|
wifi_stack::mac_t mac;
|
||||||
|
if (const auto result = esp_wifi_get_mac(ifx, std::begin(mac)); result == ESP_OK)
|
||||||
|
return mac;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESP_LOGW(TAG, "esp_wifi_get_mac() failed with %s", esp_err_to_name(result));
|
||||||
|
return tl::make_unexpected(fmt::format("esp_wifi_get_mac() failed with {}", esp_err_to_name(result)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mac_or_error get_default_mac_addr()
|
mac_or_error get_default_mac_addr()
|
||||||
{
|
{
|
||||||
static const mac_or_error cachedResult = []() -> mac_or_error {
|
static const mac_or_error cachedResult = []() -> mac_or_error {
|
||||||
|
@@ -73,6 +73,7 @@ void delete_scan_result();
|
|||||||
//! Util wrappers
|
//! Util wrappers
|
||||||
using mac_or_error = tl::expected<mac_t, std::string>;
|
using mac_or_error = tl::expected<mac_t, std::string>;
|
||||||
tl::expected<wifi_ap_record_t, std::string> get_sta_ap_info();
|
tl::expected<wifi_ap_record_t, std::string> get_sta_ap_info();
|
||||||
|
mac_or_error get_mac_addr(wifi_interface_t ifx);
|
||||||
mac_or_error get_default_mac_addr();
|
mac_or_error get_default_mac_addr();
|
||||||
mac_or_error get_custom_mac_addr();
|
mac_or_error get_custom_mac_addr();
|
||||||
mac_or_error get_base_mac_addr();
|
mac_or_error get_base_mac_addr();
|
||||||
|
Reference in New Issue
Block a user