Skip to content

Commit a57bbdb

Browse files
authored
Merge branch 'master' into feature/ppp_modem_support
2 parents 40b2b84 + 3a0dd1c commit a57bbdb

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

libraries/ESP32/examples/HWSerial_Events/HWSerial_Events.ino renamed to libraries/ESP32/examples/HWCDC_Events/HWCDC_Events.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ const char* HWCDC_Status() {
6363
}
6464

6565
void setup() {
66+
HWCDCSerial.onEvent(usbEventCallback);
67+
HWCDCSerial.begin();
68+
6669
Serial0.begin(115200);
6770
Serial0.setDebugOutput(true);
68-
69-
HWCDCSerial.begin();
70-
HWCDCSerial.onEvent(usbEventCallback);
7171
Serial0.println("Starting...");
7272
}
7373

libraries/Network/src/NetworkManager.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,32 @@ int NetworkManager::hostByName(const char* aHostname, IPAddress& aResult)
8888

8989
struct addrinfo hints;
9090
memset(&hints, 0, sizeof(hints));
91-
hints.ai_family = AF_UNSPEC;
9291
hints.ai_socktype = SOCK_STREAM;
9392

93+
// **Workaround**
94+
// LWIP AF_UNSPEC always prefers IPv4 and doesn't check what network is
95+
// available. See https://github.com/espressif/esp-idf/issues/13255
96+
// Until that is fixed, as a work around if we have a global scope IPv6,
97+
// then we check IPv6 only first.
98+
if (hasGlobalV6) {
99+
hints.ai_family = AF_INET6;
100+
err = lwip_getaddrinfo(aHostname, servname, &hints, &res);
101+
102+
if (err == ERR_OK)
103+
{
104+
struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)res->ai_addr;
105+
// As an array of u8_t
106+
aResult = IPAddress(IPv6, ipv6->sin6_addr.s6_addr);
107+
log_d("DNS found IPv6 first %s", aResult.toString().c_str());
108+
lwip_freeaddrinfo(res);
109+
return 1;
110+
}
111+
}
112+
// **End Workaround**
113+
114+
hints.ai_family = AF_UNSPEC;
94115
err = lwip_getaddrinfo(aHostname, servname, &hints, &res);
116+
95117
if (err == ERR_OK)
96118
{
97119
if (res->ai_family == AF_INET6)

0 commit comments

Comments
 (0)