![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
For test
Diff: ESP8266.h
- Revision:
- 34:65cd9c6eedb8
- Parent:
- 32:91b3f3162c6a
- Child:
- 35:90be2bc2a492
--- a/ESP8266.h Thu Feb 05 02:28:09 2015 +0000 +++ b/ESP8266.h Thu Feb 05 03:38:10 2015 +0000 @@ -8,25 +8,44 @@ #include "time.h" #include "ArduinoSerial.h" +/** + * The way of SoftAP encrypstion. + * + */ typedef enum { - ESP8266_ECN_OPEN = 0, - ESP8266_ECN_WEP = 1, - ESP8266_ECN_WAP_PSK = 2, - ESP8266_ECN_WAP2_PSK = 3, - ESP8266_ECN_WAP_WAP2_PSK = 4, + ESP8266_ECN_OPEN = 0, /**< OPEN */ + ESP8266_ECN_WEP = 1, /**< WEP */ + ESP8266_ECN_WAP_PSK = 2, /**< WAP_PSK */ + ESP8266_ECN_WAP2_PSK = 3, /**< WAP2_PSK */ + ESP8266_ECN_WAP_WAP2_PSK = 4, /**< WAP_WAP2_PSK */ } ESP8266Encrypstion; +/** + * The ip protocol for communication. + * + * Only TCP or UPD supported. + */ typedef enum { - ESP8266_COMM_UDP = 0, - ESP8266_COMM_TCP = 1, + ESP8266_COMM_UDP = 0, /**< UPD */ + ESP8266_COMM_TCP = 1, /**< TCP */ } ESP8266CommMode; +/** + * The work mode. + * + * Station | SoftAP | Station + SoftAP. + */ typedef enum { - ESP8266_MODE_STA = 1, - ESP8266_MODE_SAP = 2, - ESP8266_MODE_STA_SAP = 3, + ESP8266_MODE_STA = 1, /**< Station */ + ESP8266_MODE_SAP = 2, /**< SoftAP */ + ESP8266_MODE_STA_SAP = 3, /**< Station + SoftAP */ } ESP8266WorkMode; +/** + * The channel for SoftAP. + * + * Only 1 - 13 acceptable. + */ typedef enum { ESP8266_CHANNEL_1 = 1, ESP8266_CHANNEL_2, @@ -43,8 +62,9 @@ ESP8266_CHANNEL_13, } ESP8266Channel; + /** - * Provide methods to manipulate ESP8266 via WiFi. + * Provide methods to manipulate ESP8266 for internet access via WiFi. */ class ESP8266 { @@ -96,76 +116,139 @@ bool setStationSoftAPMode(String ssid, String pwd, String sap_ssid, String sap_pwd , ESP8266Channel chl = ESP8266_CHANNEL_7, ESP8266Encrypstion ecn = ESP8266_ECN_WAP_WAP2_PSK); - + /** + * Start a TCP connection to server or init UDP communication. + */ bool ipConfig(uint8_t type, String addr, int port, uint8_t mux = 0, uint8_t id = 0); - //send data in sigle connection mode + + /** + * Send data in sigle connection mode(mux = 0). + * + */ bool send(String str); - //send data int multiple connection mode + /** + * Send data in multiple connection mode(mux = 1). + * + */ bool send(uint8_t id, String str); - + + /** + * Start to receive data from network. + */ int recvData(char *buf); - //reset the module + /** + * Get the current id of data received via member method:recvData in multiple connection mode. + */ + int getMuxID(void); + + /** + * Reset the module. + */ bool reset(void); - //set the working mode of module + + /** + * Set work mode. + * + */ bool confMode(uint8_t mode); - //set the name and password of wifi + + /** + * Join in AP. + * + */ bool confJAP(String ssid , String pwd); - //set the parametter of SSID, password, channel, encryption in AP mode. + + /** + * Set SoftAP Parameters. + * + */ bool confSAP(String ssid , String pwd , uint8_t chl , uint8_t ecn); - //inquire the current mode of wifi module + + /** + * Get current work mode. + * + */ String showMode(void); - //show the list of wifi hotspot + + /** + * Get the list of Access Points available. + * + */ String showAP(void); - //show the name of current wifi access port + /** + * Get the SSID of AP joined already. + */ String showJAP(void); - //quit the connection of current wifi + /** + * Quit the AP joined before. + */ bool quitAP(void); - //show the parameter of ssid, password, channel, encryption in AP mode + + /** + * Get SoftAP Parameters. + * + */ String showSAP(void); - //inquire the connection status + /** + * Get the status of connection. + * + */ String showStatus(void); - //show the current connection mode(sigle or multiple) + /** + * Get the connection mode(sigle or multiple) + */ String showMux(void); - //set the connection mode(sigle:0 or multiple:1) + /** + * Set the connection mode(sigle or multiple) + */ bool confMux(int mux); - //create new tcp or udp connection (sigle connection mode) + /** + * Create new tcp or udp connection in sigle connection mode. + */ bool newMux(uint8_t type, String addr, int port); - //create new tcp or udp connection (multiple connection mode)(id:0-4) + /** + * Create new tcp or udp connection in multiple connection mode)(id:0-4). + */ bool newMux(uint8_t id, uint8_t type, String addr, int port); - //close tcp or udp (sigle connection mode) + /** + * Close tcp or udp in sigle connection mode. + */ void closeMux(void); - //close tcp or udp (multiple connection mode) + /** + * Close tcp or udp in multiple connection mode. + */ void closeMux(uint8_t id); - //show the current ip address + /** + * Show the current ip address. + */ String showIP(void); - //set the parameter of server + /** + * Start or stop the TCP server. + */ bool confServer(uint8_t mode, int port); - // get m_mux_id - int getMuxID(void); - private: - ArduinoSerial m_uart; + ArduinoSerial m_uart; /* The UART to communicate with ESP8266 */ int m_mux_id; };