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:
50:2d7f6b97234e
Parent:
49:750ed1b67483
Child:
51:eb8c3577e22d
--- a/ESP8266Interface.cpp	Fri Feb 26 17:33:55 2016 +0000
+++ b/ESP8266Interface.cpp	Mon Feb 29 23:05:00 2016 +0000
@@ -32,7 +32,7 @@
     // ESP8266 specific methods
     ESP8266Socket(
         ESP8266 *esp,
-        socket_protocol_t proto,
+        ns_protocol_t proto,
         int id);
 
     virtual ~ESP8266Socket();
@@ -48,7 +48,7 @@
 
 private:
     ESP8266 *_esp;
-    socket_protocol_t _proto;
+    ns_protocol_t _proto;
     int _id;
 };
 
@@ -67,7 +67,7 @@
 int32_t ESP8266Interface::connect(
     const char *ap, 
     const char *pass_phrase, 
-    wifi_security_t)
+    ns_security_t)
 {
     _esp.setTimeout(ESP8266_CONNECT_TIMEOUT);
 
@@ -111,7 +111,7 @@
     return _esp.getMACAddress();
 }
 
-SocketInterface *ESP8266Interface::createSocket(socket_protocol_t proto)
+SocketInterface *ESP8266Interface::createSocket(ns_protocol_t proto)
 {
     // Look for an unused socket
     int id = -1;
@@ -142,7 +142,7 @@
 // ESP8266Socket implementation
 ESP8266Socket::ESP8266Socket(
         ESP8266 *esp,
-        socket_protocol_t proto,
+        ns_protocol_t proto,
         int id)
     : _esp(esp)
     , _proto(proto)
@@ -158,7 +158,7 @@
 {
     _esp->setTimeout(ESP8266_MISC_TIMEOUT);
 
-    const char *proto = (_proto == SOCK_UDP) ? "UDP" : "TCP";
+    const char *proto = (_proto == NS_UDP) ? "UDP" : "TCP";
 
     if (!_esp->open(proto, _id, ip, port)) {
         return NS_ERROR_TIMEOUT;