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)
Committer:
Christopher Haster
Date:
Mon Feb 22 23:53:46 2016 -0600
Branch:
api-changes
Revision:
34:9c26a3dcdc1f
Parent:
30:c19f1e61063b
Child:
36:3d55c7187e34
Matched changes in NetworkSocketAPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 18:9fc7976c7b27 1 /* ESP8266Interface Example
sarahmarshy 18:9fc7976c7b27 2 * Copyright (c) 2015 ARM Limited
sarahmarshy 18:9fc7976c7b27 3 *
sarahmarshy 18:9fc7976c7b27 4 * Licensed under the Apache License, Version 2.0 (the "License");
sarahmarshy 18:9fc7976c7b27 5 * you may not use this file except in compliance with the License.
sarahmarshy 18:9fc7976c7b27 6 * You may obtain a copy of the License at
sarahmarshy 18:9fc7976c7b27 7 *
sarahmarshy 18:9fc7976c7b27 8 * http://www.apache.org/licenses/LICENSE-2.0
sarahmarshy 18:9fc7976c7b27 9 *
sarahmarshy 18:9fc7976c7b27 10 * Unless required by applicable law or agreed to in writing, software
sarahmarshy 18:9fc7976c7b27 11 * distributed under the License is distributed on an "AS IS" BASIS,
sarahmarshy 18:9fc7976c7b27 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sarahmarshy 18:9fc7976c7b27 13 * See the License for the specific language governing permissions and
sarahmarshy 18:9fc7976c7b27 14 * limitations under the License.
sarahmarshy 18:9fc7976c7b27 15 */
sarahmarshy 18:9fc7976c7b27 16
Christopher Haster 34:9c26a3dcdc1f 17 #ifndef ESP8266_INTERFACE_H
Christopher Haster 34:9c26a3dcdc1f 18 #define ESP8266_INTERFACE_H
sarahmarshy 18:9fc7976c7b27 19
sarahmarshy 18:9fc7976c7b27 20 #include "WiFiInterface.h"
sarahmarshy 23:fd0f3197c30b 21 #include "ESP8266.h"
Christopher Haster 34:9c26a3dcdc1f 22
Christopher Haster 34:9c26a3dcdc1f 23 #define ESP8266_SOCKET_COUNT 5
sarahmarshy 18:9fc7976c7b27 24
Christopher Haster 34:9c26a3dcdc1f 25 /** ESP8266Interface class
Christopher Haster 34:9c26a3dcdc1f 26 * Implementation of the NetworkInterface for the ESP8266
sarahmarshy 18:9fc7976c7b27 27 */
sarahmarshy 18:9fc7976c7b27 28 class ESP8266Interface : public WiFiInterface
sarahmarshy 18:9fc7976c7b27 29 {
sarahmarshy 18:9fc7976c7b27 30 public:
Christopher Haster 34:9c26a3dcdc1f 31 ESP8266Interface(PinName tx, PinName rx, bool debug = false);
Christopher Haster 34:9c26a3dcdc1f 32
Christopher Haster 34:9c26a3dcdc1f 33 // Implementation of WiFiInterface
Christopher Haster 34:9c26a3dcdc1f 34 virtual int32_t connect(
Christopher Haster 34:9c26a3dcdc1f 35 const char *ssid,
Christopher Haster 34:9c26a3dcdc1f 36 const char *pass,
Christopher Haster 34:9c26a3dcdc1f 37 wifi_security_t security = WI_NONE,
Christopher Haster 34:9c26a3dcdc1f 38 uint32_t timeout_ms = 1500);
Christopher Haster 34:9c26a3dcdc1f 39
Christopher Haster 34:9c26a3dcdc1f 40 virtual int32_t disconnect();
Christopher Haster 34:9c26a3dcdc1f 41
Christopher Haster 34:9c26a3dcdc1f 42 // Implementation of NetworkInterface
Christopher Haster 34:9c26a3dcdc1f 43 virtual const char *getIPAddress();
Christopher Haster 34:9c26a3dcdc1f 44 virtual const char *getMACAddress();
Christopher Haster 34:9c26a3dcdc1f 45
Christopher Haster 34:9c26a3dcdc1f 46 virtual SocketInterface *createSocket(socket_protocol_t proto);
Christopher Haster 34:9c26a3dcdc1f 47 virtual void destroySocket(SocketInterface *socket);
Christopher Haster 34:9c26a3dcdc1f 48
Christopher Haster 34:9c26a3dcdc1f 49 private:
Christopher Haster 34:9c26a3dcdc1f 50 ESP8266 _esp;
sarahmarshy 18:9fc7976c7b27 51
Christopher Haster 34:9c26a3dcdc1f 52 bool _ids[ESP8266_SOCKET_COUNT];
Christopher Haster 34:9c26a3dcdc1f 53 const char *_ip_address;
Christopher Haster 34:9c26a3dcdc1f 54 const char *_mac_address;
sarahmarshy 18:9fc7976c7b27 55 };
sarahmarshy 18:9fc7976c7b27 56
Christopher Haster 34:9c26a3dcdc1f 57
sarahmarshy 18:9fc7976c7b27 58 #endif