Skip to content

Commit 0207e39

Browse files
fixing connection issue on Ethernet and Wifi Client when host is passed
1 parent 1ac341d commit 0207e39

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

libraries/Ethernet/src/EthernetClient.h

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ class EthernetClient : public lwipClient {
1414
this->bindCNetIf(Ethernet);
1515
}
1616

17+
int connect(const char* host, uint16_t port) {
18+
auto res = lwipClient::connect(host, port);
19+
20+
this->bindCNetIf(Ethernet);
21+
22+
return res;
23+
}
24+
1725
int connect(IPAddress ip, uint16_t port) {
1826
auto res = lwipClient::connect(ip, port);
1927

libraries/WiFi/src/WiFiClient.h

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ class WiFiClient: public lwipClient {
1414
this->bindCNetIf(WiFiStation);
1515
}
1616

17+
int connect(const char* host, uint16_t port) {
18+
auto res = lwipClient::connect(host, port);
19+
20+
this->bindCNetIf(WiFiStation);
21+
22+
return res;
23+
}
24+
1725
int connect(IPAddress ip, uint16_t port) {
1826
auto res = lwipClient::connect(ip, port);
1927

libraries/lwIpWrapper/src/CNetIf.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,14 @@ bool CNetIf::dhcpRenew() {
459459

460460
#endif
461461

462+
IPAddress CNetIf::dnsServerIP() {
463+
#if LWIP_DNS
464+
return CLwipIf::getInstance().getDns(0);
465+
#else
466+
return INADDR_NONE;
467+
#endif
468+
}
469+
462470
/* ##########################################################################
463471
* ETHERNET NETWORK INTERFACE CLASS
464472
* ########################################################################## */

libraries/lwIpWrapper/src/CNetIf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class CNetIf: public NetworkInterface {
167167
IPAddress localIP() { return IPAddress(this->getIpAdd()); }
168168
IPAddress subnetMask() { return IPAddress(this->getNmAdd()); }
169169
IPAddress gatewayIP() { return IPAddress(this->getGwAdd()); }
170-
IPAddress dnsServerIP() { /* FIXME understand where dns should be managed */}
170+
IPAddress dnsServerIP();
171171

172172
void config(IPAddress _ip, IPAddress _gw, IPAddress _nm);
173173

0 commit comments

Comments
 (0)