blownelco Plaetevoet / ESP8266Interface

Fork of ESP8266Interface 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 
00025  /**
00026  * Interface using ESP8266 to connect to an IP-based network
00027  */
00028 class ESP8266Interface: public ESP8266 {
00029 public:
00030 
00031     /**
00032     * Constructor
00033     *
00034     * \param tx mbed pin to use for tx line of Serial interface
00035     * \param rx mbed pin to use for rx line of Serial interface
00036     * \param reset reset pin of the wifi module ()
00037     * \param ssid ssid of the network
00038     * \param phrase WEP or WPA key
00039     * \param baud the baudrate of the serial connection (defaults to 115200, diff revs of the firmware use diff baud rates
00040     */
00041   ESP8266Interface(PinName tx, PinName rx, PinName reset, const char * ssid, const char * phrase, uint32_t baud = 115200 );
00042 
00043   /** Initialize the interface with DHCP.
00044   * Initialize the interface and configure it to use DHCP (no connection at this point).
00045   * \return 0 on success, a negative number on failure
00046   */
00047   int init(); //With DHCP
00048 
00049   /** Connect
00050   * Bring the interface up, start DHCP if needed.
00051   * \return 0 on success, a negative number on failure
00052   */
00053   bool connect();
00054   
00055   /** Disconnect
00056   * Bring the interface down
00057   * \return 0 on success, a negative number on failure
00058   */
00059   int disconnect();
00060   
00061   /** Get IP address
00062   *
00063   * \return ip address
00064   */
00065   char* getIPAddress();
00066   
00067 private:
00068 };
00069 
00070 #include "UDPSocket.h"
00071 
00072 #endif /* ESP8266INTERFACE_H_ */