Socket interface for ESP8266. Implements the NetworkSocketAPI. Requires device to use the Espressif Firmware.

Dependencies:   ESP8266

Dependents:   ESP8266InterfaceTests HelloESP8266Interface

Fork of ESP8266Interface by NetworkSocketAPI

Note

This library assumes your ESP8266 is running the Espressif Firmware. For instructions on how to update your ESP8266 to use the correct firmware see the Firmware Update Wiki Page.

Currently the ESP8266Interface LIbrary has the following Abilities:

Working

  • TCP Client
  • UDP Client
  • Transparent mode (single connection of 1 type at a time)
  • Station Mode (connects to AP)

To be implimented

  • TCP Server
  • UDP Server
  • Multi Connection Mode (able to have up to 5 sockets at a time)
  • AP Mode (Make ESP Chip act like access point)
  • DNS Support (currently websites must be looked up by IP)
  • Error Recovery

Nice but not necessary

  • colorized text for ESP AT Commands in Command line (easier to differentiate from other text)
Revision:
25:91c4e9d34b77
Parent:
23:fd0f3197c30b
Child:
26:6e36dd3cec3f
--- a/ESP8266Interface.cpp	Thu Jul 23 21:25:30 2015 +0000
+++ b/ESP8266Interface.cpp	Mon Jul 27 15:17:18 2015 +0000
@@ -140,6 +140,18 @@
         return -1;
     }
 }
+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)
 : driver(driver), _id(id)
@@ -204,7 +216,7 @@
         sock_type = "TCP";
         
     if (!driver->openSocket(sock_type, _id, _port, _addr)){
-        return -1;//opening socket not succesful
+        return -1;//opening socket not successful
     }
     return 0;
         
@@ -231,7 +243,7 @@
 {
     
     if (!driver->close(_id)){
-        return -1;//closing socket not succesful
+        return -1;//closing socket not successful
     }
     return 0;
 }
@@ -244,4 +256,5 @@
 uint8_t ESP8266Socket::getID()
 {
     return _id;   
-}
\ No newline at end of file
+}
+ 
\ No newline at end of file