For test

Dependencies:   mbed

Committer:
shennongmin
Date:
Sat Jan 31 12:21:04 2015 +0000
Revision:
9:95a0ce98e12b
Parent:
8:577f955031ea
First example: WiFiTest passed!

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