For test

Dependencies:   mbed

Committer:
shennongmin
Date:
Sat Jan 31 07:01:08 2015 +0000
Revision:
7:a11e381ce969
Parent:
6:a8cf39c768c4
Child:
8:577f955031ea
Start to transplant uart

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 7:a11e381ce969 4 #include "mbed.h"
shennongmin 4:962bf18523f4 5
shennongmin 7:a11e381ce969 6 #include "WString.h"
shennongmin 7:a11e381ce969 7
shennongmin 7:a11e381ce969 8 typedef unsigned char byte;
shennongmin 7:a11e381ce969 9
shennongmin 4:962bf18523f4 10
shennongmin 4:962bf18523f4 11 //The way of encrypstion
shennongmin 7:a11e381ce969 12 #define ESP8266_ECN_OPEN 0
shennongmin 7:a11e381ce969 13 #define ESP8266_ECN_WEP 1
shennongmin 7:a11e381ce969 14 #define ESP8266_ECN_WAP_PSK 2
shennongmin 7:a11e381ce969 15 #define ESP8266_ECN_WAP2_PSK 3
shennongmin 7:a11e381ce969 16 #define ESP8266_ECN_WAP_WAP2_PSK 4
shennongmin 4:962bf18523f4 17
shennongmin 4:962bf18523f4 18 //Communication mode
shennongmin 7:a11e381ce969 19 #define ESP8266_TCP 1
shennongmin 7:a11e381ce969 20 #define ESP8266_UDP 0
shennongmin 4:962bf18523f4 21
shennongmin 4:962bf18523f4 22 //The type of initialized WIFI
shennongmin 7:a11e381ce969 23 #define ESP8266_MODE_STA 1
shennongmin 7:a11e381ce969 24 #define ESP8266_MODE_SAP 2
shennongmin 7:a11e381ce969 25 #define ESP8266_MODE_STA_SAP 3
shennongmin 4:962bf18523f4 26
shennongmin 4:962bf18523f4 27
shennongmin 4:962bf18523f4 28 class WIFI
shennongmin 4:962bf18523f4 29 {
shennongmin 4:962bf18523f4 30 public:
shennongmin 4:962bf18523f4 31
shennongmin 4:962bf18523f4 32 void begin(void);
shennongmin 4:962bf18523f4 33
shennongmin 4:962bf18523f4 34 //Initialize port
shennongmin 4:962bf18523f4 35 bool Initialize(byte mode, String ssid, String pwd, byte chl = 1, byte ecn = 2);
shennongmin 7:a11e381ce969 36
shennongmin 7:a11e381ce969 37 bool ipConfig(byte type, String addr, int port, bool a = 0, byte id = 0);
shennongmin 4:962bf18523f4 38
shennongmin 7:a11e381ce969 39 //send data in sigle connection mode
shennongmin 7:a11e381ce969 40 bool Send(String str);
shennongmin 7:a11e381ce969 41
shennongmin 7:a11e381ce969 42 //send data int multiple connection mode
shennongmin 7:a11e381ce969 43 bool Send(byte id, String str);
shennongmin 4:962bf18523f4 44
shennongmin 4:962bf18523f4 45 int ReceiveMessage(char *buf);
shennongmin 4:962bf18523f4 46
shennongmin 7:a11e381ce969 47 //reset the module
shennongmin 7:a11e381ce969 48 void Reset(void);
shennongmin 7:a11e381ce969 49
shennongmin 7:a11e381ce969 50 //set the working mode of module
shennongmin 7:a11e381ce969 51 bool confMode(byte a);
shennongmin 7:a11e381ce969 52
shennongmin 7:a11e381ce969 53 //set the name and password of wifi
shennongmin 7:a11e381ce969 54 bool confJAP(String ssid , String pwd);
shennongmin 7:a11e381ce969 55
shennongmin 7:a11e381ce969 56 //set the parametter of SSID, password, channel, encryption in AP mode.
shennongmin 7:a11e381ce969 57 bool confSAP(String ssid , String pwd , byte chl , byte ecn);
shennongmin 4:962bf18523f4 58
shennongmin 7:a11e381ce969 59 //inquire the current mode of wifi module
shennongmin 7:a11e381ce969 60 String showMode(void);
shennongmin 7:a11e381ce969 61
shennongmin 7:a11e381ce969 62 //show the list of wifi hotspot
shennongmin 7:a11e381ce969 63 String showAP(void);
shennongmin 7:a11e381ce969 64
shennongmin 7:a11e381ce969 65 //show the name of current wifi access port
shennongmin 7:a11e381ce969 66 String showJAP(void);
shennongmin 7:a11e381ce969 67
shennongmin 7:a11e381ce969 68 //quit the connection of current wifi
shennongmin 7:a11e381ce969 69 bool quitAP(void);
shennongmin 7:a11e381ce969 70
shennongmin 7:a11e381ce969 71 //show the parameter of ssid, password, channel, encryption in AP mode
shennongmin 7:a11e381ce969 72 String showSAP(void);
shennongmin 4:962bf18523f4 73
shennongmin 7:a11e381ce969 74 //inquire the connection status
shennongmin 7:a11e381ce969 75 String showStatus(void);
shennongmin 7:a11e381ce969 76
shennongmin 7:a11e381ce969 77 //show the current connection mode(sigle or multiple)
shennongmin 7:a11e381ce969 78 String showMux(void);
shennongmin 7:a11e381ce969 79
shennongmin 7:a11e381ce969 80 //set the connection mode(sigle:0 or multiple:1)
shennongmin 7:a11e381ce969 81 bool confMux(bool a);
shennongmin 7:a11e381ce969 82
shennongmin 7:a11e381ce969 83 //create new tcp or udp connection (sigle connection mode)
shennongmin 7:a11e381ce969 84 bool newMux(byte type, String addr, int port);
shennongmin 4:962bf18523f4 85
shennongmin 7:a11e381ce969 86 //create new tcp or udp connection (multiple connection mode)(id:0-4)
shennongmin 7:a11e381ce969 87 bool newMux(byte id, byte type, String addr, int port);
shennongmin 7:a11e381ce969 88
shennongmin 7:a11e381ce969 89 //close tcp or udp (sigle connection mode)
shennongmin 7:a11e381ce969 90 void closeMux(void);
shennongmin 7:a11e381ce969 91
shennongmin 7:a11e381ce969 92 //close tcp or udp (multiple connection mode)
shennongmin 7:a11e381ce969 93 void closeMux(byte id);
shennongmin 7:a11e381ce969 94
shennongmin 7:a11e381ce969 95 //show the current ip address
shennongmin 7:a11e381ce969 96 String showIP(void);
shennongmin 7:a11e381ce969 97
shennongmin 7:a11e381ce969 98 //set the parameter of server
shennongmin 7:a11e381ce969 99 bool confServer(byte mode, int port);
shennongmin 4:962bf18523f4 100
shennongmin 4:962bf18523f4 101 };
shennongmin 4:962bf18523f4 102
shennongmin 6:a8cf39c768c4 103 #endif