Added toString() for esp_ip_addr_t

This commit is contained in:
2021-10-14 19:46:08 +02:00
parent 36393e6689
commit 39af218aed
2 changed files with 13 additions and 0 deletions

View File

@@ -235,4 +235,16 @@ std::string toString(ip_addr_t val)
} }
} }
std::string toString(const esp_ip_addr_t &val)
{
switch (val.type)
{
case IPADDR_TYPE_V4: return toString(val.u_addr.ip4);
case IPADDR_TYPE_V6: return toString(val.u_addr.ip6);
default:
ESP_LOGW(TAG, "Unknown ipv%hhu", val.type);
return fmt::format("Unknown ipv{}", val.type);
}
}
} // namespace wifi_stack } // namespace wifi_stack

View File

@@ -106,5 +106,6 @@ inline std::string toString(const esp_ip4_addr_t &val)
{ return toString(*reinterpret_cast<const ip4_addr_t *>(&val)); } { return toString(*reinterpret_cast<const ip4_addr_t *>(&val)); }
inline std::string toString(const esp_ip6_addr_t &val) inline std::string toString(const esp_ip6_addr_t &val)
{ return toString(*reinterpret_cast<const ip6_addr_t *>(&val)); } { return toString(*reinterpret_cast<const ip6_addr_t *>(&val)); }
std::string toString(const esp_ip_addr_t &val);
} // namespace wifi_stack } // namespace wifi_stack