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