ESP8266 driver using the NodeMCU interface

Dependencies:   BufferedSerial

Dependents:   esp8266_nodeMCU1 esp8266_2_thingspeak1 Solarator_0-0-2 IoTBurglar_and_Fire_AlarmSystem ... more

Fork of ESP8266Interface by ESP8266

This is an alternative implementation of the ESP8266 driver that uses the NodeMCU firmware. The NodeMCU firmware provides a slightly larger feature set than the default firmware through a Lua interpreter.

Note

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

Interface changes

  • SSID and passphrase moved out of ESP8266Interface constructor and to ESP8266Interface::connect
  • ESP8266Interface constructor provides optional timeout parameter to specify how long to wait for network operations

Note

NodeMCU defaults to a baud rate of 9600 instead of 115200 used by the default firmware.

Firmware

To install the NodeMCU firmware, follow the instructions on the Firmware Update wiki page using the nodemcu_integer_0.9.6-dev_20150406.bin binary at address 0x00000 instead of boot_v1.1.bin and user1.bin.

Since the NodeMCU firmware defaults to a baud rate of 9600, the Serial Passthrough program can be used to get direct access to the Lua interpreter running on the ESP8266.

Status

Working features:

  • TCP Client
  • UDP Client Transmit (Currently only UDP Server can recieve messages)
  • Single Connection at a time
  • Station Mode (Connects to AP)
  • DNS Lookups

To be implemented:

  • TCP Server
  • UDP Server
  • UDP Client recieve
  • Multiple Connections tracked through Lua variables
  • AP Mode (Act as access point)
  • IPV6 support (Existing issue with NodeMCU)
Committer:
mbedAustin
Date:
Tue Apr 28 18:52:20 2015 +0000
Revision:
28:91e65e22e63a
Parent:
16:3f0efaa57a12
Child:
44:16da10e7b3f7
aquiring IP Address correctly, but not returning it from inner call level. Safety commit before mucking around

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"
michaeljkoster 16:3f0efaa57a12 24 #include "Endpoint.h"
samux 1:fb4494783863 25
screamer 6:5176e0864078 26 /**
michaeljkoster 13:41098c907200 27 * Interface using ESP8266 to connect to an IP-based network
samux 1:fb4494783863 28 */
michaeljkoster 13:41098c907200 29 class ESP8266Interface: public ESP8266 {
samux 1:fb4494783863 30 public:
samux 1:fb4494783863 31
samux 1:fb4494783863 32 /**
samux 1:fb4494783863 33 * Constructor
samux 1:fb4494783863 34 *
samux 1:fb4494783863 35 * \param tx mbed pin to use for tx line of Serial interface
samux 1:fb4494783863 36 * \param rx mbed pin to use for rx line of Serial interface
samux 1:fb4494783863 37 * \param reset reset pin of the wifi module ()
samux 1:fb4494783863 38 * \param ssid ssid of the network
samux 1:fb4494783863 39 * \param phrase WEP or WPA key
mbedAustin 28:91e65e22e63a 40 * \param baud the baudrate of the serial connection (defaults to 115200, diff revs of the firmware use diff baud rates
samux 1:fb4494783863 41 */
mbedAustin 28:91e65e22e63a 42 ESP8266Interface(PinName tx, PinName rx, PinName reset, const char * ssid, const char * phrase, uint32_t baud = 115200 );
samux 1:fb4494783863 43
samux 1:fb4494783863 44 /** Initialize the interface with DHCP.
samux 1:fb4494783863 45 * Initialize the interface and configure it to use DHCP (no connection at this point).
samux 1:fb4494783863 46 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 47 */
samux 1:fb4494783863 48 int init(); //With DHCP
samux 1:fb4494783863 49
samux 1:fb4494783863 50 /** Connect
samux 1:fb4494783863 51 * Bring the interface up, start DHCP if needed.
samux 1:fb4494783863 52 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 53 */
michaeljkoster 16:3f0efaa57a12 54 bool connect();
samux 1:fb4494783863 55
samux 1:fb4494783863 56 /** Disconnect
samux 1:fb4494783863 57 * Bring the interface down
samux 1:fb4494783863 58 * \return 0 on success, a negative number on failure
samux 1:fb4494783863 59 */
samux 1:fb4494783863 60 int disconnect();
samux 1:fb4494783863 61
samux 1:fb4494783863 62 /** Get IP address
samux 1:fb4494783863 63 *
screamer 6:5176e0864078 64 * \return ip address
samux 1:fb4494783863 65 */
samux 1:fb4494783863 66 char* getIPAddress();
samux 1:fb4494783863 67
samux 1:fb4494783863 68 private:
samux 1:fb4494783863 69 };
samux 1:fb4494783863 70
samux 1:fb4494783863 71 #include "UDPSocket.h"
samux 1:fb4494783863 72
michaeljkoster 13:41098c907200 73 #endif /* ESP8266INTERFACE_H_ */