now this shit works

Dependencies:   BufferedSerial

Dependents:   IoTWeatherStation

Fork of ESP8266NodeMCUInterface by ESP8266

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ESP8266Interface.h Source File

ESP8266Interface.h

00001 /* ESP8266Interface.h */
00002 /* Copyright (C) 2012 mbed.org, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019  
00020 #ifndef ESP8266INTERFACE_H_
00021 #define ESP8266INTERFACE_H_
00022 
00023 #include "ESP8266.h"
00024 #include "Endpoint.h"
00025 
00026  /**
00027  * Interface using ESP8266 to connect to an IP-based network
00028  */
00029 class ESP8266Interface: public ESP8266 {
00030 public:
00031 
00032     /**
00033     * Constructor
00034     *
00035     * @param tx mbed pin to use for tx line of Serial interface
00036     * @param rx mbed pin to use for rx line of Serial interface
00037     * @param reset reset pin of the wifi module ()
00038     * @param baud the baudrate of the serial connection
00039     * @param timeout the timeout of the serial connection
00040     */
00041     ESP8266Interface(PinName tx, PinName rx, PinName reset, int baud = 9600, int timeout = 3000);
00042     
00043     /**
00044     * Initialize the wifi hardware
00045     *
00046     * @return true if successful
00047     */
00048     bool init();
00049 
00050     /**
00051     * Connect the wifi module to the specified ssid.
00052     *
00053     * @param ssid ssid of the network
00054     * @param phrase WEP, WPA or WPA2 key
00055     * @return true if successful
00056     */
00057     bool connect(const char *ssid, const char *phrase);
00058   
00059     /**
00060     * Disconnect the ESP8266 module from the access point
00061     *
00062     * @return true if successful
00063     */
00064     int disconnect();
00065   
00066     /** Get IP address
00067     *
00068     * @return Either a pointer to the internally stored IP address or null if not connected
00069     */
00070     const char *getIPAddress();
00071 };
00072 
00073 #include "UDPSocket.h"
00074 
00075 #endif /* ESP8266INTERFACE_H_ */