pengfei wu
/
ESP8266Program
For test
Diff: uartWiFi.h
- Revision:
- 7:a11e381ce969
- Parent:
- 6:a8cf39c768c4
- Child:
- 8:577f955031ea
--- a/uartWiFi.h Fri Jan 30 15:02:02 2015 +0000 +++ b/uartWiFi.h Sat Jan 31 07:01:08 2015 +0000 @@ -1,34 +1,28 @@ -#if 0 #ifndef __UARTWIFI_H__ #define __UARTWIFI_H__ -#define debugBaudRate 9600 +#include "mbed.h" -#define DEBUG +#include "WString.h" + +typedef unsigned char byte; + -#define _cell Serial1 -#define DebugSerial Serial - //The way of encrypstion -#define OPEN 0 -#define WEP 1 -#define WAP_PSK 2 -#define WAP2_PSK 3 -#define WAP_WAP2_PSK 4 +#define ESP8266_ECN_OPEN 0 +#define ESP8266_ECN_WEP 1 +#define ESP8266_ECN_WAP_PSK 2 +#define ESP8266_ECN_WAP2_PSK 3 +#define ESP8266_ECN_WAP_WAP2_PSK 4 //Communication mode -#define TCP 1 -#define tcp 1 -#define UDP 0 -#define udp 0 - -#define OPEN 1 -#define CLOSE 0 +#define ESP8266_TCP 1 +#define ESP8266_UDP 0 //The type of initialized WIFI -#define STA 1 -#define AP 2 -#define AP_STA 3 +#define ESP8266_MODE_STA 1 +#define ESP8266_MODE_SAP 2 +#define ESP8266_MODE_STA_SAP 3 class WIFI @@ -39,40 +33,71 @@ //Initialize port bool Initialize(byte mode, String ssid, String pwd, byte chl = 1, byte ecn = 2); - boolean ipConfig(byte type, String addr, int port, boolean a = 0, byte id = 0); + + bool ipConfig(byte type, String addr, int port, bool a = 0, byte id = 0); - boolean Send(String str); //send data in sigle connection mode - boolean Send(byte id, String str); //send data int multiple connection mode + //send data in sigle connection mode + bool Send(String str); + + //send data int multiple connection mode + bool Send(byte id, String str); int ReceiveMessage(char *buf); - //String begin(void); - /*=================WIFI Function Command=================*/ - void Reset(void); //reset the module - bool confMode(byte a); //set the working mode of module - boolean confJAP(String ssid , String pwd); //set the name and password of wifi - boolean confSAP(String ssid , String pwd , byte chl , byte ecn); //set the parametter of SSID, password, channel, encryption in AP mode. + //reset the module + void Reset(void); + + //set the working mode of module + bool confMode(byte a); + + //set the name and password of wifi + bool confJAP(String ssid , String pwd); + + //set the parametter of SSID, password, channel, encryption in AP mode. + bool confSAP(String ssid , String pwd , byte chl , byte ecn); - String showMode(void); //inquire the current mode of wifi module - String showAP(void); //show the list of wifi hotspot - String showJAP(void); //show the name of current wifi access port - boolean quitAP(void); //quit the connection of current wifi - String showSAP(void); //show the parameter of ssid, password, channel, encryption in AP mode + //inquire the current mode of wifi module + String showMode(void); + + //show the list of wifi hotspot + String showAP(void); + + //show the name of current wifi access port + String showJAP(void); + + //quit the connection of current wifi + bool quitAP(void); + + //show the parameter of ssid, password, channel, encryption in AP mode + String showSAP(void); - /*================TCP/IP commands================*/ - String showStatus(void); //inquire the connection status - String showMux(void); //show the current connection mode(sigle or multiple) - boolean confMux(boolean a); //set the connection mode(sigle:0 or multiple:1) - boolean newMux(byte type, String addr, int port); //create new tcp or udp connection (sigle connection mode) - boolean newMux(byte id, byte type, String addr, int port); //create new tcp or udp connection (multiple connection mode)(id:0-4) - void closeMux(void); //close tcp or udp (sigle connection mode) - void closeMux(byte id); //close tcp or udp (multiple connection mode) - String showIP(void); //show the current ip address - boolean confServer(byte mode, int port); //set the parameter of server + //inquire the connection status + String showStatus(void); + + //show the current connection mode(sigle or multiple) + String showMux(void); + + //set the connection mode(sigle:0 or multiple:1) + bool confMux(bool a); + + //create new tcp or udp connection (sigle connection mode) + bool newMux(byte type, String addr, int port); - String m_rev; + //create new tcp or udp connection (multiple connection mode)(id:0-4) + bool newMux(byte id, byte type, String addr, int port); + + //close tcp or udp (sigle connection mode) + void closeMux(void); + + //close tcp or udp (multiple connection mode) + void closeMux(byte id); + + //show the current ip address + String showIP(void); + + //set the parameter of server + bool confServer(byte mode, int port); }; -#endif #endif \ No newline at end of file