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.
ESP8266_HardSer.h
00001 /** 00002 * @file ESP8266.h 00003 * @brief The definition of class ESP8266. 00004 * @author Wu Pengfei<pengfei.wu@itead.cc> 00005 * @date 2015.02 00006 * 00007 * @par Copyright: 00008 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License as 00011 * published by the Free Software Foundation; either version 2 of 00012 * the License, or (at your option) any later version. \n\n 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00014 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00015 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00016 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00017 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00018 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00019 * THE SOFTWARE. 00020 */ 00021 #ifndef __ESP8266_H__ 00022 #define __ESP8266_H__ 00023 00024 //#include "Arduino.h" 00025 #include "mbed.h" 00026 #include "WString.h" 00027 00028 extern Timer g_Timer; 00029 extern Serial pc; 00030 //#define LOG_ESP8266 00031 #ifdef LOG_ESP8266 00032 #define ESP8266_LOG pc.printf 00033 #define LOG_ENTER ESP8266_LOG("Enter %s\r\n", __func__); 00034 #else 00035 #define ESP8266_LOG(...) 00036 #define LOG_ENTER 00037 #endif 00038 00039 //#define ESP8266_USE_SOFTWARE_SERIAL 00040 00041 #ifdef ESP8266_USE_SOFTWARE_SERIAL 00042 //#include "SoftwareSerial.h" 00043 #define SoftwareSerial Serial 00044 #else 00045 #define HardwareSerial Serial 00046 #endif 00047 00048 #define VERSION_18 0X18 00049 #define VERSION_22 0X22 00050 #define DEFAULT_PATTERN 3 00051 00052 /** 00053 * You can modify the macro to choose a different version 00054 */ 00055 00056 #define USER_SEL_VERSION VERSION_22 00057 00058 /** 00059 * Provide an easy-to-use way to manipulate ESP8266. 00060 */ 00061 class ESP8266 { 00062 public: 00063 00064 typedef void (*onData)(uint8_t mux_id, uint32_t len, void* ptr); 00065 00066 #ifdef ESP8266_USE_SOFTWARE_SERIAL 00067 /* 00068 * Constuctor. 00069 * 00070 * @param uart - an reference of SoftwareSerial object. 00071 * @warning parameter baud depends on the AT firmware. 9600 is an common value. 00072 */ 00073 00074 ESP8266(SoftwareSerial &uart); 00075 00076 SoftwareSerial* getUart() { return m_puart; } 00077 00078 #else /* HardwareSerial */ 00079 /* 00080 * Constuctor. 00081 * 00082 * @param uart - an reference of HardwareSerial object. 00083 * @warning parameter baud depends on the AT firmware. 9600 is an common value. 00084 */ 00085 00086 ESP8266(HardwareSerial &uart); 00087 00088 HardwareSerial* getUart() { return m_puart; } 00089 00090 #endif /* #ifdef ESP8266_USE_SOFTWARE_SERIAL */ 00091 00092 void setOnData(onData cbk, void* ptr) { 00093 m_onData = cbk; 00094 m_onDataPtr = ptr; 00095 } 00096 00097 void run(); 00098 00099 /** 00100 * Verify ESP8266 whether live or not. 00101 * 00102 * Actually, this method will send command "AT" to ESP8266 and waiting for "OK". 00103 * 00104 * @retval true - alive. 00105 * @retval false - dead. 00106 */ 00107 bool kick(void); 00108 00109 /** 00110 * Restart ESP8266 by "AT+RST". 00111 * 00112 * This method will take 3 seconds or more. 00113 * 00114 * @retval true - success. 00115 * @retval false - failure. 00116 */ 00117 bool restart(void); 00118 00119 /** 00120 * Get the version of AT Command Set. 00121 * 00122 * @return the string of version. 00123 */ 00124 String getVersion(void); 00125 00126 /** 00127 * Start function of deep sleep. 00128 * 00129 * @param time - the sleep time. 00130 * @retval true - success. 00131 * @retval false - failure. 00132 * @note the feature requires hardware support. 00133 */ 00134 bool deepSleep(uint32_t time); 00135 00136 /** 00137 * Switch the echo function. 00138 * 00139 * @param mode - 1 start echo -0 stop echo 00140 * @retval true - success. 00141 * @retval false - failure. 00142 * 00143 */ 00144 bool setEcho(uint8_t mode); 00145 00146 /** 00147 * Restore factory. 00148 * @retval true - success. 00149 * @retval false - failure. 00150 * @note The operation can lead to restart the machine. 00151 */ 00152 bool restore(void); 00153 00154 /** 00155 * Set up a serial port configuration. 00156 * 00157 * @param pattern -1 send "AT+UART=", -2 send "AT+UART_CUR=", -3 send "AT+UART_DEF=". 00158 * @param baudrate - the uart baudrate. 00159 * @retval true - success. 00160 * @retval false - failure. 00161 * @note Only allows baud rate design, for the other parameters:databits- 8,stopbits -1,parity -0,flow control -0 . 00162 */ 00163 bool setUart(uint32_t baudrate,uint8_t pattern); 00164 00165 /** 00166 * Set operation mode to station. 00167 * 00168 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". 00169 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". 00170 * @retval true - success. 00171 * @retval false - failure. 00172 * 00173 */ 00174 bool setOprToStation(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); 00175 00176 /** 00177 * Get the model values list. 00178 * 00179 * @return the list of model. 00180 */ 00181 String getWifiModeList(void); 00182 00183 /** 00184 * Set operation mode to softap. 00185 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". 00186 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". 00187 * 00188 * @retval true - success. 00189 * @retval false - failure. 00190 */ 00191 bool setOprToSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); 00192 00193 /** 00194 * Set operation mode to station + softap. 00195 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". 00196 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". 00197 * 00198 * @retval true - success. 00199 * @retval false - failure. 00200 */ 00201 bool setOprToStationSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); 00202 00203 /** 00204 * Get the operation mode. 00205 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". 00206 * 00207 * @retval 0 - failure. 00208 * @retval 1 - mode Station. 00209 * @retval 2 - mode AP. 00210 * @retval 3 - mode AP + station. 00211 */ 00212 uint8_t getOprMode(uint8_t pattern1=DEFAULT_PATTERN); 00213 00214 /** 00215 * Search available AP list and return it. 00216 * 00217 * @return the list of available APs. 00218 * @note This method will occupy a lot of memeory(hundreds of Bytes to a couple of KBytes). 00219 * Do not call this method unless you must and ensure that your board has enough memery left. 00220 */ 00221 String getAPList(void); 00222 00223 /** 00224 * Search and returns the current connect AP. 00225 * 00226 * @param pattern -1, send "AT+CWJAP_DEF?",-2,send "AT+CWJAP_CUR?",-3,send "AT+CWJAP?". 00227 * @return the ssid of AP connected now. 00228 */ 00229 String getNowConecAp(uint8_t pattern=DEFAULT_PATTERN); 00230 00231 /** 00232 * Join in AP. 00233 * 00234 * @param pattern -1 send "AT+CWJAP_DEF=" -2 send "AT+CWJAP_CUR=" -3 send "AT+CWJAP=". 00235 * @param ssid - SSID of AP to join in. 00236 * @param pwd - Password of AP to join in. 00237 * @retval true - success. 00238 * @retval false - failure. 00239 * @note This method will take a couple of seconds. 00240 */ 00241 bool joinAP(String ssid, String pwd,uint8_t pattern=DEFAULT_PATTERN); 00242 00243 /** 00244 * Leave AP joined before. 00245 * 00246 * @retval true - success. 00247 * @retval false - failure. 00248 */ 00249 bool leaveAP(void); 00250 00251 /** 00252 * Set SoftAP parameters. 00253 * 00254 * @param pattern -1 send "AT+CWSAP_DEF=" -2 send "AT+CWSAP_CUR=" -3 send "AT+CWSAP=". 00255 * @param ssid - SSID of SoftAP. 00256 * @param pwd - PASSWORD of SoftAP. 00257 * @param chl - the channel (1 - 13, default: 7). 00258 * @param ecn - the way of encrypstion (0 - OPEN, 1 - WEP, 00259 * 2 - WPA_PSK, 3 - WPA2_PSK, 4 - WPA_WPA2_PSK, default: 4). 00260 * @retval true - success. 00261 * @retval false - failure. 00262 * @note This method should not be called when station mode. 00263 */ 00264 bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4,uint8_t pattern=DEFAULT_PATTERN); 00265 00266 /** 00267 * get SoftAP parameters. 00268 * 00269 * @param pattern -1 send "AT+CWSAP_DEF?" -2 send "AT+CWSAP_CUR?" -3 send "AT+CWSAP?". 00270 * @note This method should not be called when station mode. 00271 */ 00272 String getSoftAPParam(uint8_t pattern=DEFAULT_PATTERN); 00273 00274 /** 00275 * Get the IP list of devices connected to SoftAP. 00276 * 00277 * @return the list of IP. 00278 * @note This method should not be called when station mode. 00279 */ 00280 String getJoinedDeviceIP(void); 00281 00282 /** 00283 * Get the current state of DHCP. 00284 * 00285 * @param pattern -1 send "AT+CWDHCP_DEF?" -2 send "AT+CWDHCP_CUR?" -3 send "AT+CWDHCP?". 00286 * @return the state of DHCP. 00287 * 00288 */ 00289 String getDHCP(uint8_t pattern=DEFAULT_PATTERN); 00290 00291 /** 00292 * Set the state of DHCP. 00293 * @param pattern -1 send "AT+CWDHCP_DEF=" -2 send "AT+CWDHCP_CUR=" -3 send "AT+CWDHCP=". 00294 * @param mode - set ap or set station or set ap + station. 00295 * @param en - 0 disable DHCP - 1 enable DHCP. 00296 * @retval true - success. 00297 * @retval false - failure. 00298 */ 00299 bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=DEFAULT_PATTERN); 00300 00301 /** 00302 * make boot automatically connected. 00303 * @param en -1 enable -0 disable. 00304 * @retval true - success. 00305 * @retval false - failure. 00306 */ 00307 bool setAutoConnect(uint8_t en); 00308 00309 /** 00310 * Get the station's MAC address. 00311 * @param pattern -1 send "AT+CIPSTAMAC_DEF?=" -2 send "AT+CIPSTAMAC_CUR?" -3 send "AT+CIPSTAMAC?". 00312 * @return mac address. 00313 * @note This method should not be called when ap mode. 00314 */ 00315 String getStationMac(uint8_t pattern=DEFAULT_PATTERN); 00316 00317 /** 00318 * Set the station's MAC address. 00319 * @param pattern -1 send "AT+CIPSTAMAC_DEF=" -2 send "AT+CIPSTAMAC_CUR=" -3 send "AT+CIPSTAMAC=". 00320 * @param mac - the mac address of station. 00321 * @retval true - success. 00322 * @retval false - failure. 00323 */ 00324 bool setStationMac(String mac,uint8_t pattern=DEFAULT_PATTERN); 00325 00326 /** 00327 * Get the station's IP. 00328 * @param pattern -1 send "AT+CIPSTA_DEF?" -2 send "AT+CIPSTA_CUR?" -3 send "AT+CIPSTA?". 00329 * @return the station's IP. 00330 * @note This method should not be called when ap mode. 00331 */ 00332 String getStationIp(uint8_t pattern=DEFAULT_PATTERN); 00333 00334 /** 00335 * Set the station's IP. 00336 * @param pattern -1 send "AT+CIPSTA_DEF=" -2 send "AT+CIPSTA_CUR=" -3 send "AT+CIPSTA=". 00337 * @param ip - the ip of station. 00338 * @param gateway -the gateway of station. 00339 * @param netmask -the netmask of station. 00340 * @retval true - success. 00341 * @retval false - failure. 00342 * @note This method should not be called when ap mode. 00343 */ 00344 bool setStationIp(String ip,String gateway,String netmask,uint8_t pattern=DEFAULT_PATTERN); 00345 00346 /** 00347 * Get the AP's IP. 00348 * @param pattern -1 send "AT+CIPAP_DEF?" -2 send "AT+CIPAP_CUR?" -3 send "AT+CIPAP?". 00349 * @return ap's ip. 00350 * @note This method should not be called when station mode. 00351 * 00352 */ 00353 String getAPIp(uint8_t pattern=DEFAULT_PATTERN); 00354 00355 /** 00356 * Set the AP IP. 00357 * @param pattern -1 send "AT+CIPAP_DEF=" -2 send "AT+CIPAP_CUR=" -3 send "AT+CIPAP=". 00358 * @param ip - the ip of AP. 00359 * @retval true - success. 00360 * @retval false - failure. 00361 * @note This method should not be called when station mode. 00362 */ 00363 bool setAPIp(String ip,uint8_t pattern=DEFAULT_PATTERN); 00364 00365 /** 00366 * start smartconfig. 00367 * @param type -1:ESP_TOUCH -2:AirKiss. 00368 * @retval true - success. 00369 * @retval false - failure. 00370 */ 00371 bool startSmartConfig(uint8_t type); 00372 00373 /** 00374 * stop smartconfig. 00375 * 00376 * @retval true - success. 00377 * @retval false - failure. 00378 */ 00379 bool stopSmartConfig(void); 00380 00381 /** 00382 * Get the current status of connection(UDP and TCP). 00383 * 00384 * @return the status. 00385 */ 00386 String getIPStatus(void); 00387 00388 /** 00389 * Get the IP address of ESP8266. 00390 * 00391 * @return the IP list. 00392 */ 00393 String getLocalIP(void); 00394 00395 /** 00396 * Enable IP MUX(multiple connection mode). 00397 * 00398 * In multiple connection mode, a couple of TCP and UDP communication can be builded. 00399 * They can be distinguished by the identifier of TCP or UDP named mux_id. 00400 * 00401 * @retval true - success. 00402 * @retval false - failure. 00403 */ 00404 bool enableMUX(void); 00405 00406 /** 00407 * Disable IP MUX(single connection mode). 00408 * 00409 * In single connection mode, only one TCP or UDP communication can be builded. 00410 * 00411 * @retval true - success. 00412 * @retval false - failure. 00413 */ 00414 bool disableMUX(void); 00415 00416 /** 00417 * Create TCP connection in single mode. 00418 * 00419 * @param addr - the IP or domain name of the target host. 00420 * @param port - the port number of the target host. 00421 * @retval true - success. 00422 * @retval false - failure. 00423 */ 00424 bool createTCP(String addr, uint32_t port); 00425 00426 /** 00427 * Release TCP connection in single mode. 00428 * 00429 * @retval true - success. 00430 * @retval false - failure. 00431 */ 00432 bool releaseTCP(void); 00433 00434 /** 00435 * Register UDP port number in single mode. 00436 * 00437 * @param addr - the IP or domain name of the target host. 00438 * @param port - the port number of the target host. 00439 * @retval true - success. 00440 * @retval false - failure. 00441 */ 00442 bool registerUDP(String addr, uint32_t port); 00443 00444 /** 00445 * Unregister UDP port number in single mode. 00446 * 00447 * @retval true - success. 00448 * @retval false - failure. 00449 */ 00450 bool unregisterUDP(void); 00451 00452 /** 00453 * Create TCP connection in multiple mode. 00454 * 00455 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00456 * @param addr - the IP or domain name of the target host. 00457 * @param port - the port number of the target host. 00458 * @retval true - success. 00459 * @retval false - failure. 00460 */ 00461 bool createTCP(uint8_t mux_id, String addr, uint32_t port); 00462 00463 /** 00464 * Release TCP connection in multiple mode. 00465 * 00466 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00467 * @retval true - success. 00468 * @retval false - failure. 00469 */ 00470 bool releaseTCP(uint8_t mux_id); 00471 00472 /** 00473 * Register UDP port number in multiple mode. 00474 * 00475 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00476 * @param addr - the IP or domain name of the target host. 00477 * @param port - the port number of the target host. 00478 * @retval true - success. 00479 * @retval false - failure. 00480 */ 00481 bool registerUDP(uint8_t mux_id, String addr, uint32_t port); 00482 00483 /** 00484 * Unregister UDP port number in multiple mode. 00485 * 00486 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00487 * @retval true - success. 00488 * @retval false - failure. 00489 */ 00490 bool unregisterUDP(uint8_t mux_id); 00491 00492 /** 00493 * Set the timeout of TCP Server. 00494 * 00495 * @param timeout - the duration for timeout by second(0 ~ 28800, default:180). 00496 * @retval true - success. 00497 * @retval false - failure. 00498 */ 00499 bool setTCPServerTimeout(uint32_t timeout = 180); 00500 00501 /** 00502 * Start TCP Server(Only in multiple mode). 00503 * 00504 * After started, user should call method: getIPStatus to know the status of TCP connections. 00505 * The methods of receiving data can be called for user's any purpose. After communication, 00506 * release the TCP connection is needed by calling method: releaseTCP with mux_id. 00507 * 00508 * @param port - the port number to listen(default: 333). 00509 * @retval true - success. 00510 * @retval false - failure. 00511 * 00512 * @see String getIPStatus(void); 00513 * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout); 00514 * @see bool releaseTCP(uint8_t mux_id); 00515 */ 00516 bool startTCPServer(uint32_t port = 333); 00517 00518 /** 00519 * Stop TCP Server(Only in multiple mode). 00520 * 00521 * @retval true - success. 00522 * @retval false - failure. 00523 */ 00524 bool stopTCPServer(void); 00525 00526 /** 00527 *Set the module transfer mode 00528 * 00529 * @retval true - success. 00530 * @retval false - failure. 00531 */ 00532 bool setCIPMODE(uint8_t mode); 00533 00534 /** 00535 * Start Server(Only in multiple mode). 00536 * 00537 * @param port - the port number to listen(default: 333). 00538 * @retval true - success. 00539 * @retval false - failure. 00540 * 00541 * @see String getIPStatus(void); 00542 * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout); 00543 */ 00544 bool startServer(uint32_t port = 333); 00545 00546 /** 00547 * Stop Server(Only in multiple mode). 00548 * 00549 * @retval true - success. 00550 * @retval false - failure. 00551 */ 00552 bool stopServer(void); 00553 /** 00554 * Save the passthrough links 00555 * 00556 * @retval true - success. 00557 * @retval false - failure. 00558 */ 00559 bool saveTransLink (uint8_t mode,String ip,uint32_t port); 00560 00561 /** 00562 * PING COMMAND. 00563 * 00564 * @retval true - success. 00565 * @retval false - failure. 00566 */ 00567 bool setPing(String ip); 00568 00569 /** 00570 * Send data based on TCP or UDP builded already in single mode. 00571 * 00572 * @param buffer - the buffer of data to send. 00573 * @param len - the length of data to send. 00574 * @retval true - success. 00575 * @retval false - failure. 00576 */ 00577 bool send(const uint8_t *buffer, uint32_t len); 00578 00579 /** 00580 * Send data based on one of TCP or UDP builded already in multiple mode. 00581 * 00582 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00583 * @param buffer - the buffer of data to send. 00584 * @param len - the length of data to send. 00585 * @retval true - success. 00586 * @retval false - failure. 00587 */ 00588 bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len); 00589 00590 /** 00591 * Send data based on TCP or UDP builded already in single mode. 00592 * 00593 * @param buffer - the buffer of data to send from flash memeory. 00594 * @param len - the length of data to send. 00595 * @retval true - success. 00596 * @retval false - failure. 00597 */ 00598 bool sendFromFlash(const uint8_t *buffer, uint32_t len); 00599 00600 /** 00601 * Send data based on one of TCP or UDP builded already in multiple mode. 00602 * 00603 * @param mux_id - the identifier of this TCP(available value: 0 - 4). 00604 * @param buffer - the buffer of data to send from flash memeory. 00605 * @param len - the length of data to send. 00606 * @retval true - success. 00607 * @retval false - failure. 00608 */ 00609 bool sendFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len); 00610 00611 private: 00612 00613 /* 00614 * Empty the buffer or UART RX. 00615 */ 00616 void rx_empty(void); 00617 00618 /* 00619 * Recvive data from uart. Return all received data if target found or timeout. 00620 */ 00621 String recvString(String target, uint32_t timeout = 1000); 00622 00623 /* 00624 * Recvive data from uart. Return all received data if one of target1 and target2 found or timeout. 00625 */ 00626 String recvString(String target1, String target2, uint32_t timeout = 1000); 00627 00628 /* 00629 * Recvive data from uart. Return all received data if one of target1, target2 and target3 found or timeout. 00630 */ 00631 String recvString(String target1, String target2, String target3, uint32_t timeout = 1000); 00632 00633 /* 00634 * Recvive data from uart and search first target. Return true if target found, false for timeout. 00635 */ 00636 bool recvFind(String target, uint32_t timeout = 1000); 00637 00638 /* 00639 * Recvive data from uart and search first target and cut out the substring between begin and end(excluding begin and end self). 00640 * Return true if target found, false for timeout. 00641 */ 00642 bool recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout = 1000); 00643 00644 /* 00645 * Receive a package from uart. 00646 * 00647 * @param buffer - the buffer storing data. 00648 * @param buffer_size - guess what! 00649 * @param data_len - the length of data actually received(maybe more than buffer_size, the remained data will be abandoned). 00650 * @param timeout - the duration waitting data comming. 00651 * @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple. 00652 */ 00653 uint32_t checkIPD(String& data); 00654 00655 00656 bool eAT(void); 00657 bool eATRST(void); 00658 bool eATGMR(String &version); 00659 bool eATGSLP(uint32_t time); 00660 bool eATE(uint8_t mode); 00661 bool eATRESTORE(void); 00662 bool eATSETUART(uint32_t baudrate,uint8_t pattern); 00663 00664 bool qATCWMODE(uint8_t *mode,uint8_t pattern=3); 00665 bool eATCWMODE(String &list) ; 00666 bool sATCWMODE(uint8_t mode,uint8_t pattern=3); 00667 bool qATCWJAP(String &ssid,uint8_t pattern=3) ; 00668 bool sATCWJAP(String ssid, String pwd,uint8_t pattern=3); 00669 bool eATCWLAP(String &list); 00670 bool eATCWQAP(void); 00671 bool qATCWSAP(String &List,uint8_t pattern=3); 00672 bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern=3); 00673 bool eATCWLIF(String &list); 00674 bool qATCWDHCP(String &List,uint8_t pattern=3); 00675 bool sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3); 00676 bool eATCWAUTOCONN(uint8_t en); 00677 bool qATCIPSTAMAC(String &mac,uint8_t pattern=3); 00678 bool eATCIPSTAMAC(String mac,uint8_t pattern=3); 00679 bool qATCIPSTAIP(String &ip,uint8_t pattern=3); 00680 bool eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern=3); 00681 bool qATCIPAP(String &ip,uint8_t pattern=3); 00682 bool eATCIPAP(String ip,uint8_t pattern=3); 00683 bool eCWSTARTSMART(uint8_t type); 00684 bool eCWSTOPSMART(void); 00685 00686 00687 bool eATCIPSTATUS(String &list); 00688 bool sATCIPSTARTSingle(String type, String addr, uint32_t port); 00689 bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port); 00690 bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len); 00691 bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len); 00692 bool sATCIPSENDSingleFromFlash(const uint8_t *buffer, uint32_t len); 00693 bool sATCIPSENDMultipleFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len); 00694 bool sATCIPCLOSEMulitple(uint8_t mux_id); 00695 bool eATCIPCLOSESingle(void); 00696 bool eATCIFSR(String &list); 00697 bool sATCIPMUX(uint8_t mode); 00698 bool sATCIPSERVER(uint8_t mode, uint32_t port = 333); 00699 bool sATCIPMODE(uint8_t mode); 00700 bool eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port); 00701 bool eATPING(String ip); 00702 bool sATCIPSTO(uint32_t timeout); 00703 00704 /* 00705 * +IPD,len:data 00706 * +IPD,id,len:data 00707 */ 00708 00709 #ifdef ESP8266_USE_SOFTWARE_SERIAL 00710 SoftwareSerial *m_puart; /* The UART to communicate with ESP8266 */ 00711 #else 00712 HardwareSerial *m_puart; /* The UART to communicate with ESP8266 */ 00713 #endif 00714 onData m_onData; 00715 void* m_onDataPtr; 00716 }; 00717 00718 #endif /* #ifndef __ESP8266_H__ */ 00719 00720
Generated on Tue Jul 12 2022 23:11:54 by
