BLYNK TEST

Dependencies:   mbed Blynk

Committer:
kenobi
Date:
Tue Jan 26 08:23:29 2021 +0000
Revision:
5:8a3cf73d7ed3
Parent:
3:4cd9171ba989
bLYNK

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lixianyu 3:4cd9171ba989 1 /**
lixianyu 3:4cd9171ba989 2 * @file ESP8266.h
lixianyu 3:4cd9171ba989 3 * @brief The definition of class ESP8266.
lixianyu 3:4cd9171ba989 4 * @author Wu Pengfei<pengfei.wu@itead.cc>
lixianyu 3:4cd9171ba989 5 * @date 2015.02
lixianyu 3:4cd9171ba989 6 *
lixianyu 3:4cd9171ba989 7 * @par Copyright:
lixianyu 3:4cd9171ba989 8 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
lixianyu 3:4cd9171ba989 9 * This program is free software; you can redistribute it and/or
lixianyu 3:4cd9171ba989 10 * modify it under the terms of the GNU General Public License as
lixianyu 3:4cd9171ba989 11 * published by the Free Software Foundation; either version 2 of
lixianyu 3:4cd9171ba989 12 * the License, or (at your option) any later version. \n\n
lixianyu 3:4cd9171ba989 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
lixianyu 3:4cd9171ba989 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
lixianyu 3:4cd9171ba989 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
lixianyu 3:4cd9171ba989 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
lixianyu 3:4cd9171ba989 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
lixianyu 3:4cd9171ba989 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
lixianyu 3:4cd9171ba989 19 * THE SOFTWARE.
lixianyu 3:4cd9171ba989 20 */
lixianyu 3:4cd9171ba989 21 #ifndef __ESP8266_H__
lixianyu 3:4cd9171ba989 22 #define __ESP8266_H__
lixianyu 3:4cd9171ba989 23
lixianyu 3:4cd9171ba989 24 //#include "Arduino.h"
lixianyu 3:4cd9171ba989 25 #include "mbed.h"
lixianyu 3:4cd9171ba989 26 #include "WString.h"
lixianyu 3:4cd9171ba989 27
lixianyu 3:4cd9171ba989 28 extern Timer g_Timer;
lixianyu 3:4cd9171ba989 29 extern Serial pc;
lixianyu 3:4cd9171ba989 30 //#define LOG_ESP8266
lixianyu 3:4cd9171ba989 31 #ifdef LOG_ESP8266
lixianyu 3:4cd9171ba989 32 #define ESP8266_LOG pc.printf
lixianyu 3:4cd9171ba989 33 #define LOG_ENTER ESP8266_LOG("Enter %s\r\n", __func__);
lixianyu 3:4cd9171ba989 34 #else
lixianyu 3:4cd9171ba989 35 #define ESP8266_LOG(...)
lixianyu 3:4cd9171ba989 36 #define LOG_ENTER
lixianyu 3:4cd9171ba989 37 #endif
lixianyu 3:4cd9171ba989 38
lixianyu 3:4cd9171ba989 39 //#define ESP8266_USE_SOFTWARE_SERIAL
lixianyu 3:4cd9171ba989 40
lixianyu 3:4cd9171ba989 41 #ifdef ESP8266_USE_SOFTWARE_SERIAL
lixianyu 3:4cd9171ba989 42 //#include "SoftwareSerial.h"
lixianyu 3:4cd9171ba989 43 #define SoftwareSerial Serial
lixianyu 3:4cd9171ba989 44 #else
lixianyu 3:4cd9171ba989 45 #define HardwareSerial Serial
lixianyu 3:4cd9171ba989 46 #endif
lixianyu 3:4cd9171ba989 47
lixianyu 3:4cd9171ba989 48 #define VERSION_18 0X18
lixianyu 3:4cd9171ba989 49 #define VERSION_22 0X22
lixianyu 3:4cd9171ba989 50 #define DEFAULT_PATTERN 3
lixianyu 3:4cd9171ba989 51
lixianyu 3:4cd9171ba989 52 /**
lixianyu 3:4cd9171ba989 53 * You can modify the macro to choose a different version
lixianyu 3:4cd9171ba989 54 */
lixianyu 3:4cd9171ba989 55
lixianyu 3:4cd9171ba989 56 #define USER_SEL_VERSION VERSION_22
lixianyu 3:4cd9171ba989 57
lixianyu 3:4cd9171ba989 58 /**
lixianyu 3:4cd9171ba989 59 * Provide an easy-to-use way to manipulate ESP8266.
lixianyu 3:4cd9171ba989 60 */
lixianyu 3:4cd9171ba989 61 class ESP8266 {
lixianyu 3:4cd9171ba989 62 public:
lixianyu 3:4cd9171ba989 63
lixianyu 3:4cd9171ba989 64 typedef void (*onData)(uint8_t mux_id, uint32_t len, void* ptr);
lixianyu 3:4cd9171ba989 65
lixianyu 3:4cd9171ba989 66 #ifdef ESP8266_USE_SOFTWARE_SERIAL
lixianyu 3:4cd9171ba989 67 /*
lixianyu 3:4cd9171ba989 68 * Constuctor.
lixianyu 3:4cd9171ba989 69 *
lixianyu 3:4cd9171ba989 70 * @param uart - an reference of SoftwareSerial object.
lixianyu 3:4cd9171ba989 71 * @warning parameter baud depends on the AT firmware. 9600 is an common value.
lixianyu 3:4cd9171ba989 72 */
lixianyu 3:4cd9171ba989 73
lixianyu 3:4cd9171ba989 74 ESP8266(SoftwareSerial &uart);
lixianyu 3:4cd9171ba989 75
lixianyu 3:4cd9171ba989 76 SoftwareSerial* getUart() { return m_puart; }
lixianyu 3:4cd9171ba989 77
lixianyu 3:4cd9171ba989 78 #else /* HardwareSerial */
lixianyu 3:4cd9171ba989 79 /*
lixianyu 3:4cd9171ba989 80 * Constuctor.
lixianyu 3:4cd9171ba989 81 *
lixianyu 3:4cd9171ba989 82 * @param uart - an reference of HardwareSerial object.
lixianyu 3:4cd9171ba989 83 * @warning parameter baud depends on the AT firmware. 9600 is an common value.
lixianyu 3:4cd9171ba989 84 */
lixianyu 3:4cd9171ba989 85
lixianyu 3:4cd9171ba989 86 ESP8266(HardwareSerial &uart);
lixianyu 3:4cd9171ba989 87
lixianyu 3:4cd9171ba989 88 HardwareSerial* getUart() { return m_puart; }
lixianyu 3:4cd9171ba989 89
lixianyu 3:4cd9171ba989 90 #endif /* #ifdef ESP8266_USE_SOFTWARE_SERIAL */
lixianyu 3:4cd9171ba989 91
lixianyu 3:4cd9171ba989 92 void setOnData(onData cbk, void* ptr) {
lixianyu 3:4cd9171ba989 93 m_onData = cbk;
lixianyu 3:4cd9171ba989 94 m_onDataPtr = ptr;
lixianyu 3:4cd9171ba989 95 }
lixianyu 3:4cd9171ba989 96
lixianyu 3:4cd9171ba989 97 void run();
lixianyu 3:4cd9171ba989 98
lixianyu 3:4cd9171ba989 99 /**
lixianyu 3:4cd9171ba989 100 * Verify ESP8266 whether live or not.
lixianyu 3:4cd9171ba989 101 *
lixianyu 3:4cd9171ba989 102 * Actually, this method will send command "AT" to ESP8266 and waiting for "OK".
lixianyu 3:4cd9171ba989 103 *
lixianyu 3:4cd9171ba989 104 * @retval true - alive.
lixianyu 3:4cd9171ba989 105 * @retval false - dead.
lixianyu 3:4cd9171ba989 106 */
lixianyu 3:4cd9171ba989 107 bool kick(void);
lixianyu 3:4cd9171ba989 108
lixianyu 3:4cd9171ba989 109 /**
lixianyu 3:4cd9171ba989 110 * Restart ESP8266 by "AT+RST".
lixianyu 3:4cd9171ba989 111 *
lixianyu 3:4cd9171ba989 112 * This method will take 3 seconds or more.
lixianyu 3:4cd9171ba989 113 *
lixianyu 3:4cd9171ba989 114 * @retval true - success.
lixianyu 3:4cd9171ba989 115 * @retval false - failure.
lixianyu 3:4cd9171ba989 116 */
lixianyu 3:4cd9171ba989 117 bool restart(void);
lixianyu 3:4cd9171ba989 118
lixianyu 3:4cd9171ba989 119 /**
lixianyu 3:4cd9171ba989 120 * Get the version of AT Command Set.
lixianyu 3:4cd9171ba989 121 *
lixianyu 3:4cd9171ba989 122 * @return the string of version.
lixianyu 3:4cd9171ba989 123 */
lixianyu 3:4cd9171ba989 124 String getVersion(void);
lixianyu 3:4cd9171ba989 125
lixianyu 3:4cd9171ba989 126 /**
lixianyu 3:4cd9171ba989 127 * Start function of deep sleep.
lixianyu 3:4cd9171ba989 128 *
lixianyu 3:4cd9171ba989 129 * @param time - the sleep time.
lixianyu 3:4cd9171ba989 130 * @retval true - success.
lixianyu 3:4cd9171ba989 131 * @retval false - failure.
lixianyu 3:4cd9171ba989 132 * @note the feature requires hardware support.
lixianyu 3:4cd9171ba989 133 */
lixianyu 3:4cd9171ba989 134 bool deepSleep(uint32_t time);
lixianyu 3:4cd9171ba989 135
lixianyu 3:4cd9171ba989 136 /**
lixianyu 3:4cd9171ba989 137 * Switch the echo function.
lixianyu 3:4cd9171ba989 138 *
lixianyu 3:4cd9171ba989 139 * @param mode - 1 start echo -0 stop echo
lixianyu 3:4cd9171ba989 140 * @retval true - success.
lixianyu 3:4cd9171ba989 141 * @retval false - failure.
lixianyu 3:4cd9171ba989 142 *
lixianyu 3:4cd9171ba989 143 */
lixianyu 3:4cd9171ba989 144 bool setEcho(uint8_t mode);
lixianyu 3:4cd9171ba989 145
lixianyu 3:4cd9171ba989 146 /**
lixianyu 3:4cd9171ba989 147 * Restore factory.
lixianyu 3:4cd9171ba989 148 * @retval true - success.
lixianyu 3:4cd9171ba989 149 * @retval false - failure.
lixianyu 3:4cd9171ba989 150 * @note The operation can lead to restart the machine.
lixianyu 3:4cd9171ba989 151 */
lixianyu 3:4cd9171ba989 152 bool restore(void);
lixianyu 3:4cd9171ba989 153
lixianyu 3:4cd9171ba989 154 /**
lixianyu 3:4cd9171ba989 155 * Set up a serial port configuration.
lixianyu 3:4cd9171ba989 156 *
lixianyu 3:4cd9171ba989 157 * @param pattern -1 send "AT+UART=", -2 send "AT+UART_CUR=", -3 send "AT+UART_DEF=".
lixianyu 3:4cd9171ba989 158 * @param baudrate - the uart baudrate.
lixianyu 3:4cd9171ba989 159 * @retval true - success.
lixianyu 3:4cd9171ba989 160 * @retval false - failure.
lixianyu 3:4cd9171ba989 161 * @note Only allows baud rate design, for the other parameters:databits- 8,stopbits -1,parity -0,flow control -0 .
lixianyu 3:4cd9171ba989 162 */
lixianyu 3:4cd9171ba989 163 bool setUart(uint32_t baudrate,uint8_t pattern);
lixianyu 3:4cd9171ba989 164
lixianyu 3:4cd9171ba989 165 /**
lixianyu 3:4cd9171ba989 166 * Set operation mode to station.
lixianyu 3:4cd9171ba989 167 *
lixianyu 3:4cd9171ba989 168 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
lixianyu 3:4cd9171ba989 169 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
lixianyu 3:4cd9171ba989 170 * @retval true - success.
lixianyu 3:4cd9171ba989 171 * @retval false - failure.
lixianyu 3:4cd9171ba989 172 *
lixianyu 3:4cd9171ba989 173 */
lixianyu 3:4cd9171ba989 174 bool setOprToStation(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 175
lixianyu 3:4cd9171ba989 176 /**
lixianyu 3:4cd9171ba989 177 * Get the model values list.
lixianyu 3:4cd9171ba989 178 *
lixianyu 3:4cd9171ba989 179 * @return the list of model.
lixianyu 3:4cd9171ba989 180 */
lixianyu 3:4cd9171ba989 181 String getWifiModeList(void);
lixianyu 3:4cd9171ba989 182
lixianyu 3:4cd9171ba989 183 /**
lixianyu 3:4cd9171ba989 184 * Set operation mode to softap.
lixianyu 3:4cd9171ba989 185 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
lixianyu 3:4cd9171ba989 186 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
lixianyu 3:4cd9171ba989 187 *
lixianyu 3:4cd9171ba989 188 * @retval true - success.
lixianyu 3:4cd9171ba989 189 * @retval false - failure.
lixianyu 3:4cd9171ba989 190 */
lixianyu 3:4cd9171ba989 191 bool setOprToSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 192
lixianyu 3:4cd9171ba989 193 /**
lixianyu 3:4cd9171ba989 194 * Set operation mode to station + softap.
lixianyu 3:4cd9171ba989 195 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
lixianyu 3:4cd9171ba989 196 * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
lixianyu 3:4cd9171ba989 197 *
lixianyu 3:4cd9171ba989 198 * @retval true - success.
lixianyu 3:4cd9171ba989 199 * @retval false - failure.
lixianyu 3:4cd9171ba989 200 */
lixianyu 3:4cd9171ba989 201 bool setOprToStationSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 202
lixianyu 3:4cd9171ba989 203 /**
lixianyu 3:4cd9171ba989 204 * Get the operation mode.
lixianyu 3:4cd9171ba989 205 * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
lixianyu 3:4cd9171ba989 206 *
lixianyu 3:4cd9171ba989 207 * @retval 0 - failure.
lixianyu 3:4cd9171ba989 208 * @retval 1 - mode Station.
lixianyu 3:4cd9171ba989 209 * @retval 2 - mode AP.
lixianyu 3:4cd9171ba989 210 * @retval 3 - mode AP + station.
lixianyu 3:4cd9171ba989 211 */
lixianyu 3:4cd9171ba989 212 uint8_t getOprMode(uint8_t pattern1=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 213
lixianyu 3:4cd9171ba989 214 /**
lixianyu 3:4cd9171ba989 215 * Search available AP list and return it.
lixianyu 3:4cd9171ba989 216 *
lixianyu 3:4cd9171ba989 217 * @return the list of available APs.
lixianyu 3:4cd9171ba989 218 * @note This method will occupy a lot of memeory(hundreds of Bytes to a couple of KBytes).
lixianyu 3:4cd9171ba989 219 * Do not call this method unless you must and ensure that your board has enough memery left.
lixianyu 3:4cd9171ba989 220 */
lixianyu 3:4cd9171ba989 221 String getAPList(void);
lixianyu 3:4cd9171ba989 222
lixianyu 3:4cd9171ba989 223 /**
lixianyu 3:4cd9171ba989 224 * Search and returns the current connect AP.
lixianyu 3:4cd9171ba989 225 *
lixianyu 3:4cd9171ba989 226 * @param pattern -1, send "AT+CWJAP_DEF?",-2,send "AT+CWJAP_CUR?",-3,send "AT+CWJAP?".
lixianyu 3:4cd9171ba989 227 * @return the ssid of AP connected now.
lixianyu 3:4cd9171ba989 228 */
lixianyu 3:4cd9171ba989 229 String getNowConecAp(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 230
lixianyu 3:4cd9171ba989 231 /**
lixianyu 3:4cd9171ba989 232 * Join in AP.
lixianyu 3:4cd9171ba989 233 *
lixianyu 3:4cd9171ba989 234 * @param pattern -1 send "AT+CWJAP_DEF=" -2 send "AT+CWJAP_CUR=" -3 send "AT+CWJAP=".
lixianyu 3:4cd9171ba989 235 * @param ssid - SSID of AP to join in.
lixianyu 3:4cd9171ba989 236 * @param pwd - Password of AP to join in.
lixianyu 3:4cd9171ba989 237 * @retval true - success.
lixianyu 3:4cd9171ba989 238 * @retval false - failure.
lixianyu 3:4cd9171ba989 239 * @note This method will take a couple of seconds.
lixianyu 3:4cd9171ba989 240 */
lixianyu 3:4cd9171ba989 241 bool joinAP(String ssid, String pwd,uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 242
lixianyu 3:4cd9171ba989 243 /**
lixianyu 3:4cd9171ba989 244 * Leave AP joined before.
lixianyu 3:4cd9171ba989 245 *
lixianyu 3:4cd9171ba989 246 * @retval true - success.
lixianyu 3:4cd9171ba989 247 * @retval false - failure.
lixianyu 3:4cd9171ba989 248 */
lixianyu 3:4cd9171ba989 249 bool leaveAP(void);
lixianyu 3:4cd9171ba989 250
lixianyu 3:4cd9171ba989 251 /**
lixianyu 3:4cd9171ba989 252 * Set SoftAP parameters.
lixianyu 3:4cd9171ba989 253 *
lixianyu 3:4cd9171ba989 254 * @param pattern -1 send "AT+CWSAP_DEF=" -2 send "AT+CWSAP_CUR=" -3 send "AT+CWSAP=".
lixianyu 3:4cd9171ba989 255 * @param ssid - SSID of SoftAP.
lixianyu 3:4cd9171ba989 256 * @param pwd - PASSWORD of SoftAP.
lixianyu 3:4cd9171ba989 257 * @param chl - the channel (1 - 13, default: 7).
lixianyu 3:4cd9171ba989 258 * @param ecn - the way of encrypstion (0 - OPEN, 1 - WEP,
lixianyu 3:4cd9171ba989 259 * 2 - WPA_PSK, 3 - WPA2_PSK, 4 - WPA_WPA2_PSK, default: 4).
lixianyu 3:4cd9171ba989 260 * @retval true - success.
lixianyu 3:4cd9171ba989 261 * @retval false - failure.
lixianyu 3:4cd9171ba989 262 * @note This method should not be called when station mode.
lixianyu 3:4cd9171ba989 263 */
lixianyu 3:4cd9171ba989 264 bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4,uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 265
lixianyu 3:4cd9171ba989 266 /**
lixianyu 3:4cd9171ba989 267 * get SoftAP parameters.
lixianyu 3:4cd9171ba989 268 *
lixianyu 3:4cd9171ba989 269 * @param pattern -1 send "AT+CWSAP_DEF?" -2 send "AT+CWSAP_CUR?" -3 send "AT+CWSAP?".
lixianyu 3:4cd9171ba989 270 * @note This method should not be called when station mode.
lixianyu 3:4cd9171ba989 271 */
lixianyu 3:4cd9171ba989 272 String getSoftAPParam(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 273
lixianyu 3:4cd9171ba989 274 /**
lixianyu 3:4cd9171ba989 275 * Get the IP list of devices connected to SoftAP.
lixianyu 3:4cd9171ba989 276 *
lixianyu 3:4cd9171ba989 277 * @return the list of IP.
lixianyu 3:4cd9171ba989 278 * @note This method should not be called when station mode.
lixianyu 3:4cd9171ba989 279 */
lixianyu 3:4cd9171ba989 280 String getJoinedDeviceIP(void);
lixianyu 3:4cd9171ba989 281
lixianyu 3:4cd9171ba989 282 /**
lixianyu 3:4cd9171ba989 283 * Get the current state of DHCP.
lixianyu 3:4cd9171ba989 284 *
lixianyu 3:4cd9171ba989 285 * @param pattern -1 send "AT+CWDHCP_DEF?" -2 send "AT+CWDHCP_CUR?" -3 send "AT+CWDHCP?".
lixianyu 3:4cd9171ba989 286 * @return the state of DHCP.
lixianyu 3:4cd9171ba989 287 *
lixianyu 3:4cd9171ba989 288 */
lixianyu 3:4cd9171ba989 289 String getDHCP(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 290
lixianyu 3:4cd9171ba989 291 /**
lixianyu 3:4cd9171ba989 292 * Set the state of DHCP.
lixianyu 3:4cd9171ba989 293 * @param pattern -1 send "AT+CWDHCP_DEF=" -2 send "AT+CWDHCP_CUR=" -3 send "AT+CWDHCP=".
lixianyu 3:4cd9171ba989 294 * @param mode - set ap or set station or set ap + station.
lixianyu 3:4cd9171ba989 295 * @param en - 0 disable DHCP - 1 enable DHCP.
lixianyu 3:4cd9171ba989 296 * @retval true - success.
lixianyu 3:4cd9171ba989 297 * @retval false - failure.
lixianyu 3:4cd9171ba989 298 */
lixianyu 3:4cd9171ba989 299 bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 300
lixianyu 3:4cd9171ba989 301 /**
lixianyu 3:4cd9171ba989 302 * make boot automatically connected.
lixianyu 3:4cd9171ba989 303 * @param en -1 enable -0 disable.
lixianyu 3:4cd9171ba989 304 * @retval true - success.
lixianyu 3:4cd9171ba989 305 * @retval false - failure.
lixianyu 3:4cd9171ba989 306 */
lixianyu 3:4cd9171ba989 307 bool setAutoConnect(uint8_t en);
lixianyu 3:4cd9171ba989 308
lixianyu 3:4cd9171ba989 309 /**
lixianyu 3:4cd9171ba989 310 * Get the station's MAC address.
lixianyu 3:4cd9171ba989 311 * @param pattern -1 send "AT+CIPSTAMAC_DEF?=" -2 send "AT+CIPSTAMAC_CUR?" -3 send "AT+CIPSTAMAC?".
lixianyu 3:4cd9171ba989 312 * @return mac address.
lixianyu 3:4cd9171ba989 313 * @note This method should not be called when ap mode.
lixianyu 3:4cd9171ba989 314 */
lixianyu 3:4cd9171ba989 315 String getStationMac(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 316
lixianyu 3:4cd9171ba989 317 /**
lixianyu 3:4cd9171ba989 318 * Set the station's MAC address.
lixianyu 3:4cd9171ba989 319 * @param pattern -1 send "AT+CIPSTAMAC_DEF=" -2 send "AT+CIPSTAMAC_CUR=" -3 send "AT+CIPSTAMAC=".
lixianyu 3:4cd9171ba989 320 * @param mac - the mac address of station.
lixianyu 3:4cd9171ba989 321 * @retval true - success.
lixianyu 3:4cd9171ba989 322 * @retval false - failure.
lixianyu 3:4cd9171ba989 323 */
lixianyu 3:4cd9171ba989 324 bool setStationMac(String mac,uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 325
lixianyu 3:4cd9171ba989 326 /**
lixianyu 3:4cd9171ba989 327 * Get the station's IP.
lixianyu 3:4cd9171ba989 328 * @param pattern -1 send "AT+CIPSTA_DEF?" -2 send "AT+CIPSTA_CUR?" -3 send "AT+CIPSTA?".
lixianyu 3:4cd9171ba989 329 * @return the station's IP.
lixianyu 3:4cd9171ba989 330 * @note This method should not be called when ap mode.
lixianyu 3:4cd9171ba989 331 */
lixianyu 3:4cd9171ba989 332 String getStationIp(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 333
lixianyu 3:4cd9171ba989 334 /**
lixianyu 3:4cd9171ba989 335 * Set the station's IP.
lixianyu 3:4cd9171ba989 336 * @param pattern -1 send "AT+CIPSTA_DEF=" -2 send "AT+CIPSTA_CUR=" -3 send "AT+CIPSTA=".
lixianyu 3:4cd9171ba989 337 * @param ip - the ip of station.
lixianyu 3:4cd9171ba989 338 * @param gateway -the gateway of station.
lixianyu 3:4cd9171ba989 339 * @param netmask -the netmask of station.
lixianyu 3:4cd9171ba989 340 * @retval true - success.
lixianyu 3:4cd9171ba989 341 * @retval false - failure.
lixianyu 3:4cd9171ba989 342 * @note This method should not be called when ap mode.
lixianyu 3:4cd9171ba989 343 */
lixianyu 3:4cd9171ba989 344 bool setStationIp(String ip,String gateway,String netmask,uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 345
lixianyu 3:4cd9171ba989 346 /**
lixianyu 3:4cd9171ba989 347 * Get the AP's IP.
lixianyu 3:4cd9171ba989 348 * @param pattern -1 send "AT+CIPAP_DEF?" -2 send "AT+CIPAP_CUR?" -3 send "AT+CIPAP?".
lixianyu 3:4cd9171ba989 349 * @return ap's ip.
lixianyu 3:4cd9171ba989 350 * @note This method should not be called when station mode.
lixianyu 3:4cd9171ba989 351 *
lixianyu 3:4cd9171ba989 352 */
lixianyu 3:4cd9171ba989 353 String getAPIp(uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 354
lixianyu 3:4cd9171ba989 355 /**
lixianyu 3:4cd9171ba989 356 * Set the AP IP.
lixianyu 3:4cd9171ba989 357 * @param pattern -1 send "AT+CIPAP_DEF=" -2 send "AT+CIPAP_CUR=" -3 send "AT+CIPAP=".
lixianyu 3:4cd9171ba989 358 * @param ip - the ip of AP.
lixianyu 3:4cd9171ba989 359 * @retval true - success.
lixianyu 3:4cd9171ba989 360 * @retval false - failure.
lixianyu 3:4cd9171ba989 361 * @note This method should not be called when station mode.
lixianyu 3:4cd9171ba989 362 */
lixianyu 3:4cd9171ba989 363 bool setAPIp(String ip,uint8_t pattern=DEFAULT_PATTERN);
lixianyu 3:4cd9171ba989 364
lixianyu 3:4cd9171ba989 365 /**
lixianyu 3:4cd9171ba989 366 * start smartconfig.
lixianyu 3:4cd9171ba989 367 * @param type -1:ESP_TOUCH -2:AirKiss.
lixianyu 3:4cd9171ba989 368 * @retval true - success.
lixianyu 3:4cd9171ba989 369 * @retval false - failure.
lixianyu 3:4cd9171ba989 370 */
lixianyu 3:4cd9171ba989 371 bool startSmartConfig(uint8_t type);
lixianyu 3:4cd9171ba989 372
lixianyu 3:4cd9171ba989 373 /**
lixianyu 3:4cd9171ba989 374 * stop smartconfig.
lixianyu 3:4cd9171ba989 375 *
lixianyu 3:4cd9171ba989 376 * @retval true - success.
lixianyu 3:4cd9171ba989 377 * @retval false - failure.
lixianyu 3:4cd9171ba989 378 */
lixianyu 3:4cd9171ba989 379 bool stopSmartConfig(void);
lixianyu 3:4cd9171ba989 380
lixianyu 3:4cd9171ba989 381 /**
lixianyu 3:4cd9171ba989 382 * Get the current status of connection(UDP and TCP).
lixianyu 3:4cd9171ba989 383 *
lixianyu 3:4cd9171ba989 384 * @return the status.
lixianyu 3:4cd9171ba989 385 */
lixianyu 3:4cd9171ba989 386 String getIPStatus(void);
lixianyu 3:4cd9171ba989 387
lixianyu 3:4cd9171ba989 388 /**
lixianyu 3:4cd9171ba989 389 * Get the IP address of ESP8266.
lixianyu 3:4cd9171ba989 390 *
lixianyu 3:4cd9171ba989 391 * @return the IP list.
lixianyu 3:4cd9171ba989 392 */
lixianyu 3:4cd9171ba989 393 String getLocalIP(void);
lixianyu 3:4cd9171ba989 394
lixianyu 3:4cd9171ba989 395 /**
lixianyu 3:4cd9171ba989 396 * Enable IP MUX(multiple connection mode).
lixianyu 3:4cd9171ba989 397 *
lixianyu 3:4cd9171ba989 398 * In multiple connection mode, a couple of TCP and UDP communication can be builded.
lixianyu 3:4cd9171ba989 399 * They can be distinguished by the identifier of TCP or UDP named mux_id.
lixianyu 3:4cd9171ba989 400 *
lixianyu 3:4cd9171ba989 401 * @retval true - success.
lixianyu 3:4cd9171ba989 402 * @retval false - failure.
lixianyu 3:4cd9171ba989 403 */
lixianyu 3:4cd9171ba989 404 bool enableMUX(void);
lixianyu 3:4cd9171ba989 405
lixianyu 3:4cd9171ba989 406 /**
lixianyu 3:4cd9171ba989 407 * Disable IP MUX(single connection mode).
lixianyu 3:4cd9171ba989 408 *
lixianyu 3:4cd9171ba989 409 * In single connection mode, only one TCP or UDP communication can be builded.
lixianyu 3:4cd9171ba989 410 *
lixianyu 3:4cd9171ba989 411 * @retval true - success.
lixianyu 3:4cd9171ba989 412 * @retval false - failure.
lixianyu 3:4cd9171ba989 413 */
lixianyu 3:4cd9171ba989 414 bool disableMUX(void);
lixianyu 3:4cd9171ba989 415
lixianyu 3:4cd9171ba989 416 /**
lixianyu 3:4cd9171ba989 417 * Create TCP connection in single mode.
lixianyu 3:4cd9171ba989 418 *
lixianyu 3:4cd9171ba989 419 * @param addr - the IP or domain name of the target host.
lixianyu 3:4cd9171ba989 420 * @param port - the port number of the target host.
lixianyu 3:4cd9171ba989 421 * @retval true - success.
lixianyu 3:4cd9171ba989 422 * @retval false - failure.
lixianyu 3:4cd9171ba989 423 */
lixianyu 3:4cd9171ba989 424 bool createTCP(String addr, uint32_t port);
lixianyu 3:4cd9171ba989 425
lixianyu 3:4cd9171ba989 426 /**
lixianyu 3:4cd9171ba989 427 * Release TCP connection in single mode.
lixianyu 3:4cd9171ba989 428 *
lixianyu 3:4cd9171ba989 429 * @retval true - success.
lixianyu 3:4cd9171ba989 430 * @retval false - failure.
lixianyu 3:4cd9171ba989 431 */
lixianyu 3:4cd9171ba989 432 bool releaseTCP(void);
lixianyu 3:4cd9171ba989 433
lixianyu 3:4cd9171ba989 434 /**
lixianyu 3:4cd9171ba989 435 * Register UDP port number in single mode.
lixianyu 3:4cd9171ba989 436 *
lixianyu 3:4cd9171ba989 437 * @param addr - the IP or domain name of the target host.
lixianyu 3:4cd9171ba989 438 * @param port - the port number of the target host.
lixianyu 3:4cd9171ba989 439 * @retval true - success.
lixianyu 3:4cd9171ba989 440 * @retval false - failure.
lixianyu 3:4cd9171ba989 441 */
lixianyu 3:4cd9171ba989 442 bool registerUDP(String addr, uint32_t port);
lixianyu 3:4cd9171ba989 443
lixianyu 3:4cd9171ba989 444 /**
lixianyu 3:4cd9171ba989 445 * Unregister UDP port number in single mode.
lixianyu 3:4cd9171ba989 446 *
lixianyu 3:4cd9171ba989 447 * @retval true - success.
lixianyu 3:4cd9171ba989 448 * @retval false - failure.
lixianyu 3:4cd9171ba989 449 */
lixianyu 3:4cd9171ba989 450 bool unregisterUDP(void);
lixianyu 3:4cd9171ba989 451
lixianyu 3:4cd9171ba989 452 /**
lixianyu 3:4cd9171ba989 453 * Create TCP connection in multiple mode.
lixianyu 3:4cd9171ba989 454 *
lixianyu 3:4cd9171ba989 455 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 456 * @param addr - the IP or domain name of the target host.
lixianyu 3:4cd9171ba989 457 * @param port - the port number of the target host.
lixianyu 3:4cd9171ba989 458 * @retval true - success.
lixianyu 3:4cd9171ba989 459 * @retval false - failure.
lixianyu 3:4cd9171ba989 460 */
lixianyu 3:4cd9171ba989 461 bool createTCP(uint8_t mux_id, String addr, uint32_t port);
lixianyu 3:4cd9171ba989 462
lixianyu 3:4cd9171ba989 463 /**
lixianyu 3:4cd9171ba989 464 * Release TCP connection in multiple mode.
lixianyu 3:4cd9171ba989 465 *
lixianyu 3:4cd9171ba989 466 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 467 * @retval true - success.
lixianyu 3:4cd9171ba989 468 * @retval false - failure.
lixianyu 3:4cd9171ba989 469 */
lixianyu 3:4cd9171ba989 470 bool releaseTCP(uint8_t mux_id);
lixianyu 3:4cd9171ba989 471
lixianyu 3:4cd9171ba989 472 /**
lixianyu 3:4cd9171ba989 473 * Register UDP port number in multiple mode.
lixianyu 3:4cd9171ba989 474 *
lixianyu 3:4cd9171ba989 475 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 476 * @param addr - the IP or domain name of the target host.
lixianyu 3:4cd9171ba989 477 * @param port - the port number of the target host.
lixianyu 3:4cd9171ba989 478 * @retval true - success.
lixianyu 3:4cd9171ba989 479 * @retval false - failure.
lixianyu 3:4cd9171ba989 480 */
lixianyu 3:4cd9171ba989 481 bool registerUDP(uint8_t mux_id, String addr, uint32_t port);
lixianyu 3:4cd9171ba989 482
lixianyu 3:4cd9171ba989 483 /**
lixianyu 3:4cd9171ba989 484 * Unregister UDP port number in multiple mode.
lixianyu 3:4cd9171ba989 485 *
lixianyu 3:4cd9171ba989 486 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 487 * @retval true - success.
lixianyu 3:4cd9171ba989 488 * @retval false - failure.
lixianyu 3:4cd9171ba989 489 */
lixianyu 3:4cd9171ba989 490 bool unregisterUDP(uint8_t mux_id);
lixianyu 3:4cd9171ba989 491
lixianyu 3:4cd9171ba989 492 /**
lixianyu 3:4cd9171ba989 493 * Set the timeout of TCP Server.
lixianyu 3:4cd9171ba989 494 *
lixianyu 3:4cd9171ba989 495 * @param timeout - the duration for timeout by second(0 ~ 28800, default:180).
lixianyu 3:4cd9171ba989 496 * @retval true - success.
lixianyu 3:4cd9171ba989 497 * @retval false - failure.
lixianyu 3:4cd9171ba989 498 */
lixianyu 3:4cd9171ba989 499 bool setTCPServerTimeout(uint32_t timeout = 180);
lixianyu 3:4cd9171ba989 500
lixianyu 3:4cd9171ba989 501 /**
lixianyu 3:4cd9171ba989 502 * Start TCP Server(Only in multiple mode).
lixianyu 3:4cd9171ba989 503 *
lixianyu 3:4cd9171ba989 504 * After started, user should call method: getIPStatus to know the status of TCP connections.
lixianyu 3:4cd9171ba989 505 * The methods of receiving data can be called for user's any purpose. After communication,
lixianyu 3:4cd9171ba989 506 * release the TCP connection is needed by calling method: releaseTCP with mux_id.
lixianyu 3:4cd9171ba989 507 *
lixianyu 3:4cd9171ba989 508 * @param port - the port number to listen(default: 333).
lixianyu 3:4cd9171ba989 509 * @retval true - success.
lixianyu 3:4cd9171ba989 510 * @retval false - failure.
lixianyu 3:4cd9171ba989 511 *
lixianyu 3:4cd9171ba989 512 * @see String getIPStatus(void);
lixianyu 3:4cd9171ba989 513 * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
lixianyu 3:4cd9171ba989 514 * @see bool releaseTCP(uint8_t mux_id);
lixianyu 3:4cd9171ba989 515 */
lixianyu 3:4cd9171ba989 516 bool startTCPServer(uint32_t port = 333);
lixianyu 3:4cd9171ba989 517
lixianyu 3:4cd9171ba989 518 /**
lixianyu 3:4cd9171ba989 519 * Stop TCP Server(Only in multiple mode).
lixianyu 3:4cd9171ba989 520 *
lixianyu 3:4cd9171ba989 521 * @retval true - success.
lixianyu 3:4cd9171ba989 522 * @retval false - failure.
lixianyu 3:4cd9171ba989 523 */
lixianyu 3:4cd9171ba989 524 bool stopTCPServer(void);
lixianyu 3:4cd9171ba989 525
lixianyu 3:4cd9171ba989 526 /**
lixianyu 3:4cd9171ba989 527 *Set the module transfer mode
lixianyu 3:4cd9171ba989 528 *
lixianyu 3:4cd9171ba989 529 * @retval true - success.
lixianyu 3:4cd9171ba989 530 * @retval false - failure.
lixianyu 3:4cd9171ba989 531 */
lixianyu 3:4cd9171ba989 532 bool setCIPMODE(uint8_t mode);
lixianyu 3:4cd9171ba989 533
lixianyu 3:4cd9171ba989 534 /**
lixianyu 3:4cd9171ba989 535 * Start Server(Only in multiple mode).
lixianyu 3:4cd9171ba989 536 *
lixianyu 3:4cd9171ba989 537 * @param port - the port number to listen(default: 333).
lixianyu 3:4cd9171ba989 538 * @retval true - success.
lixianyu 3:4cd9171ba989 539 * @retval false - failure.
lixianyu 3:4cd9171ba989 540 *
lixianyu 3:4cd9171ba989 541 * @see String getIPStatus(void);
lixianyu 3:4cd9171ba989 542 * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
lixianyu 3:4cd9171ba989 543 */
lixianyu 3:4cd9171ba989 544 bool startServer(uint32_t port = 333);
lixianyu 3:4cd9171ba989 545
lixianyu 3:4cd9171ba989 546 /**
lixianyu 3:4cd9171ba989 547 * Stop Server(Only in multiple mode).
lixianyu 3:4cd9171ba989 548 *
lixianyu 3:4cd9171ba989 549 * @retval true - success.
lixianyu 3:4cd9171ba989 550 * @retval false - failure.
lixianyu 3:4cd9171ba989 551 */
lixianyu 3:4cd9171ba989 552 bool stopServer(void);
lixianyu 3:4cd9171ba989 553 /**
lixianyu 3:4cd9171ba989 554 * Save the passthrough links
lixianyu 3:4cd9171ba989 555 *
lixianyu 3:4cd9171ba989 556 * @retval true - success.
lixianyu 3:4cd9171ba989 557 * @retval false - failure.
lixianyu 3:4cd9171ba989 558 */
lixianyu 3:4cd9171ba989 559 bool saveTransLink (uint8_t mode,String ip,uint32_t port);
lixianyu 3:4cd9171ba989 560
lixianyu 3:4cd9171ba989 561 /**
lixianyu 3:4cd9171ba989 562 * PING COMMAND.
lixianyu 3:4cd9171ba989 563 *
lixianyu 3:4cd9171ba989 564 * @retval true - success.
lixianyu 3:4cd9171ba989 565 * @retval false - failure.
lixianyu 3:4cd9171ba989 566 */
lixianyu 3:4cd9171ba989 567 bool setPing(String ip);
lixianyu 3:4cd9171ba989 568
lixianyu 3:4cd9171ba989 569 /**
lixianyu 3:4cd9171ba989 570 * Send data based on TCP or UDP builded already in single mode.
lixianyu 3:4cd9171ba989 571 *
lixianyu 3:4cd9171ba989 572 * @param buffer - the buffer of data to send.
lixianyu 3:4cd9171ba989 573 * @param len - the length of data to send.
lixianyu 3:4cd9171ba989 574 * @retval true - success.
lixianyu 3:4cd9171ba989 575 * @retval false - failure.
lixianyu 3:4cd9171ba989 576 */
lixianyu 3:4cd9171ba989 577 bool send(const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 578
lixianyu 3:4cd9171ba989 579 /**
lixianyu 3:4cd9171ba989 580 * Send data based on one of TCP or UDP builded already in multiple mode.
lixianyu 3:4cd9171ba989 581 *
lixianyu 3:4cd9171ba989 582 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 583 * @param buffer - the buffer of data to send.
lixianyu 3:4cd9171ba989 584 * @param len - the length of data to send.
lixianyu 3:4cd9171ba989 585 * @retval true - success.
lixianyu 3:4cd9171ba989 586 * @retval false - failure.
lixianyu 3:4cd9171ba989 587 */
lixianyu 3:4cd9171ba989 588 bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 589
lixianyu 3:4cd9171ba989 590 /**
lixianyu 3:4cd9171ba989 591 * Send data based on TCP or UDP builded already in single mode.
lixianyu 3:4cd9171ba989 592 *
lixianyu 3:4cd9171ba989 593 * @param buffer - the buffer of data to send from flash memeory.
lixianyu 3:4cd9171ba989 594 * @param len - the length of data to send.
lixianyu 3:4cd9171ba989 595 * @retval true - success.
lixianyu 3:4cd9171ba989 596 * @retval false - failure.
lixianyu 3:4cd9171ba989 597 */
lixianyu 3:4cd9171ba989 598 bool sendFromFlash(const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 599
lixianyu 3:4cd9171ba989 600 /**
lixianyu 3:4cd9171ba989 601 * Send data based on one of TCP or UDP builded already in multiple mode.
lixianyu 3:4cd9171ba989 602 *
lixianyu 3:4cd9171ba989 603 * @param mux_id - the identifier of this TCP(available value: 0 - 4).
lixianyu 3:4cd9171ba989 604 * @param buffer - the buffer of data to send from flash memeory.
lixianyu 3:4cd9171ba989 605 * @param len - the length of data to send.
lixianyu 3:4cd9171ba989 606 * @retval true - success.
lixianyu 3:4cd9171ba989 607 * @retval false - failure.
lixianyu 3:4cd9171ba989 608 */
lixianyu 3:4cd9171ba989 609 bool sendFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 610
lixianyu 3:4cd9171ba989 611 private:
lixianyu 3:4cd9171ba989 612
lixianyu 3:4cd9171ba989 613 /*
lixianyu 3:4cd9171ba989 614 * Empty the buffer or UART RX.
lixianyu 3:4cd9171ba989 615 */
lixianyu 3:4cd9171ba989 616 void rx_empty(void);
lixianyu 3:4cd9171ba989 617
lixianyu 3:4cd9171ba989 618 /*
lixianyu 3:4cd9171ba989 619 * Recvive data from uart. Return all received data if target found or timeout.
lixianyu 3:4cd9171ba989 620 */
lixianyu 3:4cd9171ba989 621 String recvString(String target, uint32_t timeout = 1000);
lixianyu 3:4cd9171ba989 622
lixianyu 3:4cd9171ba989 623 /*
lixianyu 3:4cd9171ba989 624 * Recvive data from uart. Return all received data if one of target1 and target2 found or timeout.
lixianyu 3:4cd9171ba989 625 */
lixianyu 3:4cd9171ba989 626 String recvString(String target1, String target2, uint32_t timeout = 1000);
lixianyu 3:4cd9171ba989 627
lixianyu 3:4cd9171ba989 628 /*
lixianyu 3:4cd9171ba989 629 * Recvive data from uart. Return all received data if one of target1, target2 and target3 found or timeout.
lixianyu 3:4cd9171ba989 630 */
lixianyu 3:4cd9171ba989 631 String recvString(String target1, String target2, String target3, uint32_t timeout = 1000);
lixianyu 3:4cd9171ba989 632
lixianyu 3:4cd9171ba989 633 /*
lixianyu 3:4cd9171ba989 634 * Recvive data from uart and search first target. Return true if target found, false for timeout.
lixianyu 3:4cd9171ba989 635 */
lixianyu 3:4cd9171ba989 636 bool recvFind(String target, uint32_t timeout = 1000);
lixianyu 3:4cd9171ba989 637
lixianyu 3:4cd9171ba989 638 /*
lixianyu 3:4cd9171ba989 639 * Recvive data from uart and search first target and cut out the substring between begin and end(excluding begin and end self).
lixianyu 3:4cd9171ba989 640 * Return true if target found, false for timeout.
lixianyu 3:4cd9171ba989 641 */
lixianyu 3:4cd9171ba989 642 bool recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout = 1000);
lixianyu 3:4cd9171ba989 643
lixianyu 3:4cd9171ba989 644 /*
lixianyu 3:4cd9171ba989 645 * Receive a package from uart.
lixianyu 3:4cd9171ba989 646 *
lixianyu 3:4cd9171ba989 647 * @param buffer - the buffer storing data.
lixianyu 3:4cd9171ba989 648 * @param buffer_size - guess what!
lixianyu 3:4cd9171ba989 649 * @param data_len - the length of data actually received(maybe more than buffer_size, the remained data will be abandoned).
lixianyu 3:4cd9171ba989 650 * @param timeout - the duration waitting data comming.
lixianyu 3:4cd9171ba989 651 * @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple.
lixianyu 3:4cd9171ba989 652 */
lixianyu 3:4cd9171ba989 653 uint32_t checkIPD(String& data);
lixianyu 3:4cd9171ba989 654
lixianyu 3:4cd9171ba989 655
lixianyu 3:4cd9171ba989 656 bool eAT(void);
lixianyu 3:4cd9171ba989 657 bool eATRST(void);
lixianyu 3:4cd9171ba989 658 bool eATGMR(String &version);
lixianyu 3:4cd9171ba989 659 bool eATGSLP(uint32_t time);
lixianyu 3:4cd9171ba989 660 bool eATE(uint8_t mode);
lixianyu 3:4cd9171ba989 661 bool eATRESTORE(void);
lixianyu 3:4cd9171ba989 662 bool eATSETUART(uint32_t baudrate,uint8_t pattern);
lixianyu 3:4cd9171ba989 663
lixianyu 3:4cd9171ba989 664 bool qATCWMODE(uint8_t *mode,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 665 bool eATCWMODE(String &list) ;
lixianyu 3:4cd9171ba989 666 bool sATCWMODE(uint8_t mode,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 667 bool qATCWJAP(String &ssid,uint8_t pattern=3) ;
lixianyu 3:4cd9171ba989 668 bool sATCWJAP(String ssid, String pwd,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 669 bool eATCWLAP(String &list);
lixianyu 3:4cd9171ba989 670 bool eATCWQAP(void);
lixianyu 3:4cd9171ba989 671 bool qATCWSAP(String &List,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 672 bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 673 bool eATCWLIF(String &list);
lixianyu 3:4cd9171ba989 674 bool qATCWDHCP(String &List,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 675 bool sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3);
lixianyu 3:4cd9171ba989 676 bool eATCWAUTOCONN(uint8_t en);
lixianyu 3:4cd9171ba989 677 bool qATCIPSTAMAC(String &mac,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 678 bool eATCIPSTAMAC(String mac,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 679 bool qATCIPSTAIP(String &ip,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 680 bool eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 681 bool qATCIPAP(String &ip,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 682 bool eATCIPAP(String ip,uint8_t pattern=3);
lixianyu 3:4cd9171ba989 683 bool eCWSTARTSMART(uint8_t type);
lixianyu 3:4cd9171ba989 684 bool eCWSTOPSMART(void);
lixianyu 3:4cd9171ba989 685
lixianyu 3:4cd9171ba989 686
lixianyu 3:4cd9171ba989 687 bool eATCIPSTATUS(String &list);
lixianyu 3:4cd9171ba989 688 bool sATCIPSTARTSingle(String type, String addr, uint32_t port);
lixianyu 3:4cd9171ba989 689 bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port);
lixianyu 3:4cd9171ba989 690 bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 691 bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 692 bool sATCIPSENDSingleFromFlash(const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 693 bool sATCIPSENDMultipleFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
lixianyu 3:4cd9171ba989 694 bool sATCIPCLOSEMulitple(uint8_t mux_id);
lixianyu 3:4cd9171ba989 695 bool eATCIPCLOSESingle(void);
lixianyu 3:4cd9171ba989 696 bool eATCIFSR(String &list);
lixianyu 3:4cd9171ba989 697 bool sATCIPMUX(uint8_t mode);
lixianyu 3:4cd9171ba989 698 bool sATCIPSERVER(uint8_t mode, uint32_t port = 333);
lixianyu 3:4cd9171ba989 699 bool sATCIPMODE(uint8_t mode);
lixianyu 3:4cd9171ba989 700 bool eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port);
lixianyu 3:4cd9171ba989 701 bool eATPING(String ip);
lixianyu 3:4cd9171ba989 702 bool sATCIPSTO(uint32_t timeout);
lixianyu 3:4cd9171ba989 703
lixianyu 3:4cd9171ba989 704 /*
lixianyu 3:4cd9171ba989 705 * +IPD,len:data
lixianyu 3:4cd9171ba989 706 * +IPD,id,len:data
lixianyu 3:4cd9171ba989 707 */
lixianyu 3:4cd9171ba989 708
lixianyu 3:4cd9171ba989 709 #ifdef ESP8266_USE_SOFTWARE_SERIAL
lixianyu 3:4cd9171ba989 710 SoftwareSerial *m_puart; /* The UART to communicate with ESP8266 */
lixianyu 3:4cd9171ba989 711 #else
lixianyu 3:4cd9171ba989 712 HardwareSerial *m_puart; /* The UART to communicate with ESP8266 */
lixianyu 3:4cd9171ba989 713 #endif
lixianyu 3:4cd9171ba989 714 onData m_onData;
lixianyu 3:4cd9171ba989 715 void* m_onDataPtr;
lixianyu 3:4cd9171ba989 716 };
lixianyu 3:4cd9171ba989 717
lixianyu 3:4cd9171ba989 718 #endif /* #ifndef __ESP8266_H__ */
lixianyu 3:4cd9171ba989 719
lixianyu 3:4cd9171ba989 720