ESP8266 Socket Library. AT Thinker firmware.

Dependents:   ESP8266_MQTT_HelloWorld ESP8266_IFTTT_Test ECE_4180_Lab_4 websocketmbed ... more

Fork of ESP8266Interface by ESP8266

This repository has been superceded

This project has moved to https://developer.mbed.org/teams/ESP8266/code/esp8266-driver/

This library works with the AT Thinker firmware.

Note

This library is currently in Beta. It is not feature complete and has some bugs, proceed with caution! Fixes and patches are welcome and appreciated!

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 implemented

  • 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:
michaeljkoster
Date:
Sun Nov 30 21:37:16 2014 +0000
Revision:
14:4d1128f72e00
Parent:
13:41098c907200
Child:
16:3f0efaa57a12
Add getIPAddress

Who changed what in which revision?

UserRevisionLine numberNew contents of line
michaeljkoster 13:41098c907200 1 /* ESP8266Interface.h */
mbed_official 0:302ec35139ec 2 /* Copyright (C) 2012 mbed.org, MIT License
mbed_official 0:302ec35139ec 3 *
mbed_official 0:302ec35139ec 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 0:302ec35139ec 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mbed_official 0:302ec35139ec 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mbed_official 0:302ec35139ec 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mbed_official 0:302ec35139ec 8 * furnished to do so, subject to the following conditions:
mbed_official 0:302ec35139ec 9 *
mbed_official 0:302ec35139ec 10 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 0:302ec35139ec 11 * substantial portions of the Software.
mbed_official 0:302ec35139ec 12 *
mbed_official 0:302ec35139ec 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 0:302ec35139ec 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 0:302ec35139ec 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 0:302ec35139ec 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:302ec35139ec 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 0:302ec35139ec 18 */
mbed_official 0:302ec35139ec 19
michaeljkoster 13:41098c907200 20 #ifndef ESP8266INTERFACE_H_
michaeljkoster 13:41098c907200 21 #define ESP8266INTERFACE_H_
mbed_official 0:302ec35139ec 22
michaeljkoster 13:41098c907200 23 #include "ESP8266.h"
samux 1:fb4494783863 24
screamer 6:5176e0864078 25 /**
michaeljkoster 13:41098c907200 26 * Interface using ESP8266 to connect to an IP-based network
samux 1:fb4494783863 27 */
michaeljkoster 13:41098c907200 28 class ESP8266Interface: public ESP8266 {
samux 1:fb4494783863 29 public:
samux 1:fb4494783863 30
samux 1:fb4494783863 31 /**
samux 1:fb4494783863 32 * Constructor
samux 1:fb4494783863 33 *
samux 1:fb4494783863 34 * \param tx mbed pin to use for tx line of Serial interface
samux 1:fb4494783863 35 * \param rx mbed pin to use for rx line of Serial interface
samux 1:fb4494783863 36 * \param reset reset pin of the wifi module ()
samux 1:fb4494783863 37 * \param ssid ssid of the network
samux 1:fb4494783863 38 * \param phrase WEP or WPA key
samux 1:fb4494783863 39 */
michaeljkoster 13:41098c907200 40 ESP8266Interface(PinName tx, PinName rx, PinName reset, const char * ssid, const char * phrase );
samux 1:fb4494783863 41
samux 1:fb4494783863 42 /** Initialize the interface with DHCP.
samux 1:fb4494783863 43 * Initialize the interface and configure it to use DHCP (no connection at this point).
samux 1:fb4494783863 44 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 45 */
samux 1:fb4494783863 46 int init(); //With DHCP
samux 1:fb4494783863 47
samux 1:fb4494783863 48 /** Connect
samux 1:fb4494783863 49 * Bring the interface up, start DHCP if needed.
samux 1:fb4494783863 50 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 51 */
samux 1:fb4494783863 52 int connect();
samux 1:fb4494783863 53
samux 1:fb4494783863 54 /** Disconnect
samux 1:fb4494783863 55 * Bring the interface down
samux 1:fb4494783863 56 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 57 */
samux 1:fb4494783863 58 int disconnect();
samux 1:fb4494783863 59
samux 1:fb4494783863 60 /** Get IP address
samux 1:fb4494783863 61 *
screamer 6:5176e0864078 62 * \return ip address
samux 1:fb4494783863 63 */
samux 1:fb4494783863 64 char* getIPAddress();
samux 1:fb4494783863 65
samux 1:fb4494783863 66 private:
samux 1:fb4494783863 67 };
samux 1:fb4494783863 68
samux 1:fb4494783863 69 #include "UDPSocket.h"
samux 1:fb4494783863 70
michaeljkoster 13:41098c907200 71 #endif /* ESP8266INTERFACE_H_ */