From daedb9ef59d5aa4774a1e8b6bbfb63410fa61262 Mon Sep 17 00:00:00 2001 From: Michal Paszta Date: Thu, 19 Dec 2019 14:24:48 +0200 Subject: [PATCH 1/2] Update mbed-os version to 5.15 --- mbed-os.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbed-os.lib b/mbed-os.lib index 9c56b49..9a97f6c 100644 --- a/mbed-os.lib +++ b/mbed-os.lib @@ -1 +1 @@ -https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9 +https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7 From 1935ed443706e4cacefa0fad09e78a7300fa2b89 Mon Sep 17 00:00:00 2001 From: Michal Paszta Date: Wed, 4 Dec 2019 09:32:22 +0200 Subject: [PATCH 2/2] Replace string-based API with SocketAddress-based ones --- main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 7f2f8e9..a9b2485 100644 --- a/main.cpp +++ b/main.cpp @@ -100,12 +100,13 @@ int main() } // Show the network address - const char *ip = net->get_ip_address(); - const char *netmask = net->get_netmask(); - const char *gateway = net->get_gateway(); - printf("IP address: %s\n", ip ? ip : "None"); - printf("Netmask: %s\n", netmask ? netmask : "None"); - printf("Gateway: %s\n", gateway ? gateway : "None"); + SocketAddress a; + net->get_ip_address(&a); + printf("IP address: %s\n", a.get_ip_address() ? a.get_ip_address() : "None"); + net->get_netmask(&a); + printf("Netmask: %s\n", a.get_ip_address() ? a.get_ip_address() : "None"); + net->get_gateway(&a); + printf("Gateway: %s\n", a.get_ip_address() ? a.get_ip_address() : "None"); Thread *thread = new Thread(osPriorityNormal1, 2048); thread->start(print_stats); @@ -128,7 +129,13 @@ int main() char *buffer = new char[256]; char *p = buffer; - result = socket.connect("api.ipify.org", 80); + result = NetworkInterface::get_default_instance()->gethostbyname("api.ipify.org", &a); + if (result != NSAPI_ERROR_OK) { + printf("Error! DNS resolution failed with %d\n", result); + goto DISCONNECT; + } + a.set_port(80); + result = socket.connect(a); if (result != 0) { stdio_mutex.lock(); printf("Error! socket.connect() returned: %d\n", result);