For test

Dependencies:   mbed

Committer:
shennongmin
Date:
Mon Feb 02 09:46:16 2015 +0000
Revision:
10:9d4ec0359a5c
Parent:
uartWiFi.h@9:95a0ce98e12b
Child:
14:40b1decf03f3
Style remained

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shennongmin 10:9d4ec0359a5c 1 #ifndef __ESP8266_H__
shennongmin 10:9d4ec0359a5c 2 #define __ESP8266_H__
shennongmin 4:962bf18523f4 3
shennongmin 7:a11e381ce969 4 #include "mbed.h"
shennongmin 10:9d4ec0359a5c 5 #include "time.h"
shennongmin 10:9d4ec0359a5c 6 #include "ArduinoSerial.h"
shennongmin 7:a11e381ce969 7
shennongmin 4:962bf18523f4 8
shennongmin 4:962bf18523f4 9 //The way of encrypstion
shennongmin 7:a11e381ce969 10 #define ESP8266_ECN_OPEN 0
shennongmin 7:a11e381ce969 11 #define ESP8266_ECN_WEP 1
shennongmin 7:a11e381ce969 12 #define ESP8266_ECN_WAP_PSK 2
shennongmin 7:a11e381ce969 13 #define ESP8266_ECN_WAP2_PSK 3
shennongmin 7:a11e381ce969 14 #define ESP8266_ECN_WAP_WAP2_PSK 4
shennongmin 4:962bf18523f4 15
shennongmin 4:962bf18523f4 16 //Communication mode
shennongmin 7:a11e381ce969 17 #define ESP8266_TCP 1
shennongmin 7:a11e381ce969 18 #define ESP8266_UDP 0
shennongmin 4:962bf18523f4 19
shennongmin 9:95a0ce98e12b 20 //The type of initialized ESP8266
shennongmin 7:a11e381ce969 21 #define ESP8266_MODE_STA 1
shennongmin 7:a11e381ce969 22 #define ESP8266_MODE_SAP 2
shennongmin 7:a11e381ce969 23 #define ESP8266_MODE_STA_SAP 3
shennongmin 4:962bf18523f4 24
shennongmin 9:95a0ce98e12b 25 //Default channel
shennongmin 9:95a0ce98e12b 26 #define ESP8266_DEFAULT_CHANNEL (7) /* 1 - 13 */
shennongmin 4:962bf18523f4 27
shennongmin 10:9d4ec0359a5c 28 class ArduinoSerial;
shennongmin 10:9d4ec0359a5c 29
shennongmin 9:95a0ce98e12b 30 class ESP8266
shennongmin 4:962bf18523f4 31 {
shennongmin 4:962bf18523f4 32 public:
shennongmin 10:9d4ec0359a5c 33 ESP8266(PinName tx, PinName rx);
shennongmin 10:9d4ec0359a5c 34
shennongmin 4:962bf18523f4 35 void begin(void);
shennongmin 4:962bf18523f4 36
shennongmin 4:962bf18523f4 37 //Initialize port
shennongmin 10:9d4ec0359a5c 38 bool Initialize(uint8_t mode, String ssid, String pwd, uint8_t chl = ESP8266_DEFAULT_CHANNEL, uint8_t ecn = ESP8266_ECN_WAP_WAP2_PSK);
shennongmin 7:a11e381ce969 39
shennongmin 10:9d4ec0359a5c 40 bool ipConfig(uint8_t type, String addr, int port, uint8_t a = 0, uint8_t 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 10:9d4ec0359a5c 46 bool Send(uint8_t 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 10:9d4ec0359a5c 54 bool confMode(uint8_t 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 10:9d4ec0359a5c 60 bool confSAP(String ssid , String pwd , uint8_t chl , uint8_t 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 10:9d4ec0359a5c 87 bool newMux(uint8_t 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 10:9d4ec0359a5c 90 bool newMux(uint8_t id, uint8_t 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 10:9d4ec0359a5c 96 void closeMux(uint8_t 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 10:9d4ec0359a5c 102 bool confServer(uint8_t mode, int port);
shennongmin 4:962bf18523f4 103
shennongmin 10:9d4ec0359a5c 104 // get chlID
shennongmin 10:9d4ec0359a5c 105 int get_chlID(void);
shennongmin 10:9d4ec0359a5c 106
shennongmin 10:9d4ec0359a5c 107 private:
shennongmin 10:9d4ec0359a5c 108 ArduinoSerial esp_uart;
shennongmin 10:9d4ec0359a5c 109 int chlID;
shennongmin 4:962bf18523f4 110 };
shennongmin 9:95a0ce98e12b 111
shennongmin 10:9d4ec0359a5c 112 #endif /* #ifndef __ESP8266_H__ */