Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ESP8266
Fork of ESP8266Interface by
Diff: ESP8266Interface.cpp
- Revision:
- 26:6e36dd3cec3f
- Parent:
- 24:37504440f296
- Parent:
- 25:91c4e9d34b77
- Child:
- 27:eaeecaaae611
--- a/ESP8266Interface.cpp Sun Jul 26 21:53:45 2015 +0000
+++ b/ESP8266Interface.cpp Mon Jul 27 15:25:53 2015 +0000
@@ -140,6 +140,18 @@
}
return 0;
}
+void ESP8266Interface::getHostByName(const char *name, char* hostIP)
+{
+ SocketInterface* sock = this->allocateSocket(SOCK_UDP);
+ IPADDRESS_t ip;
+ DnsQuery dns(sock);
+ dns.gethostbyname(name, ip);
+ sock->close();
+ this->deallocateSocket(sock);
+ char* resolved = ip.string_format();
+ memcpy(hostIP, resolved, strlen(resolved)+1);
+ printf("IP:%s\n",resolved);
+}
ESP8266Socket::ESP8266Socket(uint32_t handle, ESP8266 &driver, socket_protocol_t type, uint8_t id)
{
@@ -198,6 +210,7 @@
int32_t ESP8266Socket::open()
{
+
string sock_type = (SOCK_UDP == _type) ? "UDP" : "TCP";
if (!_driver->openSocket(sock_type, _id, _port, _addr)) {
return -1;
