Skip to content

Commit ee2590e

Browse files
authored
Merge pull request #756 from JAndrassy/sockethlp_dnsipn
SocketHelpers - added dnsIP(n) getter as in WiFi libraries
2 parents 7bc601c + 11cdf0a commit ee2590e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libraries/SocketWrapper/src/SocketHelpers.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ arduino::IPAddress arduino::MbedSocketClass::dnsServerIP() {
5050
return ipAddressFromSocketAddress(ip);
5151
}
5252

53+
arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) {
54+
SocketAddress ip;
55+
NetworkInterface* interface = getNetwork();
56+
interface->get_dns_server(n, &ip, nullptr);
57+
return ipAddressFromSocketAddress(ip);
58+
}
59+
5360
void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) {
5461
nsapi_addr_t convertedIP = { NSAPI_IPv4, { local_ip[0], local_ip[1], local_ip[2], local_ip[3] } };
5562
_ip = SocketAddress(convertedIP);

libraries/SocketWrapper/src/SocketHelpers.h

+7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ class MbedSocketClass {
9999
*/
100100
IPAddress dnsServerIP();
101101

102+
/*
103+
* Get the DNS Server ip address.
104+
*
105+
* return: DNS Server ip address value
106+
*/
107+
IPAddress dnsIP(int n = 0);
108+
102109
virtual NetworkInterface* getNetwork() = 0;
103110

104111
int download(char* url, const char* target, bool const is_https = false);

0 commit comments

Comments
 (0)