Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
SocketHelpers - added dnsIP(n) getter as in WiFi libraries
  • Loading branch information
JAndrassy committed Nov 10, 2023
commit 11cdf0a8acc9e13331bbcde5f63940643766f954
7 changes: 7 additions & 0 deletions libraries/SocketWrapper/src/SocketHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ arduino::IPAddress arduino::MbedSocketClass::dnsServerIP() {
return ipAddressFromSocketAddress(ip);
}

arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) {
SocketAddress ip;
NetworkInterface* interface = getNetwork();
interface->get_dns_server(n, &ip, nullptr);
return ipAddressFromSocketAddress(ip);
}

void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) {
nsapi_addr_t convertedIP = { NSAPI_IPv4, { local_ip[0], local_ip[1], local_ip[2], local_ip[3] } };
_ip = SocketAddress(convertedIP);
Expand Down
7 changes: 7 additions & 0 deletions libraries/SocketWrapper/src/SocketHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class MbedSocketClass {
*/
IPAddress dnsServerIP();

/*
* Get the DNS Server ip address.
*
* return: DNS Server ip address value
*/
IPAddress dnsIP(int n = 0);

virtual NetworkInterface* getNetwork() = 0;

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