For test

Dependencies:   mbed

Committer:
shennongmin
Date:
Fri Jan 30 12:19:57 2015 +0000
Revision:
5:218b5decd1ea
Parent:
4:962bf18523f4
Child:
6:a8cf39c768c4
Add WString class and ready to transplant.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shennongmin 4:962bf18523f4 1 #ifndef __UARTWIFI_H__
shennongmin 4:962bf18523f4 2 #define __UARTWIFI_H__
shennongmin 4:962bf18523f4 3
shennongmin 4:962bf18523f4 4 #define debugBaudRate 9600
shennongmin 4:962bf18523f4 5
shennongmin 4:962bf18523f4 6 #define DEBUG
shennongmin 4:962bf18523f4 7
shennongmin 4:962bf18523f4 8 #define _cell Serial1
shennongmin 4:962bf18523f4 9 #define DebugSerial Serial
shennongmin 5:218b5decd1ea 10
shennongmin 4:962bf18523f4 11 //The way of encrypstion
shennongmin 4:962bf18523f4 12 #define OPEN 0
shennongmin 4:962bf18523f4 13 #define WEP 1
shennongmin 4:962bf18523f4 14 #define WAP_PSK 2
shennongmin 4:962bf18523f4 15 #define WAP2_PSK 3
shennongmin 4:962bf18523f4 16 #define WAP_WAP2_PSK 4
shennongmin 4:962bf18523f4 17
shennongmin 4:962bf18523f4 18 //Communication mode
shennongmin 4:962bf18523f4 19 #define TCP 1
shennongmin 4:962bf18523f4 20 #define tcp 1
shennongmin 4:962bf18523f4 21 #define UDP 0
shennongmin 4:962bf18523f4 22 #define udp 0
shennongmin 4:962bf18523f4 23
shennongmin 4:962bf18523f4 24 #define OPEN 1
shennongmin 4:962bf18523f4 25 #define CLOSE 0
shennongmin 4:962bf18523f4 26
shennongmin 4:962bf18523f4 27 //The type of initialized WIFI
shennongmin 4:962bf18523f4 28 #define STA 1
shennongmin 4:962bf18523f4 29 #define AP 2
shennongmin 4:962bf18523f4 30 #define AP_STA 3
shennongmin 4:962bf18523f4 31
shennongmin 4:962bf18523f4 32
shennongmin 4:962bf18523f4 33 class WIFI
shennongmin 4:962bf18523f4 34 {
shennongmin 4:962bf18523f4 35 public:
shennongmin 4:962bf18523f4 36
shennongmin 4:962bf18523f4 37 void begin(void);
shennongmin 4:962bf18523f4 38
shennongmin 4:962bf18523f4 39 //Initialize port
shennongmin 4:962bf18523f4 40 bool Initialize(byte mode, String ssid, String pwd, byte chl = 1, byte ecn = 2);
shennongmin 4:962bf18523f4 41 boolean ipConfig(byte type, String addr, int port, boolean a = 0, byte id = 0);
shennongmin 4:962bf18523f4 42
shennongmin 4:962bf18523f4 43 boolean Send(String str); //send data in sigle connection mode
shennongmin 4:962bf18523f4 44 boolean Send(byte id, String str); //send data int multiple connection mode
shennongmin 4:962bf18523f4 45
shennongmin 4:962bf18523f4 46 int ReceiveMessage(char *buf);
shennongmin 4:962bf18523f4 47
shennongmin 4:962bf18523f4 48 //String begin(void);
shennongmin 4:962bf18523f4 49 /*=================WIFI Function Command=================*/
shennongmin 4:962bf18523f4 50 void Reset(void); //reset the module
shennongmin 4:962bf18523f4 51 bool confMode(byte a); //set the working mode of module
shennongmin 4:962bf18523f4 52 boolean confJAP(String ssid , String pwd); //set the name and password of wifi
shennongmin 4:962bf18523f4 53 boolean confSAP(String ssid , String pwd , byte chl , byte ecn); //set the parametter of SSID, password, channel, encryption in AP mode.
shennongmin 4:962bf18523f4 54
shennongmin 4:962bf18523f4 55 String showMode(void); //inquire the current mode of wifi module
shennongmin 4:962bf18523f4 56 String showAP(void); //show the list of wifi hotspot
shennongmin 4:962bf18523f4 57 String showJAP(void); //show the name of current wifi access port
shennongmin 4:962bf18523f4 58 boolean quitAP(void); //quit the connection of current wifi
shennongmin 4:962bf18523f4 59 String showSAP(void); //show the parameter of ssid, password, channel, encryption in AP mode
shennongmin 4:962bf18523f4 60
shennongmin 4:962bf18523f4 61 /*================TCP/IP commands================*/
shennongmin 4:962bf18523f4 62 String showStatus(void); //inquire the connection status
shennongmin 4:962bf18523f4 63 String showMux(void); //show the current connection mode(sigle or multiple)
shennongmin 4:962bf18523f4 64 boolean confMux(boolean a); //set the connection mode(sigle:0 or multiple:1)
shennongmin 4:962bf18523f4 65 boolean newMux(byte type, String addr, int port); //create new tcp or udp connection (sigle connection mode)
shennongmin 4:962bf18523f4 66 boolean newMux(byte id, byte type, String addr, int port); //create new tcp or udp connection (multiple connection mode)(id:0-4)
shennongmin 4:962bf18523f4 67 void closeMux(void); //close tcp or udp (sigle connection mode)
shennongmin 4:962bf18523f4 68 void closeMux(byte id); //close tcp or udp (multiple connection mode)
shennongmin 4:962bf18523f4 69 String showIP(void); //show the current ip address
shennongmin 4:962bf18523f4 70 boolean confServer(byte mode, int port); //set the parameter of server
shennongmin 4:962bf18523f4 71
shennongmin 4:962bf18523f4 72 String m_rev;
shennongmin 4:962bf18523f4 73
shennongmin 4:962bf18523f4 74 };
shennongmin 4:962bf18523f4 75
shennongmin 4:962bf18523f4 76 #endif