Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ESP8266 by
ESP8266.h
00001 #ifndef ESP8266_H 00002 #define ESP8266_H 00003 00004 #include <string> 00005 #include "mbed.h" 00006 00007 #define CMD_END "\r\n" 00008 00009 /** 00010 * Info about host to send data. 00011 * Owner: Name of who owns the host 00012 * Host: IP or address 00013 * GETstring: String to fill in sensor ID and data 00014 */ 00015 typedef struct { 00016 char* Owner; 00017 char* Host; 00018 char* GETstring; 00019 } HostInfo; 00020 00021 /** 00022 * Info about WiFi networks 00023 * Owner: Name of who owns the network 00024 * SSID: Name of the network 00025 * password: Password of the network 00026 */ 00027 typedef struct { 00028 char* Owner; 00029 char* SSID; 00030 char* password; 00031 } WifiInfo; 00032 00033 typedef enum { STATION = 1, ACCESS_POINT, BOTH} WiFiMode; 00034 00035 class ESP8266 { 00036 public: 00037 /** 00038 * ESP8266 constructor 00039 * 00040 * @param tx TX pin 00041 * @param rx RX pin 00042 * @param br Baud Rate 00043 */ 00044 ESP8266(PinName tx, PinName rx, int br); 00045 00046 /** 00047 * ESP8266 destructor 00048 */ 00049 ~ESP8266(); 00050 00051 void SendCMD(char *s); 00052 void Reset(void); 00053 bool RcvReply(char *r, int to); 00054 bool GetList(char *l); 00055 void Join(char *id, char *pwd); 00056 bool GetIP(char *ip); 00057 void SetMode(WiFiMode mode); 00058 void Quit(void); 00059 void SetSingle(void); 00060 void SetMultiple(void); 00061 bool GetConnStatus(char *st); 00062 void StartServerMode(int port); 00063 void CloseServerMode(void); 00064 void setTransparent(void); 00065 void startTCPConn(char *IP, int port); 00066 void sendURL(char *URL, char *IP, char *command); 00067 00068 void deepsleep(size_t ms); 00069 00070 private: 00071 Serial comm; 00072 void AddEOL(char * s); 00073 void AddChar(char * s, char c); 00074 }; 00075 00076 #endif //ESP8266_H 00077 /* 00078 COMMAND TABLE 00079 Basic: 00080 AT: Just to generate "OK" reply 00081 00082 Wifi: 00083 AT+RST: restart the module 00084 AT+CWMODE: define wifi mode; AT+CWMODE=<mode> 1= Sta, 2= AP, 3=both; Inquiry: AT+CWMODE? or AT+CWMODE=? 00085 AT+CWJAP: join the AP wifi; AT+ CWJAP =<ssid>,< pwd > - ssid = ssid, pwd = wifi password, both between quotes; Inquiry: AT+ CWJAP? 00086 AT+CWLAP: list the AP wifi 00087 AT+CWQAP: quit the AP wifi; Inquiry: AT+CWQAP=? 00088 * AT+CWSAP: set the parameters of AP; AT+CWSAP= <ssid>,<pwd>,<chl>,<ecn> - ssid, pwd, chl = channel, ecn = encryption; Inquiry: AT+CWJAP? 00089 00090 TCP/IP: 00091 AT+CIPSTATUS: get the connection status 00092 * 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=? 00093 * AT+CIPSEND: send data; 1)single connection(+CIPMUX=0) AT+CIPSEND=<length>; 2) multiple connection (+CIPMUX=1) AT+CIPSEND= <id>,<length>; Inquiry: AT+CIPSEND=? 00094 * AT+CIPCLOSE: close TCP or UDP connection; AT+CIPCLOSE=<id> or AT+CIPCLOSE; Inquiry: AT+CIPCLOSE=? 00095 AT+CIFSR: Get IP address; Inquiry: AT+ CIFSR=? 00096 AT+CIPMUX: set mutiple connection; AT+ CIPMUX=<mode> - 0 for single connection 1 for mutiple connection; Inquiry: AT+CIPMUX? 00097 AT+CIPSERVER: set as server; AT+ CIPSERVER= <mode>[,<port> ] - mode 0 to close server mode, mode 1 to open; port = port; Inquiry: AT+CIFSR=? 00098 * +IPD: received data 00099 */
Generated on Thu Jul 14 2022 13:36:25 by
1.7.2
