ESP8266
Dependencies: mbed
ESP8266.h@1:edcfe804de99, 2017-12-10 (annotated)
- Committer:
- chanagan2540
- Date:
- Sun Dec 10 08:08:29 2017 +0000
- Revision:
- 1:edcfe804de99
- Parent:
- 0:3222c85ebd43
???;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chanagan2540 | 0:3222c85ebd43 | 1 | #ifndef ESP8266_H |
chanagan2540 | 0:3222c85ebd43 | 2 | #define ESP8266_H |
chanagan2540 | 0:3222c85ebd43 | 3 | |
chanagan2540 | 0:3222c85ebd43 | 4 | #include <string> |
chanagan2540 | 0:3222c85ebd43 | 5 | #include "mbed.h" |
chanagan2540 | 0:3222c85ebd43 | 6 | |
chanagan2540 | 0:3222c85ebd43 | 7 | class ESP8266 |
chanagan2540 | 0:3222c85ebd43 | 8 | { |
chanagan2540 | 0:3222c85ebd43 | 9 | public: |
chanagan2540 | 0:3222c85ebd43 | 10 | /** |
chanagan2540 | 0:3222c85ebd43 | 11 | * ESP8266 constructor |
chanagan2540 | 0:3222c85ebd43 | 12 | * |
chanagan2540 | 0:3222c85ebd43 | 13 | * @param tx TX pin |
chanagan2540 | 0:3222c85ebd43 | 14 | * @param rx RX pin |
chanagan2540 | 0:3222c85ebd43 | 15 | * @param br Baud Rate |
chanagan2540 | 0:3222c85ebd43 | 16 | */ |
chanagan2540 | 0:3222c85ebd43 | 17 | ESP8266(PinName tx, PinName rx, int br); |
chanagan2540 | 0:3222c85ebd43 | 18 | |
chanagan2540 | 0:3222c85ebd43 | 19 | /** |
chanagan2540 | 0:3222c85ebd43 | 20 | * ESP8266 destructor |
chanagan2540 | 0:3222c85ebd43 | 21 | */ |
chanagan2540 | 0:3222c85ebd43 | 22 | ~ESP8266(); |
chanagan2540 | 1:edcfe804de99 | 23 | |
chanagan2540 | 1:edcfe804de99 | 24 | void check(void); |
chanagan2540 | 1:edcfe804de99 | 25 | void look(void); |
chanagan2540 | 1:edcfe804de99 | 26 | void SetPath(char * t, char* o, char * v); |
chanagan2540 | 0:3222c85ebd43 | 27 | void Check(char * con); |
chanagan2540 | 0:3222c85ebd43 | 28 | void SendCMD(char * s); |
chanagan2540 | 0:3222c85ebd43 | 29 | void Reset(void); |
chanagan2540 | 0:3222c85ebd43 | 30 | void RcvReply(char * r, int to); |
chanagan2540 | 0:3222c85ebd43 | 31 | void GetList(char * l); |
chanagan2540 | 1:edcfe804de99 | 32 | void Join(char * id, char * pwd); |
chanagan2540 | 0:3222c85ebd43 | 33 | void GetIP(char * ip); |
chanagan2540 | 0:3222c85ebd43 | 34 | void SetMode(char mode); |
chanagan2540 | 0:3222c85ebd43 | 35 | void Quit(void); |
chanagan2540 | 0:3222c85ebd43 | 36 | void SetSingle(void); |
chanagan2540 | 0:3222c85ebd43 | 37 | void SetMultiple(void); |
chanagan2540 | 0:3222c85ebd43 | 38 | void GetConnStatus(char * st); |
chanagan2540 | 0:3222c85ebd43 | 39 | void StartServerMode(int port); |
chanagan2540 | 0:3222c85ebd43 | 40 | void CloseServerMode(void); |
chanagan2540 | 0:3222c85ebd43 | 41 | |
chanagan2540 | 0:3222c85ebd43 | 42 | private: |
chanagan2540 | 0:3222c85ebd43 | 43 | Serial comm; |
chanagan2540 | 0:3222c85ebd43 | 44 | void AddEOL(char * s); |
chanagan2540 | 0:3222c85ebd43 | 45 | void AddChar(char * s, char c); |
chanagan2540 | 0:3222c85ebd43 | 46 | void itoa(int c, char s[]); |
chanagan2540 | 0:3222c85ebd43 | 47 | |
chanagan2540 | 0:3222c85ebd43 | 48 | }; |
chanagan2540 | 0:3222c85ebd43 | 49 | |
chanagan2540 | 0:3222c85ebd43 | 50 | #endif |
chanagan2540 | 0:3222c85ebd43 | 51 | /* |
chanagan2540 | 0:3222c85ebd43 | 52 | COMMAND TABLE |
chanagan2540 | 0:3222c85ebd43 | 53 | Basic: |
chanagan2540 | 0:3222c85ebd43 | 54 | AT: Just to generate "OK" reply |
chanagan2540 | 0:3222c85ebd43 | 55 | Wifi: |
chanagan2540 | 0:3222c85ebd43 | 56 | AT+RST: restart the module |
chanagan2540 | 0:3222c85ebd43 | 57 | AT+CWMODE: define wifi mode; AT+CWMODE=<mode> 1= Sta, 2= AP, 3=both; Inquiry: AT+CWMODE? or AT+CWMODE=? |
chanagan2540 | 0:3222c85ebd43 | 58 | AT+CWJAP: join the AP wifi; AT+ CWJAP =<ssid>,< pwd > - ssid = ssid, pwd = wifi password, both between quotes; Inquiry: AT+ CWJAP? |
chanagan2540 | 0:3222c85ebd43 | 59 | AT+CWLAP: list the AP wifi |
chanagan2540 | 0:3222c85ebd43 | 60 | AT+CWQAP: quit the AP wifi; Inquiry: AT+CWQAP=? |
chanagan2540 | 0:3222c85ebd43 | 61 | * AT+CWSAP: set the parameters of AP; AT+CWSAP= <ssid>,<pwd>,<chl>,<ecn> - ssid, pwd, chl = channel, ecn = encryption; Inquiry: AT+CWJAP? |
chanagan2540 | 0:3222c85ebd43 | 62 | TCP/IP: |
chanagan2540 | 0:3222c85ebd43 | 63 | AT+CIPSTATUS: get the connection status |
chanagan2540 | 0:3222c85ebd43 | 64 | * AT+CIPSTART: set up TCP or UDP connection 1)single connection (+CIPMUX=0) AT+CIPSTART= <type>,<addr>,<port>; 2) multiple connection (+CIPMUX=1) AT+CIPSTART= <id><type>,<addr>, <port> - id = 0-4, type = TCP/UDP, addr = IP address, port= port; Inquiry: AT+CIPSTART=? |
chanagan2540 | 0:3222c85ebd43 | 65 | * AT+CIPSEND: send data; 1)single connection(+CIPMUX=0) AT+CIPSEND=<length>; 2) multiple connection (+CIPMUX=1) AT+CIPSEND= <id>,<length>; Inquiry: AT+CIPSEND=? |
chanagan2540 | 0:3222c85ebd43 | 66 | * AT+CIPCLOSE: close TCP or UDP connection; AT+CIPCLOSE=<id> or AT+CIPCLOSE; Inquiry: AT+CIPCLOSE=? |
chanagan2540 | 0:3222c85ebd43 | 67 | AT+CIFSR: Get IP address; Inquiry: AT+ CIFSR=? |
chanagan2540 | 0:3222c85ebd43 | 68 | AT+CIPMUX: set mutiple connection; AT+ CIPMUX=<mode> - 0 for single connection 1 for mutiple connection; Inquiry: AT+CIPMUX? |
chanagan2540 | 0:3222c85ebd43 | 69 | AT+CIPSERVER: set as server; AT+ CIPSERVER= <mode>[,<port> ] - mode 0 to close server mode, mode 1 to open; port = port; Inquiry: AT+CIFSR=? |
chanagan2540 | 0:3222c85ebd43 | 70 | * +IPD: received data |
chanagan2540 | 0:3222c85ebd43 | 71 | */ |