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