fix(net): Do not use netif_index_to_name

Causes error on recent IDF builds
This commit is contained in:
me-no-dev 2024-10-22 12:13:04 +03:00
parent 8ac076c44c
commit 20a28b58bc
2 changed files with 9 additions and 13 deletions

View file

@ -344,13 +344,13 @@ size_t IPAddress::printTo(Print &p, bool includeZone) const {
n += p.print(':'); n += p.print(':');
} }
} }
// add a zone if zone-id is non-zero // add a zone if zone-id is non-zero (causes exception on recent IDF builds)
if (_zone > 0 && includeZone) { // if (_zone > 0 && includeZone) {
n += p.print('%'); // n += p.print('%');
char if_name[NETIF_NAMESIZE]; // char if_name[NETIF_NAMESIZE];
netif_index_to_name(_zone, if_name); // netif_index_to_name(_zone, if_name);
n += p.print(if_name); // n += p.print(if_name);
} // }
return n; return n;
} }

View file

@ -115,14 +115,10 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
setStatusBits(ESP_NETIF_HAS_LOCAL_IP6_BIT); setStatusBits(ESP_NETIF_HAS_LOCAL_IP6_BIT);
} }
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
char if_name[NETIF_NAMESIZE] = {
0,
};
netif_index_to_name(event->ip6_info.ip.zone, if_name);
static const char *addr_types[] = {"UNKNOWN", "GLOBAL", "LINK_LOCAL", "SITE_LOCAL", "UNIQUE_LOCAL", "IPV4_MAPPED_IPV6"}; static const char *addr_types[] = {"UNKNOWN", "GLOBAL", "LINK_LOCAL", "SITE_LOCAL", "UNIQUE_LOCAL", "IPV4_MAPPED_IPV6"};
log_v( log_v(
"IF %s Got IPv6: Interface: %d, IP Index: %d, Type: %s, Zone: %d (%s), Address: " IPV6STR, desc(), _interface_id, event->ip_index, addr_types[addr_type], "IF %s Got IPv6: Interface: %d, IP Index: %d, Type: %s, Zone: %d, Address: " IPV6STR, desc(), _interface_id, event->ip_index, addr_types[addr_type],
event->ip6_info.ip.zone, if_name, IPV62STR(event->ip6_info.ip) event->ip6_info.ip.zone, IPV62STR(event->ip6_info.ip)
); );
#endif #endif
memcpy(&arduino_event.event_info.got_ip6, event_data, sizeof(ip_event_got_ip6_t)); memcpy(&arduino_event.event_info.got_ip6, event_data, sizeof(ip_event_got_ip6_t));