diff --git a/ESP8266.cpp b/ESP8266.cpp index 47bcc7c..e972699 100644 --- a/ESP8266.cpp +++ b/ESP8266.cpp @@ -19,6 +19,7 @@ * THE SOFTWARE. */ #include "ESP8266.h" +#include #define LOG_OUTPUT_DEBUG (1) #define LOG_OUTPUT_DEBUG_PREFIX (1) @@ -84,33 +85,58 @@ String ESP8266::getVersion(void) return version; } -bool ESP8266::setOprToStation(void) +bool ESP8266::setEcho(uint8_t mode) +{ + return eATE(mode); +} + +bool ESP8266::restore(void) +{ + return eATRESTORE(); +} +bool ESP8266::setUart(uint32_t baudrate,uint8_t pattern) +{ + return eATSETUART(baudrate,pattern); +} + +bool ESP8266::deepSleep(uint32_t time) +{ + return eATGSLP(time); +} + + +bool ESP8266::setOprToStation(uint8_t pattern1,uint8_t pattern2) { uint8_t mode; - if (!qATCWMODE(&mode)) { + if (!qATCWMODE(&mode,pattern1)) { return false; } if (mode == 1) { return true; } else { - if (sATCWMODE(1) && restart()) { + if (sATCWMODE(1,pattern2)){ return true; } else { return false; } } } - -bool ESP8266::setOprToSoftAP(void) +String ESP8266::getWifiModeList(void) +{ + String list; + eATCWMODE(list); + return list; +} +bool ESP8266::setOprToSoftAP(uint8_t pattern1,uint8_t pattern2) { uint8_t mode; - if (!qATCWMODE(&mode)) { + if (!qATCWMODE(&mode,pattern1)) { return false; } if (mode == 2) { return true; } else { - if (sATCWMODE(2) && restart()) { + if (sATCWMODE(2,pattern2) ){ return true; } else { return false; @@ -118,16 +144,16 @@ bool ESP8266::setOprToSoftAP(void) } } -bool ESP8266::setOprToStationSoftAP(void) +bool ESP8266::setOprToStationSoftAP(uint8_t pattern1,uint8_t pattern2) { uint8_t mode; - if (!qATCWMODE(&mode)) { + if (!qATCWMODE(&mode,pattern1)) { return false; } if (mode == 3) { return true; } else { - if (sATCWMODE(3) && restart()) { + if (sATCWMODE(3,pattern2) ){ return true; } else { return false; @@ -135,6 +161,24 @@ bool ESP8266::setOprToStationSoftAP(void) } } +uint8_t ESP8266::getOprMode(uint8_t pattern1) +{ + uint8_t mode; + if (!qATCWMODE(&mode,pattern1)) { + return 0; + } else { + return mode; + } +} + +String ESP8266::getNowConecAp(uint8_t pattern) +{ + String ssid; + qATCWJAP(ssid,pattern); + return ssid; +} + + String ESP8266::getAPList(void) { String list; @@ -142,9 +186,9 @@ String ESP8266::getAPList(void) return list; } -bool ESP8266::joinAP(String ssid, String pwd) +bool ESP8266::joinAP(String ssid, String pwd,uint8_t pattern) { - return sATCWJAP(ssid, pwd); + return sATCWJAP(ssid, pwd,pattern); } bool ESP8266::leaveAP(void) @@ -152,9 +196,18 @@ bool ESP8266::leaveAP(void) return eATCWQAP(); } -bool ESP8266::setSoftAPParam(String ssid, String pwd, uint8_t chl, uint8_t ecn) +String ESP8266::getSoftAPParam(uint8_t pattern) +{ + String list; + qATCWSAP(list,pattern); + return list; +} + + + +bool ESP8266::setSoftAPParam(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern) { - return sATCWSAP(ssid, pwd, chl, ecn); + return sATCWSAP(ssid, pwd, chl, ecn,pattern); } String ESP8266::getJoinedDeviceIP(void) @@ -164,6 +217,71 @@ String ESP8266::getJoinedDeviceIP(void) return list; } +String ESP8266::getDHCP(uint8_t pattern) +{ + String dhcp; + qATCWDHCP(dhcp,pattern); + return dhcp; +} +bool ESP8266::setDHCP(uint8_t mode, uint8_t en, uint8_t pattern) +{ + return sATCWDHCP(mode, en, pattern); +} + +bool ESP8266::setAutoConnect(uint8_t en) +{ + return eATCWAUTOCONN(en); +} +String ESP8266::getStationMac(uint8_t pattern) +{ + String mac; + qATCIPSTAMAC(mac,pattern); + return mac; +} + + +bool ESP8266::setStationMac(String mac,uint8_t pattern) +{ + return eATCIPSTAMAC(mac,pattern); +} + +String ESP8266::getStationIp(uint8_t pattern) +{ + String ip; + qATCIPSTAIP(ip,pattern); + return ip; +} + +bool ESP8266::setStationIp(String ip,String gateway,String netmask,uint8_t pattern) +{ + return eATCIPSTAIP(ip,gateway,netmask,pattern); +} + +String ESP8266::getAPIp(uint8_t pattern) +{ + String ip; + qATCIPAP(ip,pattern); + return ip; +} + +bool ESP8266::setAPIp(String ip,uint8_t pattern) +{ + return eATCIPAP(ip,pattern); +} + +bool ESP8266::startSmartConfig(uint8_t type) +{ + return eCWSTARTSMART(type); +} + +bool ESP8266::stopSmartConfig(void) +{ + return eCWSTOPSMART(); +} + + + + String ESP8266::getIPStatus(void) { String list; @@ -188,9 +306,9 @@ bool ESP8266::disableMUX(void) return sATCIPMUX(0); } -bool ESP8266::createTCP(String addr, uint32_t port) +bool ESP8266::createTCP(String addr, uint32_t port, uint16_t keep_alive=0) { - return sATCIPSTARTSingle("TCP", addr, port); + return sATCIPSTARTSingleTCP(addr, port, keep_alive); } bool ESP8266::releaseTCP(void) @@ -198,32 +316,32 @@ bool ESP8266::releaseTCP(void) return eATCIPCLOSESingle(); } -bool ESP8266::registerUDP(String addr, uint32_t port) +bool ESP8266::registerUDP(String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode) { - return sATCIPSTARTSingle("UDP", addr, port); + return sATCIPSTARTSingleUDP(remote_addr, remote_port, local_port, udp_mode); } -bool ESP8266::unregisterUDP(void) +bool ESP8266::registerUDP(uint8_t mux_id, String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode) { - return eATCIPCLOSESingle(); + return sATCIPSTARTMultipleUDP(mux_id, remote_addr, remote_port, local_port, udp_mode); } -bool ESP8266::createTCP(uint8_t mux_id, String addr, uint32_t port) +bool ESP8266::unregisterUDP() { - return sATCIPSTARTMultiple(mux_id, "TCP", addr, port); + return eATCIPCLOSESingle(); } -bool ESP8266::releaseTCP(uint8_t mux_id) +bool ESP8266::unregisterUDP(uint8_t mux_id) { - return sATCIPCLOSEMulitple(mux_id); + return eATCIPCLOSEMultiple(mux_id); } -bool ESP8266::registerUDP(uint8_t mux_id, String addr, uint32_t port) +bool ESP8266::createTCP(uint8_t mux_id, String addr, uint32_t port, uint16_t keep_alive=0) { - return sATCIPSTARTMultiple(mux_id, "UDP", addr, port); + return sATCIPSTARTMultipleTCP(mux_id, addr, port, keep_alive); } -bool ESP8266::unregisterUDP(uint8_t mux_id) +bool ESP8266::releaseTCP(uint8_t mux_id) { return sATCIPCLOSEMulitple(mux_id); } @@ -248,14 +366,19 @@ bool ESP8266::stopTCPServer(void) return false; } -bool ESP8266::startServer(uint32_t port) +bool ESP8266::setCIPMODE(uint8_t mode) +{ + return sATCIPMODE(mode); +} + +bool ESP8266::saveTransLink (uint8_t mode,String ip,uint32_t port) { - return startTCPServer(port); + return eATSAVETRANSLINK(mode,ip,port); } -bool ESP8266::stopServer(void) +bool ESP8266::setPing(String ip) { - return stopTCPServer(); + return eATPING(ip); } bool ESP8266::send(const uint8_t *buffer, uint32_t len) @@ -263,6 +386,16 @@ bool ESP8266::send(const uint8_t *buffer, uint32_t len) return sATCIPSENDSingle(buffer, len); } +bool ESP8266::sendFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len) +{ + return sATCIPSENDMultipleFromFlash(mux_id, buffer, len); +} + +bool ESP8266::sendFromFlash(const uint8_t *buffer, uint32_t len) +{ + return sATCIPSENDSingleFromFlash(buffer, len); +} + bool ESP8266::send(uint8_t mux_id, const uint8_t *buffer, uint32_t len) { return sATCIPSENDMultiple(mux_id, buffer, len); @@ -391,6 +524,7 @@ String ESP8266::recvString(String target, uint32_t timeout) break; } } + return data; } @@ -459,72 +593,208 @@ bool ESP8266::recvFindAndFilter(String target, String begin, String end, String return true; } } - data = ""; + data = data_tmp; return false; } bool ESP8266::eAT(void) { rx_empty(); - m_puart->println("AT"); + m_puart->println(F("AT")); return recvFind("OK"); } bool ESP8266::eATRST(void) { rx_empty(); - m_puart->println("AT+RST"); + m_puart->println(F("AT+RST")); return recvFind("OK"); } bool ESP8266::eATGMR(String &version) { rx_empty(); - m_puart->println("AT+GMR"); - return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", version); + delay(3000); + m_puart->println(F("AT+GMR")); + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", version,10000); +} + +bool ESP8266::eATGSLP(uint32_t time) +{ + rx_empty(); + m_puart->print(F("AT+GSLP=")); + m_puart->println(time); + return recvFind("OK"); +} + + +bool ESP8266::eATE(uint8_t mode) +{ + rx_empty(); + m_puart->print(F("ATE")); + m_puart->println(mode); + return recvFind("OK"); +} + +bool ESP8266::eATRESTORE(void) +{ + rx_empty(); + m_puart->println(F("AT+RESTORE")); + return recvFind("OK"); +} + + +bool ESP8266::eATSETUART(uint32_t baudrate,uint8_t pattern) +{ + rx_empty(); + if(pattern>3||pattern<1){ + return false; + } + switch(pattern){ + case 1: + m_puart->print(F("AT+UART=")); + break; + case 2: + m_puart->print(F("AT+UART_CUR=")); + break; + case 3: + m_puart->print(F("AT+UART_DEF=")); + break; + } + m_puart->print(baudrate); + m_puart->print(F(",")); + m_puart->print(8); + m_puart->print(F(",")); + m_puart->print(1); + m_puart->print(F(",")); + m_puart->print(0); + m_puart->print(F(",")); + m_puart->println(0); + if(recvFind("OK",5000)){ + + m_puart->begin(baudrate); + return true; + } + else{ + return false; + } + } -bool ESP8266::qATCWMODE(uint8_t *mode) + +bool ESP8266::qATCWMODE(uint8_t *mode,uint8_t pattern) { String str_mode; bool ret; - if (!mode) { + if (!mode||!pattern) { return false; } rx_empty(); - m_puart->println("AT+CWMODE?"); - ret = recvFindAndFilter("OK", "+CWMODE:", "\r\n\r\nOK", str_mode); + switch(pattern) + { + case 1 : + m_puart->println(F("AT+CWMODE_DEF?")); + break; + case 2: + m_puart->println(F("AT+CWMODE_CUR?")); + break; + default: + m_puart->println(F("AT+CWMODE?")); + } + ret = recvFindAndFilter("OK", ":", "\r\n\r\nOK", str_mode); if (ret) { - *mode = (uint8_t)str_mode.toInt(); + *mode = (uint8_t)str_mode.toInt(); return true; } else { return false; } } +bool ESP8266::eATCWMODE(String &list) +{ + rx_empty(); + m_puart->println(F("AT+CWMODE=?")); + return recvFindAndFilter("OK", "+CWMODE:(", ")\r\n\r\nOK", list); +} -bool ESP8266::sATCWMODE(uint8_t mode) +bool ESP8266::sATCWMODE(uint8_t mode,uint8_t pattern) { + if(!pattern){ + return false; + } String data; rx_empty(); - m_puart->print("AT+CWMODE="); + switch(pattern) + { + case 1 : + m_puart->print(F("AT+CWMODE_DEF=")); + break; + case 2: + m_puart->print(F("AT+CWMODE_CUR=")); + break; + default: + m_puart->print(F("AT+CWMODE=")); + } m_puart->println(mode); - data = recvString("OK", "no change"); + if (data.indexOf("OK") != -1 || data.indexOf("no change") != -1) { return true; } return false; } -bool ESP8266::sATCWJAP(String ssid, String pwd) + +bool ESP8266::qATCWJAP(String &ssid,uint8_t pattern) +{ + + bool ret; + if (!pattern) { + return false; + } + rx_empty(); + switch(pattern) + { + case 1 : + m_puart->println(F("AT+CWJAP_DEF?")); + break; + case 2: + m_puart->println(F("AT+CWJAP_CUR?")); + break; + default: + m_puart->println(F("AT+CWJAP?")); + } + ssid = recvString("OK", "No AP"); + if (ssid.indexOf("OK") != -1 || ssid.indexOf("No AP") != -1) { + return true; + } + return false; + +} + +bool ESP8266::sATCWJAP(String ssid, String pwd,uint8_t pattern) { String data; + if (!pattern) { + return false; + } rx_empty(); - m_puart->print("AT+CWJAP=\""); + switch(pattern) + { + case 1 : + m_puart->print(F("AT+CWJAP_DEF=\"")); + + break; + case 2: + m_puart->print(F("AT+CWJAP_CUR=\"")); + break; + default: + m_puart->print(F("AT+CWJAP=\"")); + } + m_puart->print(ssid); - m_puart->print("\",\""); + m_puart->print(F("\",\"")); m_puart->print(pwd); - m_puart->println("\""); + m_puart->println(F("\"")); data = recvString("OK", "FAIL", 10000); if (data.indexOf("OK") != -1) { @@ -533,33 +803,73 @@ bool ESP8266::sATCWJAP(String ssid, String pwd) return false; } -bool ESP8266::eATCWLAP(String &list) +bool ESP8266::eATCWLAP(String &list) { String data; rx_empty(); - m_puart->println("AT+CWLAP"); - return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list, 10000); + m_puart->println(F("AT+CWLAP")); + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list, 15000); } + + + bool ESP8266::eATCWQAP(void) { String data; rx_empty(); - m_puart->println("AT+CWQAP"); + m_puart->println(F("AT+CWQAP")); return recvFind("OK"); } -bool ESP8266::sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn) + +bool ESP8266::qATCWSAP(String &List,uint8_t pattern) +{ + if (!pattern) { + return false; + } + rx_empty(); + switch(pattern) + { + case 1 : + m_puart->println(F("AT+CWSAP_DEF?")); + + break; + case 2: + m_puart->println(F("AT+CWSAP_CUR?")); + break; + default: + m_puart->println(F("AT+CWSAP?")); + } + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", List,10000); + +} + +bool ESP8266::sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern) { String data; + if (!pattern) { + return false; + } rx_empty(); - m_puart->print("AT+CWSAP=\""); + switch(pattern){ + case 1 : + m_puart->print(F("AT+CWSAP_DEF=\"")); + + break; + case 2: + m_puart->print(F("AT+CWSAP_CUR=\"")); + break; + default: + m_puart->print(F("AT+CWSAP=\"")); + + } m_puart->print(ssid); - m_puart->print("\",\""); + m_puart->print(F("\",\"")); m_puart->print(pwd); - m_puart->print("\","); + m_puart->print(F("\",")); m_puart->print(chl); - m_puart->print(","); + m_puart->print(F(",")); m_puart->println(ecn); data = recvString("OK", "ERROR", 5000); @@ -573,27 +883,314 @@ bool ESP8266::eATCWLIF(String &list) { String data; rx_empty(); - m_puart->println("AT+CWLIF"); + m_puart->println(F("AT+CWLIF")); return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list); } + +bool ESP8266::qATCWDHCP(String &List,uint8_t pattern) +{ + if (!pattern) { + return false; + } + rx_empty(); + switch(pattern) + { + case 1 : + m_puart->println(F("AT+CWDHCP_DEF?")); + break; + case 2: + m_puart->println(F("AT+CWDHCP_CUR?")); + break; + default: + m_puart->println(F("AT+CWDHCP?")); + } + + return recvFindAndFilter("OK", "\r\r\n", "\r\nOK", List,10000); + +} + + +bool ESP8266::sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern) +{ + String data; + if (!pattern) { + return false; + } + rx_empty(); + switch(pattern){ + case 1 : + m_puart->print(F("AT+CWDHCP_DEF=")); + + break; + case 2: + m_puart->print(F("AT+CWDHCP_CUR=")); + break; + default: + m_puart->print(F("AT+CWDHCP=")); + + } + m_puart->print(mode); + m_puart->print(F(",")); + m_puart->println(en); + data = recvString("OK", "ERROR", 2000); + + if (data.indexOf("OK") != -1) { + return true; + } + return false; +} + + +bool ESP8266::eATCWAUTOCONN(uint8_t en) +{ + + rx_empty(); + if(en>1||en<0){ + return false; + } + m_puart->print(F("AT+CWAUTOCONN=")); + m_puart->println(en); + return recvFind("OK"); + +} + +bool ESP8266::qATCIPSTAMAC(String &mac,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->println(F("AT+CIPSTAMAC_DEF?")); + + break; + case 2: + m_puart->println(F("AT+CIPSTAMAC_CUR?")); + break; + default: + m_puart->println(F("AT+CIPSTAMAC?")); + + } + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", mac,2000); + +} + + + +bool ESP8266::eATCIPSTAMAC(String mac,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->print(F("AT+CIPSTAMAC_DEF=")); + + break; + case 2: + m_puart->print(F("AT+CIPSTAMAC_CUR=")); + break; + default: + m_puart->print(F("AT+CIPSTAMAC=")); + + } + m_puart->print(F("\"")); + m_puart->print(mac); + m_puart->println(F("\"")); + return recvFind("OK"); + +} + +bool ESP8266::qATCIPSTAIP(String &ip,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->println(F("AT+CIPSTA_DEF?")); + + break; + case 2: + m_puart->println(F("AT+CIPSTA_CUR?")); + break; + default: + m_puart->println(F("AT+CIPSTA?")); + + } + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", ip,2000); + +} + +bool ESP8266::eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->print(F("AT+CIPSTA_DEF=")); + + break; + case 2: + m_puart->print(F("AT+CIPSTA_CUR=")); + break; + default: + m_puart->print(F("AT+CIPSTA=")); + + } + m_puart->print(F("\"")); + m_puart->print(ip); + m_puart->print(F("\",\"")); + m_puart->print(gateway); + m_puart->print(F("\",\"")); + m_puart->print(netmask); + m_puart->println(F("\"")); + return recvFind("OK"); + +} + + +bool ESP8266::qATCIPAP(String &ip,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->println(F("AT+CIPAP_DEF?")); + + break; + case 2: + m_puart->println(F("AT+CIPAP_CUR?")); + break; + default: + m_puart->println(F("AT+CIPAP?")); + + } + return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", ip,2000); + +} + + +bool ESP8266::eATCIPAP(String ip,uint8_t pattern) +{ + + rx_empty(); + if (!pattern) { + return false; + } + switch(pattern){ + case 1 : + m_puart->print(F("AT+CIPAP_DEF=")); + + break; + case 2: + m_puart->print(F("AT+CIPAP_CUR=")); + break; + default: + m_puart->print(F("AT+CIPAP=")); + + } + m_puart->print(F("\"")); + m_puart->print(ip); + m_puart->println(F("\"")); + return recvFind("OK"); + +} + + +bool ESP8266::eCWSTARTSMART(uint8_t type) +{ + rx_empty(); + m_puart->print(F("AT+CWSTARTSMART=")); + m_puart->println(type); + return recvFind("OK"); +} + +bool ESP8266::eCWSTOPSMART(void) +{ + rx_empty(); + m_puart->println(F("AT+CWSTOPSMART")); + return recvFind("OK"); +} + bool ESP8266::eATCIPSTATUS(String &list) { String data; delay(100); rx_empty(); - m_puart->println("AT+CIPSTATUS"); + m_puart->println(F("AT+CIPSTATUS")); return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list); } -bool ESP8266::sATCIPSTARTSingle(String type, String addr, uint32_t port) + +bool ESP8266::sATCIPSTARTSingleUDP(String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode) +{ + String data; + rx_empty(); + m_puart->print(F("AT+CIPSTART=\"")); + m_puart->print(F("UDP")); + m_puart->print(F("\",\"")); + m_puart->print(remote_addr); + m_puart->print(F("\",")); + m_puart->print(remote_port); + m_puart->print(","); + m_puart->print(local_port); + m_puart->print(","); + m_puart->println(udp_mode); + + data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000); + if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) { + return true; + } + return false; +} + +bool ESP8266::sATCIPSTARTMultipleUDP(uint8_t mux_id, String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode) +{ + String data; + rx_empty(); + m_puart->print(F("AT+CIPSTART=")); + m_puart->print(mux_id); + m_puart->print(F(",\"")); + m_puart->print(F("UDP")); + m_puart->print(F("\",\"")); + m_puart->print(remote_addr); + m_puart->print(F("\",")); + m_puart->print(remote_port); + m_puart->print(","); + m_puart->print(local_port); + m_puart->print(","); + m_puart->println(udp_mode); + + data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000); + if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) { + return true; + } + return false; +} +bool ESP8266::sATCIPSTARTSingleTCP(String addr, uint32_t port, uint16_t keep_alive=0) { String data; rx_empty(); - m_puart->print("AT+CIPSTART=\""); - m_puart->print(type); - m_puart->print("\",\""); + m_puart->print(F("AT+CIPSTART=\"")); + m_puart->print(F("TCP")); + m_puart->print(F("\",\"")); m_puart->print(addr); - m_puart->print("\","); - m_puart->println(port); + m_puart->print(F("\",")); + m_puart->print(port); + m_puart->print(","); + m_puart->println(keep_alive); data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000); if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) { @@ -601,18 +1198,20 @@ bool ESP8266::sATCIPSTARTSingle(String type, String addr, uint32_t port) } return false; } -bool ESP8266::sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port) +bool ESP8266::sATCIPSTARTMultipleTCP(uint8_t mux_id, String addr, uint32_t port, uint16_t keep_alive=0) { String data; rx_empty(); - m_puart->print("AT+CIPSTART="); + m_puart->print(F("AT+CIPSTART=")); m_puart->print(mux_id); - m_puart->print(",\""); - m_puart->print(type); - m_puart->print("\",\""); + m_puart->print(F(",\"")); + m_puart->print(F("TCP")); + m_puart->print(F("\",\"")); m_puart->print(addr); - m_puart->print("\","); - m_puart->println(port); + m_puart->print(F("\",")); + m_puart->print(port); + m_puart->print(","); + m_puart->println(keep_alive); data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000); if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) { @@ -623,7 +1222,7 @@ bool ESP8266::sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len) { rx_empty(); - m_puart->print("AT+CIPSEND="); + m_puart->print(F("AT+CIPSEND=")); m_puart->println(len); if (recvFind(">", 5000)) { rx_empty(); @@ -637,9 +1236,9 @@ bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len) bool ESP8266::sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len) { rx_empty(); - m_puart->print("AT+CIPSEND="); + m_puart->print(F("AT+CIPSEND=")); m_puart->print(mux_id); - m_puart->print(","); + m_puart->print(F(",")); m_puart->println(len); if (recvFind(">", 5000)) { rx_empty(); @@ -650,11 +1249,41 @@ bool ESP8266::sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t } return false; } +bool ESP8266::sATCIPSENDSingleFromFlash(const uint8_t *buffer, uint32_t len) +{ + rx_empty(); + m_puart->print(F("AT+CIPSEND=")); + m_puart->println(len); + if (recvFind(">", 5000)) { + rx_empty(); + for (uint32_t i = 0; i < len; i++) { + m_puart->write((char) pgm_read_byte(&buffer[i])); + } + return recvFind("SEND OK", 10000); + } + return false; +} +bool ESP8266::sATCIPSENDMultipleFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len) +{ + rx_empty(); + m_puart->print(F("AT+CIPSEND=")); + m_puart->print(mux_id); + m_puart->print(F(",")); + m_puart->println(len); + if (recvFind(">", 5000)) { + rx_empty(); + for (uint32_t i = 0; i < len; i++) { + m_puart->write((char) pgm_read_byte(&buffer[i])); + } + return recvFind("SEND OK", 10000); + } + return false; +} bool ESP8266::sATCIPCLOSEMulitple(uint8_t mux_id) { String data; rx_empty(); - m_puart->print("AT+CIPCLOSE="); + m_puart->print(F("AT+CIPCLOSE=")); m_puart->println(mux_id); data = recvString("OK", "link is not", 5000); @@ -666,20 +1295,28 @@ bool ESP8266::sATCIPCLOSEMulitple(uint8_t mux_id) bool ESP8266::eATCIPCLOSESingle(void) { rx_empty(); - m_puart->println("AT+CIPCLOSE"); + m_puart->println(F("AT+CIPCLOSE")); + return recvFind("OK", 5000); +} + +bool ESP8266::eATCIPCLOSEMultiple(uint8_t mux_id) +{ + rx_empty(); + m_puart->print(F("AT+CIPCLOSE=")); + m_puart->println(mux_id); return recvFind("OK", 5000); } bool ESP8266::eATCIFSR(String &list) { rx_empty(); - m_puart->println("AT+CIFSR"); + m_puart->println(F("AT+CIFSR")); return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list); } bool ESP8266::sATCIPMUX(uint8_t mode) { String data; rx_empty(); - m_puart->print("AT+CIPMUX="); + m_puart->print(F("AT+CIPMUX=")); m_puart->println(mode); data = recvString("OK", "Link is builded"); @@ -693,7 +1330,7 @@ bool ESP8266::sATCIPSERVER(uint8_t mode, uint32_t port) String data; if (mode) { rx_empty(); - m_puart->print("AT+CIPSERVER=1,"); + m_puart->print(F("AT+CIPSERVER=1,")); m_puart->println(port); data = recvString("OK", "no change"); @@ -703,14 +1340,68 @@ bool ESP8266::sATCIPSERVER(uint8_t mode, uint32_t port) return false; } else { rx_empty(); - m_puart->println("AT+CIPSERVER=0"); + m_puart->println(F("AT+CIPSERVER=0")); return recvFind("\r\r\n"); } } + + +bool ESP8266::sATCIPMODE(uint8_t mode) +{ + String data; + if(mode>1||mode<0){ + return false; + } + rx_empty(); + m_puart->print(F("AT+CIPMODE=")); + m_puart->println(mode); + + data = recvString("OK", "Link is builded",2000); + if (data.indexOf("OK") != -1 ) { + return true; + } + return false; +} + + + + +bool ESP8266::eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port) +{ + + String data; + rx_empty(); + m_puart->print(F("AT+SAVETRANSLINK=")); + m_puart->print(mode); + m_puart->print(F(",\"")); + m_puart->print(ip); + m_puart->print(F("\",")); + m_puart->println(port); + data = recvString("OK", "ERROR",2000); + if (data.indexOf("OK") != -1 ) { + return true; + } + return false; +} + + + +bool ESP8266::eATPING(String ip) +{ + rx_empty(); + m_puart->print(F("AT+PING=")); + m_puart->print(F("\"")); + m_puart->print(ip); + m_puart->println(F("\"")); + return recvFind("OK",2000); +} + + + bool ESP8266::sATCIPSTO(uint32_t timeout) { rx_empty(); - m_puart->print("AT+CIPSTO="); + m_puart->print(F("AT+CIPSTO=")); m_puart->println(timeout); return recvFind("OK"); } diff --git a/ESP8266.h b/ESP8266.h index bf82755..1505318 100644 --- a/ESP8266.h +++ b/ESP8266.h @@ -23,14 +23,21 @@ #include "Arduino.h" - //#define ESP8266_USE_SOFTWARE_SERIAL - #ifdef ESP8266_USE_SOFTWARE_SERIAL #include "SoftwareSerial.h" #endif +#define VERSION_18 0X18 +#define VERSION_22 0X22 +#define DEFAULT_PATTERN 3 + +/** + * You can modify the macro to choose a different version + */ + +#define USER_SEL_VERSION VERSION_18 /** * Provide an easy-to-use way to manipulate ESP8266. @@ -47,7 +54,12 @@ class ESP8266 { * * @warning parameter baud depends on the AT firmware. 9600 is an common value. */ +#if (USER_SEL_VERSION == VERSION_22) + ESP8266(SoftwareSerial &uart, uint32_t baud = 115200); +#elif (USER_SEL_VERSION == VERSION_18) ESP8266(SoftwareSerial &uart, uint32_t baud = 9600); +#endif /* #if(USER_SEL_VERSION==VERSION_22) */ + #else /* HardwareSerial */ /* * Constuctor. @@ -57,8 +69,14 @@ class ESP8266 { * * @warning parameter baud depends on the AT firmware. 9600 is an common value. */ +#if (USER_SEL_VERSION == VERSION_22) + ESP8266(HardwareSerial &uart, uint32_t baud = 115200); +#elif (USER_SEL_VERSION == VERSION_18) ESP8266(HardwareSerial &uart, uint32_t baud = 9600); -#endif +#endif /* #if(USER_SEL_VERSION == VERSION_22) */ + + +#endif /* #ifdef ESP8266_USE_SOFTWARE_SERIAL */ /** @@ -82,35 +100,99 @@ class ESP8266 { bool restart(void); /** - * Get the version of AT Command Set. + * Get the version of AT Command Set. * - * @return the string of version. + * @return the string of version. */ String getVersion(void); /** - * Set operation mode to staion. + * Start function of deep sleep. * - * @retval true - success. - * @retval false - failure. + * @param time - the sleep time. + * @retval true - success. + * @retval false - failure. + * @note the feature requires hardware support. */ - bool setOprToStation(void); + bool deepSleep(uint32_t time); /** - * Set operation mode to softap. + * Switch the echo function. * + * @param mode - 1 start echo -0 stop echo + * @retval true - success. + * @retval false - failure. + * + */ + bool setEcho(uint8_t mode); + + /** + * Restore factory. + * @retval true - success. + * @retval false - failure. + * @note The operation can lead to restart the machine. + */ + bool restore(void); + + /** + * Set up a serial port configuration. + * + * @param pattern -1 send "AT+UART=", -2 send "AT+UART_CUR=", -3 send "AT+UART_DEF=". + * @param baudrate - the uart baudrate. + * @retval true - success. + * @retval false - failure. + * @note Only allows baud rate design, for the other parameters:databits- 8,stopbits -1,parity -0,flow control -0 . + */ + bool setUart(uint32_t baudrate,uint8_t pattern); + + /** + * Set operation mode to station. + * + * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". + * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". * @retval true - success. * @retval false - failure. + * */ - bool setOprToSoftAP(void); + bool setOprToStation(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); /** - * Set operation mode to station + softap. + * Get the model values list. * - * @retval true - success. - * @retval false - failure. + * @return the list of model. + */ + String getWifiModeList(void); + + /** + * Set operation mode to softap. + * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". + * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". + * + * @retval true - success. + * @retval false - failure. + */ + bool setOprToSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); + + /** + * Set operation mode to station + softap. + * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". + * @param pattern2 -1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=". + * + * @retval true - success. + * @retval false - failure. + */ + bool setOprToStationSoftAP(uint8_t pattern1=DEFAULT_PATTERN,uint8_t pattern2=DEFAULT_PATTERN); + + /** + * Get the operation mode. + * @param pattern1 -1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?". + * + * @retval 0 - failure. + * @retval 1 - mode Station. + * @retval 2 - mode AP. + * @retval 3 - mode AP + station. */ - bool setOprToStationSoftAP(void); + uint8_t getOprMode(uint8_t pattern1=DEFAULT_PATTERN); /** * Search available AP list and return it. @@ -121,16 +203,25 @@ class ESP8266 { */ String getAPList(void); + /** + * Search and returns the current connect AP. + * + * @param pattern -1, send "AT+CWJAP_DEF?",-2,send "AT+CWJAP_CUR?",-3,send "AT+CWJAP?". + * @return the ssid of AP connected now. + */ + String getNowConecAp(uint8_t pattern=DEFAULT_PATTERN); + /** * Join in AP. * + * @param pattern -1 send "AT+CWJAP_DEF=" -2 send "AT+CWJAP_CUR=" -3 send "AT+CWJAP=". * @param ssid - SSID of AP to join in. * @param pwd - Password of AP to join in. * @retval true - success. * @retval false - failure. * @note This method will take a couple of seconds. */ - bool joinAP(String ssid, String pwd); + bool joinAP(String ssid, String pwd,uint8_t pattern=DEFAULT_PATTERN); /** * Leave AP joined before. @@ -143,14 +234,25 @@ class ESP8266 { /** * Set SoftAP parameters. * + * @param pattern -1 send "AT+CWSAP_DEF=" -2 send "AT+CWSAP_CUR=" -3 send "AT+CWSAP=". * @param ssid - SSID of SoftAP. * @param pwd - PASSWORD of SoftAP. * @param chl - the channel (1 - 13, default: 7). * @param ecn - the way of encrypstion (0 - OPEN, 1 - WEP, * 2 - WPA_PSK, 3 - WPA2_PSK, 4 - WPA_WPA2_PSK, default: 4). + * @retval true - success. + * @retval false - failure. * @note This method should not be called when station mode. */ - bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4); + bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4,uint8_t pattern=DEFAULT_PATTERN); + + /** + * get SoftAP parameters. + * + * @param pattern -1 send "AT+CWSAP_DEF?" -2 send "AT+CWSAP_CUR?" -3 send "AT+CWSAP?". + * @note This method should not be called when station mode. + */ + String getSoftAPParam(uint8_t pattern=DEFAULT_PATTERN); /** * Get the IP list of devices connected to SoftAP. @@ -160,6 +262,105 @@ class ESP8266 { */ String getJoinedDeviceIP(void); + /** + * Get the current state of DHCP. + * + * @param pattern -1 send "AT+CWDHCP_DEF?" -2 send "AT+CWDHCP_CUR?" -3 send "AT+CWDHCP?". + * @return the state of DHCP. + * + */ + String getDHCP(uint8_t pattern=DEFAULT_PATTERN); + + /** + * Set the state of DHCP. + * @param pattern -1 send "AT+CWDHCP_DEF=" -2 send "AT+CWDHCP_CUR=" -3 send "AT+CWDHCP=". + * @param mode - set ap or set station or set ap + station. + * @param en - 0 disable DHCP - 1 enable DHCP. + * @retval true - success. + * @retval false - failure. + */ + bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=DEFAULT_PATTERN); + + /** + * make boot automatically connected. + * @param en -1 enable -0 disable. + * @retval true - success. + * @retval false - failure. + */ + bool setAutoConnect(uint8_t en); + + /** + * Get the station's MAC address. + * @param pattern -1 send "AT+CIPSTAMAC_DEF?=" -2 send "AT+CIPSTAMAC_CUR?" -3 send "AT+CIPSTAMAC?". + * @return mac address. + * @note This method should not be called when ap mode. + */ + String getStationMac(uint8_t pattern=DEFAULT_PATTERN); + + /** + * Set the station's MAC address. + * @param pattern -1 send "AT+CIPSTAMAC_DEF=" -2 send "AT+CIPSTAMAC_CUR=" -3 send "AT+CIPSTAMAC=". + * @param mac - the mac address of station. + * @retval true - success. + * @retval false - failure. + */ + bool setStationMac(String mac,uint8_t pattern=DEFAULT_PATTERN); + + /** + * Get the station's IP. + * @param pattern -1 send "AT+CIPSTA_DEF?" -2 send "AT+CIPSTA_CUR?" -3 send "AT+CIPSTA?". + * @return the station's IP. + * @note This method should not be called when ap mode. + */ + String getStationIp(uint8_t pattern=DEFAULT_PATTERN); + + /** + * Set the station's IP. + * @param pattern -1 send "AT+CIPSTA_DEF=" -2 send "AT+CIPSTA_CUR=" -3 send "AT+CIPSTA=". + * @param ip - the ip of station. + * @param gateway -the gateway of station. + * @param netmask -the netmask of station. + * @retval true - success. + * @retval false - failure. + * @note This method should not be called when ap mode. + */ + bool setStationIp(String ip,String gateway,String netmask,uint8_t pattern=DEFAULT_PATTERN); + + /** + * Get the AP's IP. + * @param pattern -1 send "AT+CIPAP_DEF?" -2 send "AT+CIPAP_CUR?" -3 send "AT+CIPAP?". + * @return ap's ip. + * @note This method should not be called when station mode. + * + */ + String getAPIp(uint8_t pattern=DEFAULT_PATTERN); + + /** + * Set the AP IP. + * @param pattern -1 send "AT+CIPAP_DEF=" -2 send "AT+CIPAP_CUR=" -3 send "AT+CIPAP=". + * @param ip - the ip of AP. + * @retval true - success. + * @retval false - failure. + * @note This method should not be called when station mode. + */ + bool setAPIp(String ip,uint8_t pattern=DEFAULT_PATTERN); + + /** + * start smartconfig. + * @param type -1:ESP_TOUCH -2:AirKiss. + * @retval true - success. + * @retval false - failure. + */ + bool startSmartConfig(uint8_t type); + + /** + * stop smartconfig. + * + * @retval true - success. + * @retval false - failure. + */ + bool stopSmartConfig(void); + /** * Get the current status of connection(UDP and TCP). * @@ -195,7 +396,6 @@ class ESP8266 { */ bool disableMUX(void); - /** * Create TCP connection in single mode. * @@ -204,7 +404,7 @@ class ESP8266 { * @retval true - success. * @retval false - failure. */ - bool createTCP(String addr, uint32_t port); + bool createTCP(String addr, uint32_t port, uint16_t keep_alive); /** * Release TCP connection in single mode. @@ -218,42 +418,51 @@ class ESP8266 { * Register UDP port number in single mode. * * @param addr - the IP or domain name of the target host. - * @param port - the port number of the target host. + * @param remote_port - the port number of the target host. + * @param local_port - the port number of the local host. + * @param udp_mode - In UDP transparent transmission, it has to be 0: + * 0 : destination peer entity of UDP will not change. + * 1 : destination peer entity of UDP can change once. + * 2 : destination peer entity of UDP is allowed to change. * @retval true - success. * @retval false - failure. */ - bool registerUDP(String addr, uint32_t port); + bool registerUDP(String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode); /** - * Unregister UDP port number in single mode. - * + * Register UDP port number in multiple mode. (to recieve the udp packets too) + * + * @param mux_id - the identifier of this UDP (available value: 0 - 4). + * @param addr - the IP or domain name of the target host. + * @param remote_port - the port number of the target host. + * @param local_port - the port number of the local host. + * @param udp_mode - In UDP transparent transmission, it has to be 0: + * 0 : destination peer entity of UDP will not change. + * 1 : destination peer entity of UDP can change once. + * 2 : destination peer entity of UDP is allowed to change. * @retval true - success. * @retval false - failure. */ - bool unregisterUDP(void); - + bool registerUDP(uint8_t mux_id, String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode); + /** - * Create TCP connection in multiple mode. + * Unregister UDP port number in single mode. * - * @param mux_id - the identifier of this TCP(available value: 0 - 4). - * @param addr - the IP or domain name of the target host. - * @param port - the port number of the target host. * @retval true - success. * @retval false - failure. */ - bool createTCP(uint8_t mux_id, String addr, uint32_t port); - + bool unregisterUDP(void); + /** - * Release TCP connection in multiple mode. - * - * @param mux_id - the identifier of this TCP(available value: 0 - 4). + * Unregister UDP port number in miltiple mode. + * * @retval true - success. * @retval false - failure. */ - bool releaseTCP(uint8_t mux_id); - + bool unregisterUDP(uint8_t mux_id); + /** - * Register UDP port number in multiple mode. + * Create TCP connection in multiple mode. * * @param mux_id - the identifier of this TCP(available value: 0 - 4). * @param addr - the IP or domain name of the target host. @@ -261,17 +470,16 @@ class ESP8266 { * @retval true - success. * @retval false - failure. */ - bool registerUDP(uint8_t mux_id, String addr, uint32_t port); + bool createTCP(uint8_t mux_id, String addr, uint32_t port, uint16_t keep_alive); /** - * Unregister UDP port number in multiple mode. + * Release TCP connection in multiple mode. * * @param mux_id - the identifier of this TCP(available value: 0 - 4). * @retval true - success. * @retval false - failure. */ - bool unregisterUDP(uint8_t mux_id); - + bool releaseTCP(uint8_t mux_id); /** * Set the timeout of TCP Server. @@ -308,24 +516,28 @@ class ESP8266 { bool stopTCPServer(void); /** - * Start Server(Only in multiple mode). + *Set the module transfer mode * - * @param port - the port number to listen(default: 333). * @retval true - success. * @retval false - failure. - * - * @see String getIPStatus(void); - * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout); */ - bool startServer(uint32_t port = 333); - + bool setCIPMODE(uint8_t mode); + /** - * Stop Server(Only in multiple mode). + * Save the passthrough links * * @retval true - success. * @retval false - failure. */ - bool stopServer(void); + bool saveTransLink (uint8_t mode,String ip,uint32_t port); + + /** + * PING COMMAND. + * + * @retval true - success. + * @retval false - failure. + */ + bool setPing(String ip); /** * Send data based on TCP or UDP builded already in single mode. @@ -348,6 +560,27 @@ class ESP8266 { */ bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len); + /** + * Send data based on TCP or UDP builded already in single mode. + * + * @param buffer - the buffer of data to send from flash memeory. + * @param len - the length of data to send. + * @retval true - success. + * @retval false - failure. + */ + bool sendFromFlash(const uint8_t *buffer, uint32_t len); + + /** + * Send data based on one of TCP or UDP builded already in multiple mode. + * + * @param mux_id - the identifier of this TCP(available value: 0 - 4). + * @param buffer - the buffer of data to send from flash memeory. + * @param len - the length of data to send. + * @retval true - success. + * @retval false - failure. + */ + bool sendFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len); + /** * Receive data from TCP or UDP builded already in single mode. * @@ -431,25 +664,52 @@ class ESP8266 { bool eAT(void); bool eATRST(void); bool eATGMR(String &version); - - bool qATCWMODE(uint8_t *mode); - bool sATCWMODE(uint8_t mode); - bool sATCWJAP(String ssid, String pwd); + bool eATGSLP(uint32_t time); + bool eATE(uint8_t mode); + bool eATRESTORE(void); + bool eATSETUART(uint32_t baudrate,uint8_t pattern); + + bool qATCWMODE(uint8_t *mode,uint8_t pattern=3); + bool eATCWMODE(String &list) ; + bool sATCWMODE(uint8_t mode,uint8_t pattern=3); + bool qATCWJAP(String &ssid,uint8_t pattern=3) ; + bool sATCWJAP(String ssid, String pwd,uint8_t pattern=3); bool eATCWLAP(String &list); bool eATCWQAP(void); - bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn); + bool qATCWSAP(String &List,uint8_t pattern=3); + bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern=3); bool eATCWLIF(String &list); - + bool qATCWDHCP(String &List,uint8_t pattern=3); + bool sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3); + bool eATCWAUTOCONN(uint8_t en); + bool qATCIPSTAMAC(String &mac,uint8_t pattern=3); + bool eATCIPSTAMAC(String mac,uint8_t pattern=3); + bool qATCIPSTAIP(String &ip,uint8_t pattern=3); + bool eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern=3); + bool qATCIPAP(String &ip,uint8_t pattern=3); + bool eATCIPAP(String ip,uint8_t pattern=3); + bool eCWSTARTSMART(uint8_t type); + bool eCWSTOPSMART(void); + + bool eATCIPSTATUS(String &list); - bool sATCIPSTARTSingle(String type, String addr, uint32_t port); - bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port); + bool sATCIPSTARTSingleUDP(String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode); + bool sATCIPSTARTMultipleUDP(uint8_t mux_id, String remote_addr, uint32_t remote_port, uint32_t local_port, uint8_t udp_mode); + bool sATCIPSTARTSingleTCP(String addr, uint32_t port, uint16_t keep_alive); + bool sATCIPSTARTMultipleTCP(uint8_t mux_id, String addr, uint32_t port, uint16_t keep_alive); bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len); bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len); + bool sATCIPSENDSingleFromFlash(const uint8_t *buffer, uint32_t len); + bool sATCIPSENDMultipleFromFlash(uint8_t mux_id, const uint8_t *buffer, uint32_t len); bool sATCIPCLOSEMulitple(uint8_t mux_id); bool eATCIPCLOSESingle(void); + bool eATCIPCLOSEMultiple(uint8_t mux_id); bool eATCIFSR(String &list); bool sATCIPMUX(uint8_t mode); bool sATCIPSERVER(uint8_t mode, uint32_t port = 333); + bool sATCIPMODE(uint8_t mode); + bool eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port); + bool eATPING(String ip); bool sATCIPSTO(uint32_t timeout); /* diff --git a/README.md b/README.md index 3ae5326..99a5ade 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ will be useful for Arduino lovers. bool setOprToSoftAP (void) : Set operation mode to softap. bool setOprToStationSoftAP (void) : Set operation mode to station + softap. + + uint8_t getOprMode(void) : Get the operation mode. String getAPList (void) : Search available AP list and return it. @@ -85,6 +87,10 @@ will be useful for Arduino lovers. bool send (const uint8_t *buffer, uint32_t len) : Send data based on TCP or UDP builded already in single mode. bool send (uint8_t mux_id, const uint8_t *buffer, uint32_t len) : Send data based on one of TCP or UDP builded already in multiple mode. + + bool sendFromFlash (const uint8_t *buffer, uint32_t len) : Send data based on TCP or UDP builded already in single mode. + + bool sendFromFlash (uint8_t mux_id, const uint8_t *buffer, uint32_t len) : Send data based on one of TCP or UDP builded already in multiple mode. uint32_t recv (uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from TCP or UDP builded already in single mode. @@ -105,6 +111,18 @@ will be useful for Arduino lovers. - [Iteaduino UNO](http://imall.iteadstudio.com/im130312001.html) - [WBoard Pro](http://imall.iteadstudio.com/im141125005.html) +# Select the version of ESP8266 AT Firmware + +At present, this library supports ESP8266 AT 0.18 version and 0.22 version. You +can select one of them to fit your module by modifing this line in `ESP8266.h`: + + #define USER_SEL_VERSION VERSION_18 + +If you want to select 0.22 version, it should be like below after modification: + + #define USER_SEL_VERSION VERSION_22 + + # Using SoftwareSerial If you want to use SoftwareSerial to communicate with ESP8266, you need to modify diff --git a/doc/API-html/_connect_wi_fi_8ino-example.html b/doc/API-html/_connect_wi_fi_8ino-example.html index cd32d8b..64fca4e 100644 --- a/doc/API-html/_connect_wi_fi_8ino-example.html +++ b/doc/API-html/_connect_wi_fi_8ino-example.html @@ -67,13 +67,13 @@
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStation()) {
+
if (wifi.setOprToStation()) {
Serial.print("to station ok\r\n");
} else {
Serial.print("to station err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
@@ -91,7 +91,7 @@ diff --git a/doc/API-html/_connect_wi_fi_8ino_source.html b/doc/API-html/_connect_wi_fi_8ino_source.html index cd220f0..935645b 100644 --- a/doc/API-html/_connect_wi_fi_8ino_source.html +++ b/doc/API-html/_connect_wi_fi_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_e_s_p8266_8cpp.html b/doc/API-html/_e_s_p8266_8cpp.html index 8d16472..aa0a91d 100644 --- a/doc/API-html/_e_s_p8266_8cpp.html +++ b/doc/API-html/_e_s_p8266_8cpp.html @@ -40,6 +40,7 @@ @@ -68,7 +69,7 @@ diff --git a/doc/API-html/_e_s_p8266_8cpp_source.html b/doc/API-html/_e_s_p8266_8cpp_source.html index facbbae..5e71c86 100644 --- a/doc/API-html/_e_s_p8266_8cpp_source.html +++ b/doc/API-html/_e_s_p8266_8cpp_source.html @@ -40,6 +40,7 @@ @@ -115,682 +116,1284 @@
84  return version;
85 }
86 
-
87 bool ESP8266::setOprToStation(void)
+
87 bool ESP8266::setEcho(uint8_t mode)
88 {
-
89  uint8_t mode;
-
90  if (!qATCWMODE(&mode)) {
-
91  return false;
-
92  }
-
93  if (mode == 1) {
-
94  return true;
-
95  } else {
-
96  if (sATCWMODE(1) && restart()) {
-
97  return true;
-
98  } else {
-
99  return false;
-
100  }
-
101  }
-
102 }
-
103 
-
104 bool ESP8266::setOprToSoftAP(void)
-
105 {
-
106  uint8_t mode;
-
107  if (!qATCWMODE(&mode)) {
-
108  return false;
-
109  }
-
110  if (mode == 2) {
-
111  return true;
-
112  } else {
-
113  if (sATCWMODE(2) && restart()) {
-
114  return true;
-
115  } else {
-
116  return false;
-
117  }
-
118  }
-
119 }
-
120 
-
121 bool ESP8266::setOprToStationSoftAP(void)
-
122 {
-
123  uint8_t mode;
-
124  if (!qATCWMODE(&mode)) {
-
125  return false;
-
126  }
-
127  if (mode == 3) {
-
128  return true;
-
129  } else {
-
130  if (sATCWMODE(3) && restart()) {
-
131  return true;
-
132  } else {
-
133  return false;
-
134  }
-
135  }
-
136 }
-
137 
-
138 String ESP8266::getAPList(void)
-
139 {
-
140  String list;
-
141  eATCWLAP(list);
-
142  return list;
-
143 }
-
144 
-
145 bool ESP8266::joinAP(String ssid, String pwd)
-
146 {
-
147  return sATCWJAP(ssid, pwd);
-
148 }
-
149 
-
150 bool ESP8266::leaveAP(void)
-
151 {
-
152  return eATCWQAP();
-
153 }
-
154 
-
155 bool ESP8266::setSoftAPParam(String ssid, String pwd, uint8_t chl, uint8_t ecn)
-
156 {
-
157  return sATCWSAP(ssid, pwd, chl, ecn);
-
158 }
-
159 
-
160 String ESP8266::getJoinedDeviceIP(void)
-
161 {
-
162  String list;
-
163  eATCWLIF(list);
-
164  return list;
-
165 }
-
166 
-
167 String ESP8266::getIPStatus(void)
-
168 {
-
169  String list;
-
170  eATCIPSTATUS(list);
-
171  return list;
-
172 }
-
173 
-
174 String ESP8266::getLocalIP(void)
-
175 {
-
176  String list;
-
177  eATCIFSR(list);
-
178  return list;
-
179 }
-
180 
-
181 bool ESP8266::enableMUX(void)
-
182 {
-
183  return sATCIPMUX(1);
-
184 }
-
185 
-
186 bool ESP8266::disableMUX(void)
-
187 {
-
188  return sATCIPMUX(0);
-
189 }
-
190 
-
191 bool ESP8266::createTCP(String addr, uint32_t port)
-
192 {
-
193  return sATCIPSTARTSingle("TCP", addr, port);
-
194 }
+
89  return eATE(mode);
+
90 }
+
91 
+
92 bool ESP8266::restore(void)
+
93 {
+
94  return eATRESTORE();
+
95 }
+
96 bool ESP8266::setUart(uint32_t baudrate,uint8_t pattern)
+
97 {
+
98  return eATSETUART(baudrate,pattern);
+
99 }
+
100 
+
101 bool ESP8266::deepSleep(uint32_t time)
+
102 {
+
103  return eATGSLP(time);
+
104 }
+
105 
+
106 
+
107 bool ESP8266::setOprToStation(uint8_t pattern1,uint8_t pattern2)
+
108 {
+
109  uint8_t mode;
+
110  if (!qATCWMODE(&mode,pattern1)) {
+
111  return false;
+
112  }
+
113  if (mode == 1) {
+
114  return true;
+
115  } else {
+
116  if (sATCWMODE(1,pattern2)){
+
117  return true;
+
118  } else {
+
119  return false;
+
120  }
+
121  }
+
122 }
+
123 String ESP8266::getWifiModeList(void)
+
124 {
+
125  String list;
+
126  eATCWMODE(list);
+
127  return list;
+
128 }
+
129 bool ESP8266::setOprToSoftAP(uint8_t pattern1,uint8_t pattern2)
+
130 {
+
131  uint8_t mode;
+
132  if (!qATCWMODE(&mode,pattern1)) {
+
133  return false;
+
134  }
+
135  if (mode == 2) {
+
136  return true;
+
137  } else {
+
138  if (sATCWMODE(2,pattern2) ){
+
139  return true;
+
140  } else {
+
141  return false;
+
142  }
+
143  }
+
144 }
+
145 
+
146 bool ESP8266::setOprToStationSoftAP(uint8_t pattern1,uint8_t pattern2)
+
147 {
+
148  uint8_t mode;
+
149  if (!qATCWMODE(&mode,pattern1)) {
+
150  return false;
+
151  }
+
152  if (mode == 3) {
+
153  return true;
+
154  } else {
+
155  if (sATCWMODE(3,pattern2) ){
+
156  return true;
+
157  } else {
+
158  return false;
+
159  }
+
160  }
+
161 }
+
162 
+
163 String ESP8266::getNowConecAp(uint8_t pattern)
+
164 {
+
165  String ssid;
+
166  qATCWJAP(ssid,pattern);
+
167  return ssid;
+
168 }
+
169 
+
170 
+
171 String ESP8266::getAPList(void)
+
172 {
+
173  String list;
+
174  eATCWLAP(list);
+
175  return list;
+
176 }
+
177 
+
178 bool ESP8266::joinAP(String ssid, String pwd,uint8_t pattern)
+
179 {
+
180  return sATCWJAP(ssid, pwd,pattern);
+
181 }
+
182 
+
183 bool ESP8266::leaveAP(void)
+
184 {
+
185  return eATCWQAP();
+
186 }
+
187 
+
188 String ESP8266::getSoftAPParam(uint8_t pattern)
+
189 {
+
190  String list;
+
191  qATCWSAP(list,pattern);
+
192  return list;
+
193 }
+
194 
195 
-
196 bool ESP8266::releaseTCP(void)
-
197 {
-
198  return eATCIPCLOSESingle();
-
199 }
-
200 
-
201 bool ESP8266::registerUDP(String addr, uint32_t port)
-
202 {
-
203  return sATCIPSTARTSingle("UDP", addr, port);
-
204 }
-
205 
-
206 bool ESP8266::unregisterUDP(void)
-
207 {
-
208  return eATCIPCLOSESingle();
-
209 }
-
210 
-
211 bool ESP8266::createTCP(uint8_t mux_id, String addr, uint32_t port)
-
212 {
-
213  return sATCIPSTARTMultiple(mux_id, "TCP", addr, port);
+
196 
+
197 bool ESP8266::setSoftAPParam(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern)
+
198 {
+
199  return sATCWSAP(ssid, pwd, chl, ecn,pattern);
+
200 }
+
201 
+
202 String ESP8266::getJoinedDeviceIP(void)
+
203 {
+
204  String list;
+
205  eATCWLIF(list);
+
206  return list;
+
207 }
+
208 
+
209 String ESP8266::getDHCP(uint8_t pattern)
+
210 {
+
211  String dhcp;
+
212  qATCWDHCP(dhcp,pattern);
+
213  return dhcp;
214 }
-
215 
-
216 bool ESP8266::releaseTCP(uint8_t mux_id)
-
217 {
-
218  return sATCIPCLOSEMulitple(mux_id);
-
219 }
-
220 
-
221 bool ESP8266::registerUDP(uint8_t mux_id, String addr, uint32_t port)
-
222 {
-
223  return sATCIPSTARTMultiple(mux_id, "UDP", addr, port);
-
224 }
-
225 
-
226 bool ESP8266::unregisterUDP(uint8_t mux_id)
-
227 {
-
228  return sATCIPCLOSEMulitple(mux_id);
+
215 bool ESP8266::setDHCP(uint8_t mode, uint8_t en, uint8_t pattern)
+
216 {
+
217  return sATCWDHCP(mode, en, pattern);
+
218 }
+
219 
+
220 bool ESP8266::setAutoConnect(uint8_t en)
+
221 {
+
222  return eATCWAUTOCONN(en);
+
223 }
+
224 String ESP8266::getStationMac(uint8_t pattern)
+
225 {
+
226  String mac;
+
227  qATCIPSTAMAC(mac,pattern);
+
228  return mac;
229 }
230 
-
231 bool ESP8266::setTCPServerTimeout(uint32_t timeout)
-
232 {
-
233  return sATCIPSTO(timeout);
-
234 }
-
235 
-
236 bool ESP8266::startTCPServer(uint32_t port)
-
237 {
-
238  if (sATCIPSERVER(1, port)) {
-
239  return true;
-
240  }
-
241  return false;
+
231 
+
232 bool ESP8266::setStationMac(String mac,uint8_t pattern)
+
233 {
+
234  return eATCIPSTAMAC(mac,pattern);
+
235 }
+
236 
+
237 String ESP8266::getStationIp(uint8_t pattern)
+
238 {
+
239  String ip;
+
240  qATCIPSTAIP(ip,pattern);
+
241  return ip;
242 }
243 
-
244 bool ESP8266::stopTCPServer(void)
+
244 bool ESP8266::setStationIp(String ip,String gateway,String netmask,uint8_t pattern)
245 {
-
246  sATCIPSERVER(0);
-
247  restart();
-
248  return false;
-
249 }
-
250 
-
251 bool ESP8266::startServer(uint32_t port)
-
252 {
-
253  return startTCPServer(port);
+
246  return eATCIPSTAIP(ip,gateway,netmask,pattern);
+
247 }
+
248 
+
249 String ESP8266::getAPIp(uint8_t pattern)
+
250 {
+
251  String ip;
+
252  qATCIPAP(ip,pattern);
+
253  return ip;
254 }
255 
-
256 bool ESP8266::stopServer(void)
+
256 bool ESP8266::setAPIp(String ip,uint8_t pattern)
257 {
-
258  return stopTCPServer();
+
258  return eATCIPAP(ip,pattern);
259 }
260 
-
261 bool ESP8266::send(const uint8_t *buffer, uint32_t len)
+
261 bool ESP8266::startSmartConfig(uint8_t type)
262 {
-
263  return sATCIPSENDSingle(buffer, len);
+
263  return eCWSTARTSMART(type);
264 }
265 
-
266 bool ESP8266::send(uint8_t mux_id, const uint8_t *buffer, uint32_t len)
+
266 bool ESP8266::stopSmartConfig(void)
267 {
-
268  return sATCIPSENDMultiple(mux_id, buffer, len);
+
268  return eCWSTOPSMART();
269 }
270 
-
271 uint32_t ESP8266::recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
-
272 {
-
273  return recvPkg(buffer, buffer_size, NULL, timeout, NULL);
-
274 }
-
275 
-
276 uint32_t ESP8266::recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
-
277 {
-
278  uint8_t id;
-
279  uint32_t ret;
-
280  ret = recvPkg(buffer, buffer_size, NULL, timeout, &id);
-
281  if (ret > 0 && id == mux_id) {
-
282  return ret;
-
283  }
-
284  return 0;
-
285 }
-
286 
-
287 uint32_t ESP8266::recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
-
288 {
-
289  return recvPkg(buffer, buffer_size, NULL, timeout, coming_mux_id);
-
290 }
-
291 
-
292 /*----------------------------------------------------------------------------*/
-
293 
-
294 uint32_t ESP8266::recvPkg(uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id)
-
295 {
-
296  String data;
-
297  char a;
-
298  int32_t index_PIPDcomma = -1;
-
299  int32_t index_colon = -1; /* : */
-
300  int32_t index_comma = -1; /* , */
-
301  int32_t len = -1;
-
302  int8_t id = -1;
-
303  bool has_data = false;
-
304  //logDebug("start recv pkg");
-
305 
-
306  unsigned long start = millis();
-
307  while (millis() - start < timeout) {
-
308  while(m_puart->available() > 0) {
-
309  a = m_puart->read();
-
310  data += a;
-
311  }
-
312 
-
313  index_PIPDcomma = data.indexOf("+IPD,");
-
314  if (index_PIPDcomma != -1) {
-
315  //logDebug("index_PIPDcomma found = %d", index_PIPDcomma);
-
316  index_colon = data.indexOf(':', index_PIPDcomma + 5);
-
317  if (index_colon != -1) {
-
318  //logDebug("data1 = %s\r\n", data.c_str());
-
319  //logDebug("index_colon found = %d", index_colon);
-
320 
-
321  index_comma = data.indexOf(',', index_PIPDcomma + 5);
-
322  //logDebug("index_comma found = %d", index_comma);
-
323 
-
324  if (index_comma != -1 && index_comma < index_colon) { /* +IPD,id,len:data */
-
325  //logDebug("id = %d", id);
-
326  id = data.substring(index_PIPDcomma + 5, index_comma).toInt();
-
327  //logDebug("id = %d", id);
-
328  if (id < 0 || id > 4) {
-
329  return 0;
-
330  }
-
331  //logDebug("len = %d", len);
-
332  len = data.substring(index_comma + 1, index_colon).toInt();
-
333  //logDebug("len = %d", len);
-
334  if (len <= 0) {
-
335  return 0;
-
336  }
-
337  //logDebug("has id");
-
338  } else { /* +IPD,len:data */
-
339  len = data.substring(index_PIPDcomma + 5, index_colon).toInt();
-
340  //logDebug("len = %d", len);
-
341  if (len <= 0) {
-
342  return 0;
-
343  }
-
344  //logDebug("no id");
-
345  }
-
346  has_data = true;
-
347  //logDebug("has_data true");
-
348  break;
-
349  }
-
350  }
-
351  }
-
352  //logDebug("has_data = %u\r\n", has_data);
-
353  //logDebug("data2 = %s\r\n", data.c_str());
-
354 
-
355  if (has_data) {
-
356  start = millis();
-
357  while (millis() - start < 3000) {
-
358  while(m_puart->available() > 0) {
-
359  a = m_puart->read();
-
360  data += a;
-
361  }
-
362  //logDebug("data3 = %s\r\n", data.c_str());
-
363  if (data.length() >= index_colon + 1 + len) {
-
364  if (data_len) {
-
365  *data_len = len;
-
366  }
-
367  if (index_comma != -1 && coming_mux_id) {
-
368  *coming_mux_id = id;
-
369  }
-
370  //logDebug("len = %d", len);
-
371  //logDebug("buffer_size = %d", buffer_size);
-
372  uint32_t ret = len > buffer_size ? buffer_size : len;
-
373 
-
374  memcpy(buffer,
-
375  data.substring(index_colon + 1, index_colon + 1 + len).c_str(),
-
376  ret);
-
377  //logDebug("ret = %u\r\n", ret);
-
378  return ret;
-
379  }
-
380  }
-
381  }
-
382  //logDebug("end recv pkg");
-
383  return 0;
+
271 
+
272 
+
273 
+
274 String ESP8266::getIPStatus(void)
+
275 {
+
276  String list;
+
277  eATCIPSTATUS(list);
+
278  return list;
+
279 }
+
280 
+
281 String ESP8266::getLocalIP(void)
+
282 {
+
283  String list;
+
284  eATCIFSR(list);
+
285  return list;
+
286 }
+
287 
+
288 bool ESP8266::enableMUX(void)
+
289 {
+
290  return sATCIPMUX(1);
+
291 }
+
292 
+
293 bool ESP8266::disableMUX(void)
+
294 {
+
295  return sATCIPMUX(0);
+
296 }
+
297 
+
298 bool ESP8266::createTCP(String addr, uint32_t port)
+
299 {
+
300  return sATCIPSTARTSingle("TCP", addr, port);
+
301 }
+
302 
+
303 bool ESP8266::releaseTCP(void)
+
304 {
+
305  return eATCIPCLOSESingle();
+
306 }
+
307 
+
308 bool ESP8266::registerUDP(String addr, uint32_t port)
+
309 {
+
310  return sATCIPSTARTSingle("UDP", addr, port);
+
311 }
+
312 
+
313 bool ESP8266::unregisterUDP(void)
+
314 {
+
315  return eATCIPCLOSESingle();
+
316 }
+
317 
+
318 bool ESP8266::createTCP(uint8_t mux_id, String addr, uint32_t port)
+
319 {
+
320  return sATCIPSTARTMultiple(mux_id, "TCP", addr, port);
+
321 }
+
322 
+
323 bool ESP8266::releaseTCP(uint8_t mux_id)
+
324 {
+
325  return sATCIPCLOSEMulitple(mux_id);
+
326 }
+
327 
+
328 bool ESP8266::registerUDP(uint8_t mux_id, String addr, uint32_t port)
+
329 {
+
330  return sATCIPSTARTMultiple(mux_id, "UDP", addr, port);
+
331 }
+
332 
+
333 bool ESP8266::unregisterUDP(uint8_t mux_id)
+
334 {
+
335  return sATCIPCLOSEMulitple(mux_id);
+
336 }
+
337 
+
338 bool ESP8266::setTCPServerTimeout(uint32_t timeout)
+
339 {
+
340  return sATCIPSTO(timeout);
+
341 }
+
342 
+
343 bool ESP8266::startTCPServer(uint32_t port)
+
344 {
+
345  if (sATCIPSERVER(1, port)) {
+
346  return true;
+
347  }
+
348  return false;
+
349 }
+
350 
+
351 bool ESP8266::stopTCPServer(void)
+
352 {
+
353  sATCIPSERVER(0);
+
354  restart();
+
355  return false;
+
356 }
+
357 
+
358 bool ESP8266::setCIPMODE(uint8_t mode)
+
359 {
+
360  return sATCIPMODE(mode);
+
361 }
+
362 
+
363 bool ESP8266::saveTransLink (uint8_t mode,String ip,uint32_t port)
+
364 {
+
365  return eATSAVETRANSLINK(mode,ip,port);
+
366 }
+
367 
+
368 bool ESP8266::setPing(String ip)
+
369 {
+
370  return eATPING(ip);
+
371 }
+
372 
+
373 
+
374 
+
375 
+
376 bool ESP8266::startServer(uint32_t port)
+
377 {
+
378  return startTCPServer(port);
+
379 }
+
380 
+
381 bool ESP8266::stopServer(void)
+
382 {
+
383  return stopTCPServer();
384 }
385 
-
386 void ESP8266::rx_empty(void)
+
386 bool ESP8266::send(const uint8_t *buffer, uint32_t len)
387 {
-
388  while(m_puart->available() > 0) {
-
389  m_puart->read();
-
390  }
-
391 }
-
392 
-
393 String ESP8266::recvString(String target, uint32_t timeout)
-
394 {
-
395  String data;
-
396  char a;
-
397  unsigned long start = millis();
-
398  while (millis() - start < timeout) {
-
399  while(m_puart->available() > 0) {
-
400  a = m_puart->read();
-
401  if(a == '\0') continue;
-
402  data += a;
-
403  }
-
404  if (data.indexOf(target) != -1) {
-
405  break;
-
406  }
-
407  }
-
408  return data;
-
409 }
-
410 
-
411 String ESP8266::recvString(String target1, String target2, uint32_t timeout)
-
412 {
-
413  String data;
-
414  char a;
-
415  unsigned long start = millis();
-
416  while (millis() - start < timeout) {
-
417  while(m_puart->available() > 0) {
-
418  a = m_puart->read();
-
419  if(a == '\0') continue;
-
420  data += a;
-
421  }
-
422  if (data.indexOf(target1) != -1) {
-
423  break;
-
424  } else if (data.indexOf(target2) != -1) {
-
425  break;
-
426  }
-
427  }
-
428  return data;
-
429 }
-
430 
-
431 String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout)
-
432 {
-
433  String data;
-
434  char a;
-
435  unsigned long start = millis();
-
436  while (millis() - start < timeout) {
-
437  while(m_puart->available() > 0) {
-
438  a = m_puart->read();
-
439  if(a == '\0') continue;
-
440  data += a;
-
441  }
-
442  if (data.indexOf(target1) != -1) {
-
443  break;
-
444  } else if (data.indexOf(target2) != -1) {
-
445  break;
-
446  } else if (data.indexOf(target3) != -1) {
-
447  break;
-
448  }
-
449  }
-
450  return data;
-
451 }
-
452 
-
453 bool ESP8266::recvFind(String target, uint32_t timeout)
-
454 {
-
455  String data_tmp;
-
456  data_tmp = recvString(target, timeout);
-
457  if (data_tmp.indexOf(target) != -1) {
-
458  return true;
-
459  }
-
460  return false;
-
461 }
-
462 
-
463 bool ESP8266::recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout)
-
464 {
-
465  String data_tmp;
-
466  data_tmp = recvString(target, timeout);
-
467  if (data_tmp.indexOf(target) != -1) {
-
468  int32_t index1 = data_tmp.indexOf(begin);
-
469  int32_t index2 = data_tmp.indexOf(end);
-
470  if (index1 != -1 && index2 != -1) {
-
471  index1 += begin.length();
-
472  data = data_tmp.substring(index1, index2);
-
473  return true;
-
474  }
-
475  }
-
476  data = "";
-
477  return false;
-
478 }
-
479 
-
480 bool ESP8266::eAT(void)
-
481 {
-
482  rx_empty();
-
483  m_puart->println("AT");
-
484  return recvFind("OK");
-
485 }
-
486 
-
487 bool ESP8266::eATRST(void)
-
488 {
-
489  rx_empty();
-
490  m_puart->println("AT+RST");
-
491  return recvFind("OK");
-
492 }
-
493 
-
494 bool ESP8266::eATGMR(String &version)
-
495 {
-
496  rx_empty();
-
497  m_puart->println("AT+GMR");
-
498  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", version);
-
499 }
-
500 
-
501 bool ESP8266::qATCWMODE(uint8_t *mode)
-
502 {
-
503  String str_mode;
-
504  bool ret;
-
505  if (!mode) {
-
506  return false;
-
507  }
-
508  rx_empty();
-
509  m_puart->println("AT+CWMODE?");
-
510  ret = recvFindAndFilter("OK", "+CWMODE:", "\r\n\r\nOK", str_mode);
-
511  if (ret) {
-
512  *mode = (uint8_t)str_mode.toInt();
-
513  return true;
-
514  } else {
-
515  return false;
-
516  }
-
517 }
-
518 
-
519 bool ESP8266::sATCWMODE(uint8_t mode)
-
520 {
-
521  String data;
-
522  rx_empty();
-
523  m_puart->print("AT+CWMODE=");
-
524  m_puart->println(mode);
-
525 
-
526  data = recvString("OK", "no change");
-
527  if (data.indexOf("OK") != -1 || data.indexOf("no change") != -1) {
-
528  return true;
-
529  }
-
530  return false;
-
531 }
-
532 
-
533 bool ESP8266::sATCWJAP(String ssid, String pwd)
-
534 {
-
535  String data;
-
536  rx_empty();
-
537  m_puart->print("AT+CWJAP=\"");
-
538  m_puart->print(ssid);
-
539  m_puart->print("\",\"");
-
540  m_puart->print(pwd);
-
541  m_puart->println("\"");
-
542 
-
543  data = recvString("OK", "FAIL", 10000);
-
544  if (data.indexOf("OK") != -1) {
-
545  return true;
-
546  }
-
547  return false;
-
548 }
-
549 
-
550 bool ESP8266::eATCWLAP(String &list)
-
551 {
-
552  String data;
-
553  rx_empty();
-
554  m_puart->println("AT+CWLAP");
-
555  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list, 10000);
-
556 }
-
557 
-
558 bool ESP8266::eATCWQAP(void)
-
559 {
-
560  String data;
-
561  rx_empty();
-
562  m_puart->println("AT+CWQAP");
-
563  return recvFind("OK");
-
564 }
-
565 
-
566 bool ESP8266::sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn)
-
567 {
-
568  String data;
-
569  rx_empty();
-
570  m_puart->print("AT+CWSAP=\"");
-
571  m_puart->print(ssid);
-
572  m_puart->print("\",\"");
-
573  m_puart->print(pwd);
-
574  m_puart->print("\",");
-
575  m_puart->print(chl);
-
576  m_puart->print(",");
-
577  m_puart->println(ecn);
-
578 
-
579  data = recvString("OK", "ERROR", 5000);
-
580  if (data.indexOf("OK") != -1) {
-
581  return true;
-
582  }
-
583  return false;
-
584 }
-
585 
-
586 bool ESP8266::eATCWLIF(String &list)
-
587 {
-
588  String data;
-
589  rx_empty();
-
590  m_puart->println("AT+CWLIF");
-
591  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
-
592 }
-
593 bool ESP8266::eATCIPSTATUS(String &list)
-
594 {
-
595  String data;
-
596  delay(100);
-
597  rx_empty();
-
598  m_puart->println("AT+CIPSTATUS");
-
599  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
-
600 }
-
601 bool ESP8266::sATCIPSTARTSingle(String type, String addr, uint32_t port)
-
602 {
-
603  String data;
-
604  rx_empty();
-
605  m_puart->print("AT+CIPSTART=\"");
-
606  m_puart->print(type);
-
607  m_puart->print("\",\"");
-
608  m_puart->print(addr);
-
609  m_puart->print("\",");
-
610  m_puart->println(port);
-
611 
-
612  data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000);
-
613  if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) {
-
614  return true;
-
615  }
-
616  return false;
-
617 }
-
618 bool ESP8266::sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port)
-
619 {
-
620  String data;
-
621  rx_empty();
-
622  m_puart->print("AT+CIPSTART=");
-
623  m_puart->print(mux_id);
-
624  m_puart->print(",\"");
-
625  m_puart->print(type);
-
626  m_puart->print("\",\"");
-
627  m_puart->print(addr);
-
628  m_puart->print("\",");
-
629  m_puart->println(port);
-
630 
-
631  data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000);
-
632  if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) {
-
633  return true;
-
634  }
-
635  return false;
+
388  return sATCIPSENDSingle(buffer, len);
+
389 }
+
390 
+
391 bool ESP8266::send(uint8_t mux_id, const uint8_t *buffer, uint32_t len)
+
392 {
+
393  return sATCIPSENDMultiple(mux_id, buffer, len);
+
394 }
+
395 
+
396 uint32_t ESP8266::recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
+
397 {
+
398  return recvPkg(buffer, buffer_size, NULL, timeout, NULL);
+
399 }
+
400 
+
401 uint32_t ESP8266::recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
+
402 {
+
403  uint8_t id;
+
404  uint32_t ret;
+
405  ret = recvPkg(buffer, buffer_size, NULL, timeout, &id);
+
406  if (ret > 0 && id == mux_id) {
+
407  return ret;
+
408  }
+
409  return 0;
+
410 }
+
411 
+
412 uint32_t ESP8266::recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
+
413 {
+
414  return recvPkg(buffer, buffer_size, NULL, timeout, coming_mux_id);
+
415 }
+
416 
+
417 /*----------------------------------------------------------------------------*/
+
418 /* +IPD,<id>,<len>:<data> */
+
419 /* +IPD,<len>:<data> */
+
420 
+
421 uint32_t ESP8266::recvPkg(uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id)
+
422 {
+
423  String data;
+
424  char a;
+
425  int32_t index_PIPDcomma = -1;
+
426  int32_t index_colon = -1; /* : */
+
427  int32_t index_comma = -1; /* , */
+
428  int32_t len = -1;
+
429  int8_t id = -1;
+
430  bool has_data = false;
+
431  uint32_t ret;
+
432  unsigned long start;
+
433  uint32_t i;
+
434 
+
435  if (buffer == NULL) {
+
436  return 0;
+
437  }
+
438 
+
439  start = millis();
+
440  while (millis() - start < timeout) {
+
441  if(m_puart->available() > 0) {
+
442  a = m_puart->read();
+
443  data += a;
+
444  }
+
445 
+
446  index_PIPDcomma = data.indexOf("+IPD,");
+
447  if (index_PIPDcomma != -1) {
+
448  index_colon = data.indexOf(':', index_PIPDcomma + 5);
+
449  if (index_colon != -1) {
+
450  index_comma = data.indexOf(',', index_PIPDcomma + 5);
+
451  /* +IPD,id,len:data */
+
452  if (index_comma != -1 && index_comma < index_colon) {
+
453  id = data.substring(index_PIPDcomma + 5, index_comma).toInt();
+
454  if (id < 0 || id > 4) {
+
455  return 0;
+
456  }
+
457  len = data.substring(index_comma + 1, index_colon).toInt();
+
458  if (len <= 0) {
+
459  return 0;
+
460  }
+
461  } else { /* +IPD,len:data */
+
462  len = data.substring(index_PIPDcomma + 5, index_colon).toInt();
+
463  if (len <= 0) {
+
464  return 0;
+
465  }
+
466  }
+
467  has_data = true;
+
468  break;
+
469  }
+
470  }
+
471  }
+
472 
+
473  if (has_data) {
+
474  i = 0;
+
475  ret = len > buffer_size ? buffer_size : len;
+
476  start = millis();
+
477  while (millis() - start < 3000) {
+
478  while(m_puart->available() > 0 && i < ret) {
+
479  a = m_puart->read();
+
480  buffer[i++] = a;
+
481  }
+
482  if (i == ret) {
+
483  rx_empty();
+
484  if (data_len) {
+
485  *data_len = len;
+
486  }
+
487  if (index_comma != -1 && coming_mux_id) {
+
488  *coming_mux_id = id;
+
489  }
+
490  return ret;
+
491  }
+
492  }
+
493  }
+
494  return 0;
+
495 }
+
496 
+
497 void ESP8266::rx_empty(void)
+
498 {
+
499  while(m_puart->available() > 0) {
+
500  m_puart->read();
+
501  }
+
502 }
+
503 
+
504 String ESP8266::recvString(String target, uint32_t timeout)
+
505 {
+
506  String data;
+
507  char a;
+
508  unsigned long start = millis();
+
509  while (millis() - start < timeout) {
+
510  while(m_puart->available() > 0) {
+
511  a = m_puart->read();
+
512  if(a == '\0') continue;
+
513  data += a;
+
514  }
+
515  if (data.indexOf(target) != -1) {
+
516  break;
+
517  }
+
518  }
+
519 
+
520  return data;
+
521 }
+
522 
+
523 String ESP8266::recvString(String target1, String target2, uint32_t timeout)
+
524 {
+
525  String data;
+
526  char a;
+
527  unsigned long start = millis();
+
528  while (millis() - start < timeout) {
+
529  while(m_puart->available() > 0) {
+
530  a = m_puart->read();
+
531  if(a == '\0') continue;
+
532  data += a;
+
533  }
+
534  if (data.indexOf(target1) != -1) {
+
535  break;
+
536  } else if (data.indexOf(target2) != -1) {
+
537  break;
+
538  }
+
539  }
+
540  return data;
+
541 }
+
542 
+
543 String ESP8266::recvString(String target1, String target2, String target3, uint32_t timeout)
+
544 {
+
545  String data;
+
546  char a;
+
547  unsigned long start = millis();
+
548  while (millis() - start < timeout) {
+
549  while(m_puart->available() > 0) {
+
550  a = m_puart->read();
+
551  if(a == '\0') continue;
+
552  data += a;
+
553  }
+
554  if (data.indexOf(target1) != -1) {
+
555  break;
+
556  } else if (data.indexOf(target2) != -1) {
+
557  break;
+
558  } else if (data.indexOf(target3) != -1) {
+
559  break;
+
560  }
+
561  }
+
562  return data;
+
563 }
+
564 
+
565 bool ESP8266::recvFind(String target, uint32_t timeout)
+
566 {
+
567  String data_tmp;
+
568  data_tmp = recvString(target, timeout);
+
569  if (data_tmp.indexOf(target) != -1) {
+
570  return true;
+
571  }
+
572  return false;
+
573 }
+
574 
+
575 bool ESP8266::recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout)
+
576 {
+
577  String data_tmp;
+
578  data_tmp = recvString(target, timeout);
+
579  if (data_tmp.indexOf(target) != -1) {
+
580  int32_t index1 = data_tmp.indexOf(begin);
+
581  int32_t index2 = data_tmp.indexOf(end);
+
582  if (index1 != -1 && index2 != -1) {
+
583  index1 += begin.length();
+
584  data = data_tmp.substring(index1, index2);
+
585  return true;
+
586  }
+
587  }
+
588  data = "";
+
589  return false;
+
590 }
+
591 
+
592 bool ESP8266::eAT(void)
+
593 {
+
594  rx_empty();
+
595  m_puart->println("AT");
+
596  return recvFind("OK");
+
597 }
+
598 
+
599 bool ESP8266::eATRST(void)
+
600 {
+
601  rx_empty();
+
602  m_puart->println("AT+RST");
+
603  return recvFind("OK");
+
604 }
+
605 
+
606 bool ESP8266::eATGMR(String &version)
+
607 {
+
608  rx_empty();
+
609  delay(3000);
+
610  m_puart->println("AT+GMR");
+
611  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", version,10000);
+
612 }
+
613 
+
614 bool ESP8266::eATGSLP(uint32_t time)
+
615 {
+
616  rx_empty();
+
617  m_puart->print("AT+GSLP=");
+
618  m_puart->println(time);
+
619  return recvFind("OK");
+
620 }
+
621 
+
622 
+
623 bool ESP8266::eATE(uint8_t mode)
+
624 {
+
625  rx_empty();
+
626  m_puart->print("ATE");
+
627  m_puart->println(mode);
+
628  return recvFind("OK");
+
629 }
+
630 
+
631 bool ESP8266::eATRESTORE(void)
+
632 {
+
633  rx_empty();
+
634  m_puart->println("AT+RESTORE");
+
635  return recvFind("OK");
636 }
-
637 bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len)
-
638 {
-
639  rx_empty();
-
640  m_puart->print("AT+CIPSEND=");
-
641  m_puart->println(len);
-
642  if (recvFind(">", 5000)) {
-
643  rx_empty();
-
644  for (uint32_t i = 0; i < len; i++) {
-
645  m_puart->write(buffer[i]);
-
646  }
-
647  return recvFind("SEND OK", 10000);
-
648  }
-
649  return false;
-
650 }
-
651 bool ESP8266::sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len)
-
652 {
-
653  rx_empty();
-
654  m_puart->print("AT+CIPSEND=");
-
655  m_puart->print(mux_id);
-
656  m_puart->print(",");
-
657  m_puart->println(len);
-
658  if (recvFind(">", 5000)) {
-
659  rx_empty();
-
660  for (uint32_t i = 0; i < len; i++) {
-
661  m_puart->write(buffer[i]);
-
662  }
-
663  return recvFind("SEND OK", 10000);
-
664  }
-
665  return false;
-
666 }
-
667 bool ESP8266::sATCIPCLOSEMulitple(uint8_t mux_id)
-
668 {
-
669  String data;
-
670  rx_empty();
-
671  m_puart->print("AT+CIPCLOSE=");
-
672  m_puart->println(mux_id);
-
673 
-
674  data = recvString("OK", "link is not", 5000);
-
675  if (data.indexOf("OK") != -1 || data.indexOf("link is not") != -1) {
-
676  return true;
-
677  }
-
678  return false;
-
679 }
-
680 bool ESP8266::eATCIPCLOSESingle(void)
-
681 {
-
682  rx_empty();
-
683  m_puart->println("AT+CIPCLOSE");
-
684  return recvFind("OK", 5000);
-
685 }
-
686 bool ESP8266::eATCIFSR(String &list)
-
687 {
-
688  rx_empty();
-
689  m_puart->println("AT+CIFSR");
-
690  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
-
691 }
-
692 bool ESP8266::sATCIPMUX(uint8_t mode)
-
693 {
-
694  String data;
-
695  rx_empty();
-
696  m_puart->print("AT+CIPMUX=");
-
697  m_puart->println(mode);
-
698 
-
699  data = recvString("OK", "Link is builded");
-
700  if (data.indexOf("OK") != -1) {
-
701  return true;
+
637 
+
638 
+
639 bool ESP8266::eATSETUART(uint32_t baudrate,uint8_t pattern)
+
640 {
+
641  rx_empty();
+
642  if(pattern>3||pattern<1){
+
643  return false;
+
644  }
+
645  switch(pattern){
+
646  case 1:
+
647  m_puart->print("AT+UART=");
+
648  break;
+
649  case 2:
+
650  m_puart->print("AT+UART_CUR=");
+
651  break;
+
652  case 3:
+
653  m_puart->print("AT+UART_DEF=");
+
654  break;
+
655  }
+
656  m_puart->print(baudrate);
+
657  m_puart->print(",");
+
658  m_puart->print(8);
+
659  m_puart->print(",");
+
660  m_puart->print(1);
+
661  m_puart->print(",");
+
662  m_puart->print(0);
+
663  m_puart->print(",");
+
664  m_puart->println(0);
+
665  if(recvFind("OK",5000)){
+
666 
+
667  m_puart->begin(baudrate);
+
668  return true;
+
669  }
+
670  else{
+
671  return false;
+
672  }
+
673 
+
674 }
+
675 
+
676 
+
677 bool ESP8266::qATCWMODE(uint8_t *mode,uint8_t pattern)
+
678 {
+
679  String str_mode;
+
680  bool ret;
+
681  if (!mode||!pattern) {
+
682  return false;
+
683  }
+
684  rx_empty();
+
685  switch(pattern)
+
686  {
+
687  case 1 :
+
688  m_puart->println("AT+CWMODE_DEF?");
+
689  break;
+
690  case 2:
+
691  m_puart->println("AT+CWMODE_CUR?");
+
692  break;
+
693  default:
+
694  m_puart->println("AT+CWMODE?");
+
695  }
+
696  ret = recvFindAndFilter("OK", ":", "\r\n\r\nOK", str_mode);
+
697  if (ret) {
+
698  *mode = (uint8_t)str_mode.toInt();
+
699  return true;
+
700  } else {
+
701  return false;
702  }
-
703  return false;
-
704 }
-
705 bool ESP8266::sATCIPSERVER(uint8_t mode, uint32_t port)
-
706 {
-
707  String data;
-
708  if (mode) {
-
709  rx_empty();
-
710  m_puart->print("AT+CIPSERVER=1,");
-
711  m_puart->println(port);
-
712 
-
713  data = recvString("OK", "no change");
-
714  if (data.indexOf("OK") != -1 || data.indexOf("no change") != -1) {
-
715  return true;
-
716  }
-
717  return false;
-
718  } else {
-
719  rx_empty();
-
720  m_puart->println("AT+CIPSERVER=0");
-
721  return recvFind("\r\r\n");
-
722  }
-
723 }
-
724 bool ESP8266::sATCIPSTO(uint32_t timeout)
-
725 {
-
726  rx_empty();
-
727  m_puart->print("AT+CIPSTO=");
-
728  m_puart->println(timeout);
-
729  return recvFind("OK");
-
730 }
+
703 }
+
704 bool ESP8266::eATCWMODE(String &list)
+
705 {
+
706  rx_empty();
+
707  m_puart->println("AT+CWMODE=?");
+
708  return recvFindAndFilter("OK", "+CWMODE:(", ")\r\n\r\nOK", list);
+
709 }
+
710 
+
711 bool ESP8266::sATCWMODE(uint8_t mode,uint8_t pattern)
+
712 {
+
713  if(!pattern){
+
714  return false;
+
715  }
+
716  String data;
+
717  rx_empty();
+
718  switch(pattern)
+
719  {
+
720  case 1 :
+
721  m_puart->print("AT+CWMODE_DEF=");
+
722  break;
+
723  case 2:
+
724  m_puart->print("AT+CWMODE_CUR=");
+
725  break;
+
726  default:
+
727  m_puart->print("AT+CWMODE=");
+
728  }
+
729  m_puart->println(mode);
+
730  data = recvString("OK", "no change");
731 
-
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:261
+
732  if (data.indexOf("OK") != -1 || data.indexOf("no change") != -1) {
+
733  return true;
+
734  }
+
735  return false;
+
736 }
+
737 
+
738 
+
739 bool ESP8266::qATCWJAP(String &ssid,uint8_t pattern)
+
740 {
+
741 
+
742  bool ret;
+
743  if (!pattern) {
+
744  return false;
+
745  }
+
746  rx_empty();
+
747  switch(pattern)
+
748  {
+
749  case 1 :
+
750  m_puart->println("AT+CWJAP_DEF?");
+
751  break;
+
752  case 2:
+
753  m_puart->println("AT+CWJAP_CUR?");
+
754  break;
+
755  default:
+
756  m_puart->println("AT+CWJAP?");
+
757  }
+
758  ssid = recvString("OK", "No AP");
+
759  if (ssid.indexOf("OK") != -1 || ssid.indexOf("No AP") != -1) {
+
760  return true;
+
761  }
+
762  return false;
+
763 
+
764 }
+
765 
+
766 bool ESP8266::sATCWJAP(String ssid, String pwd,uint8_t pattern)
+
767 {
+
768  String data;
+
769  if (!pattern) {
+
770  return false;
+
771  }
+
772  rx_empty();
+
773  switch(pattern)
+
774  {
+
775  case 1 :
+
776  m_puart->print("AT+CWJAP_DEF=\"");
+
777 
+
778  break;
+
779  case 2:
+
780  m_puart->print("AT+CWJAP_CUR=\"");
+
781  break;
+
782  default:
+
783  m_puart->print("AT+CWJAP=\"");
+
784  }
+
785 
+
786  m_puart->print(ssid);
+
787  m_puart->print("\",\"");
+
788  m_puart->print(pwd);
+
789  m_puart->println("\"");
+
790 
+
791  data = recvString("OK", "FAIL", 10000);
+
792  if (data.indexOf("OK") != -1) {
+
793  return true;
+
794  }
+
795  return false;
+
796 }
+
797 
+
798 bool ESP8266::eATCWLAP(String &list)
+
799 {
+
800  String data;
+
801  rx_empty();
+
802  m_puart->println("AT+CWLAP");
+
803  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list, 15000);
+
804 }
+
805 
+
806 
+
807 
+
808 
+
809 bool ESP8266::eATCWQAP(void)
+
810 {
+
811  String data;
+
812  rx_empty();
+
813  m_puart->println("AT+CWQAP");
+
814  return recvFind("OK");
+
815 }
+
816 
+
817 
+
818 bool ESP8266::qATCWSAP(String &List,uint8_t pattern)
+
819 {
+
820  if (!pattern) {
+
821  return false;
+
822  }
+
823  rx_empty();
+
824  switch(pattern)
+
825  {
+
826  case 1 :
+
827  m_puart->println("AT+CWSAP_DEF?");
+
828 
+
829  break;
+
830  case 2:
+
831  m_puart->println("AT+CWSAP_CUR?");
+
832  break;
+
833  default:
+
834  m_puart->println("AT+CWSAP?");
+
835  }
+
836  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", List,10000);
+
837 
+
838 }
+
839 
+
840 bool ESP8266::sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern)
+
841 {
+
842  String data;
+
843  if (!pattern) {
+
844  return false;
+
845  }
+
846  rx_empty();
+
847  switch(pattern){
+
848  case 1 :
+
849  m_puart->print("AT+CWSAP_DEF=\"");
+
850 
+
851  break;
+
852  case 2:
+
853  m_puart->print("AT+CWSAP_CUR=\"");
+
854  break;
+
855  default:
+
856  m_puart->print("AT+CWSAP=\"");
+
857 
+
858  }
+
859  m_puart->print(ssid);
+
860  m_puart->print("\",\"");
+
861  m_puart->print(pwd);
+
862  m_puart->print("\",");
+
863  m_puart->print(chl);
+
864  m_puart->print(",");
+
865  m_puart->println(ecn);
+
866 
+
867  data = recvString("OK", "ERROR", 5000);
+
868  if (data.indexOf("OK") != -1) {
+
869  return true;
+
870  }
+
871  return false;
+
872 }
+
873 
+
874 bool ESP8266::eATCWLIF(String &list)
+
875 {
+
876  String data;
+
877  rx_empty();
+
878  m_puart->println("AT+CWLIF");
+
879  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
+
880 }
+
881 
+
882 bool ESP8266::qATCWDHCP(String &List,uint8_t pattern)
+
883 {
+
884  if (!pattern) {
+
885  return false;
+
886  }
+
887  rx_empty();
+
888  switch(pattern)
+
889  {
+
890  case 1 :
+
891  m_puart->println("AT+CWDHCP_DEF?");
+
892  break;
+
893  case 2:
+
894  m_puart->println("AT+CWDHCP_CUR?");
+
895  break;
+
896  default:
+
897  m_puart->println("AT+CWDHCP?");
+
898  }
+
899 
+
900  return recvFindAndFilter("OK", "\r\r\n", "\r\nOK", List,10000);
+
901 
+
902 }
+
903 
+
904 
+
905 bool ESP8266::sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern)
+
906 {
+
907  String data;
+
908  if (!pattern) {
+
909  return false;
+
910  }
+
911  rx_empty();
+
912  switch(pattern){
+
913  case 1 :
+
914  m_puart->print("AT+CWDHCP_DEF=");
+
915 
+
916  break;
+
917  case 2:
+
918  m_puart->print("AT+CWDHCP_CUR=");
+
919  break;
+
920  default:
+
921  m_puart->print("AT+CWDHCP=");
+
922 
+
923  }
+
924  m_puart->print(mode);
+
925  m_puart->print(",");
+
926  m_puart->println(en);
+
927  data = recvString("OK", "ERROR", 2000);
+
928 
+
929  if (data.indexOf("OK") != -1) {
+
930  return true;
+
931  }
+
932  return false;
+
933 }
+
934 
+
935 
+
936 bool ESP8266::eATCWAUTOCONN(uint8_t en)
+
937 {
+
938 
+
939  rx_empty();
+
940  if(en>1||en<0){
+
941  return false;
+
942  }
+
943  m_puart->print("AT+CWAUTOCONN=");
+
944  m_puart->println(en);
+
945  return recvFind("OK");
+
946 
+
947 }
+
948 
+
949 bool ESP8266::qATCIPSTAMAC(String &mac,uint8_t pattern)
+
950 {
+
951 
+
952  rx_empty();
+
953  if (!pattern) {
+
954  return false;
+
955  }
+
956  switch(pattern){
+
957  case 1 :
+
958  m_puart->println("AT+CIPSTAMAC_DEF?");
+
959 
+
960  break;
+
961  case 2:
+
962  m_puart->println("AT+CIPSTAMAC_CUR?");
+
963  break;
+
964  default:
+
965  m_puart->println("AT+CIPSTAMAC?");
+
966 
+
967  }
+
968  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", mac,2000);
+
969 
+
970 }
+
971 
+
972 
+
973 
+
974 bool ESP8266::eATCIPSTAMAC(String mac,uint8_t pattern)
+
975 {
+
976 
+
977  rx_empty();
+
978  if (!pattern) {
+
979  return false;
+
980  }
+
981  switch(pattern){
+
982  case 1 :
+
983  m_puart->print("AT+CIPSTAMAC_DEF=");
+
984 
+
985  break;
+
986  case 2:
+
987  m_puart->print("AT+CIPSTAMAC_CUR=");
+
988  break;
+
989  default:
+
990  m_puart->print("AT+CIPSTAMAC=");
+
991 
+
992  }
+
993  m_puart->print("\"");
+
994  m_puart->print(mac);
+
995  m_puart->println("\"");
+
996  return recvFind("OK");
+
997 
+
998 }
+
999 
+
1000 bool ESP8266::qATCIPSTAIP(String &ip,uint8_t pattern)
+
1001 {
+
1002 
+
1003  rx_empty();
+
1004  if (!pattern) {
+
1005  return false;
+
1006  }
+
1007  switch(pattern){
+
1008  case 1 :
+
1009  m_puart->println("AT+CIPSTA_DEF?");
+
1010 
+
1011  break;
+
1012  case 2:
+
1013  m_puart->println("AT+CIPSTA_CUR?");
+
1014  break;
+
1015  default:
+
1016  m_puart->println("AT+CIPSTA?");
+
1017 
+
1018  }
+
1019  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", ip,2000);
+
1020 
+
1021 }
+
1022 
+
1023 bool ESP8266::eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern)
+
1024 {
+
1025 
+
1026  rx_empty();
+
1027  if (!pattern) {
+
1028  return false;
+
1029  }
+
1030  switch(pattern){
+
1031  case 1 :
+
1032  m_puart->print("AT+CIPSTA_DEF=");
+
1033 
+
1034  break;
+
1035  case 2:
+
1036  m_puart->print("AT+CIPSTA_CUR=");
+
1037  break;
+
1038  default:
+
1039  m_puart->print("AT+CIPSTA=");
+
1040 
+
1041  }
+
1042  m_puart->print("\"");
+
1043  m_puart->print(ip);
+
1044  m_puart->print("\",\"");
+
1045  m_puart->print(gateway);
+
1046  m_puart->print("\",\"");
+
1047  m_puart->print(netmask);
+
1048  m_puart->println("\"");
+
1049  return recvFind("OK");
+
1050 
+
1051 }
+
1052 
+
1053 
+
1054 bool ESP8266::qATCIPAP(String &ip,uint8_t pattern)
+
1055 {
+
1056 
+
1057  rx_empty();
+
1058  if (!pattern) {
+
1059  return false;
+
1060  }
+
1061  switch(pattern){
+
1062  case 1 :
+
1063  m_puart->println("AT+CIPAP_DEF?");
+
1064 
+
1065  break;
+
1066  case 2:
+
1067  m_puart->println("AT+CIPAP_CUR?");
+
1068  break;
+
1069  default:
+
1070  m_puart->println("AT+CIPAP?");
+
1071 
+
1072  }
+
1073  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", ip,2000);
+
1074 
+
1075 }
+
1076 
+
1077 
+
1078 bool ESP8266::eATCIPAP(String ip,uint8_t pattern)
+
1079 {
+
1080 
+
1081  rx_empty();
+
1082  if (!pattern) {
+
1083  return false;
+
1084  }
+
1085  switch(pattern){
+
1086  case 1 :
+
1087  m_puart->print("AT+CIPAP_DEF=");
+
1088 
+
1089  break;
+
1090  case 2:
+
1091  m_puart->print("AT+CIPAP_CUR=");
+
1092  break;
+
1093  default:
+
1094  m_puart->print("AT+CIPAP=");
+
1095 
+
1096  }
+
1097  m_puart->print("\"");
+
1098  m_puart->print(ip);
+
1099  m_puart->println("\"");
+
1100  return recvFind("OK");
+
1101 
+
1102 }
+
1103 
+
1104 
+
1105 bool ESP8266::eCWSTARTSMART(uint8_t type)
+
1106 {
+
1107  rx_empty();
+
1108  m_puart->print("AT+CWSTARTSMART=");
+
1109  m_puart->println(type);
+
1110  return recvFind("OK");
+
1111 }
+
1112 
+
1113 bool ESP8266::eCWSTOPSMART(void)
+
1114 {
+
1115  rx_empty();
+
1116  m_puart->println("AT+CWSTOPSMART");
+
1117  return recvFind("OK");
+
1118 }
+
1119 
+
1120 bool ESP8266::eATCIPSTATUS(String &list)
+
1121 {
+
1122  String data;
+
1123  delay(100);
+
1124  rx_empty();
+
1125  m_puart->println("AT+CIPSTATUS");
+
1126  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
+
1127 }
+
1128 bool ESP8266::sATCIPSTARTSingle(String type, String addr, uint32_t port)
+
1129 {
+
1130  String data;
+
1131  rx_empty();
+
1132  m_puart->print("AT+CIPSTART=\"");
+
1133  m_puart->print(type);
+
1134  m_puart->print("\",\"");
+
1135  m_puart->print(addr);
+
1136  m_puart->print("\",");
+
1137  m_puart->println(port);
+
1138 
+
1139  data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000);
+
1140  if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) {
+
1141  return true;
+
1142  }
+
1143  return false;
+
1144 }
+
1145 bool ESP8266::sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port)
+
1146 {
+
1147  String data;
+
1148  rx_empty();
+
1149  m_puart->print("AT+CIPSTART=");
+
1150  m_puart->print(mux_id);
+
1151  m_puart->print(",\"");
+
1152  m_puart->print(type);
+
1153  m_puart->print("\",\"");
+
1154  m_puart->print(addr);
+
1155  m_puart->print("\",");
+
1156  m_puart->println(port);
+
1157 
+
1158  data = recvString("OK", "ERROR", "ALREADY CONNECT", 10000);
+
1159  if (data.indexOf("OK") != -1 || data.indexOf("ALREADY CONNECT") != -1) {
+
1160  return true;
+
1161  }
+
1162  return false;
+
1163 }
+
1164 bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len)
+
1165 {
+
1166  rx_empty();
+
1167  m_puart->print("AT+CIPSEND=");
+
1168  m_puart->println(len);
+
1169  if (recvFind(">", 5000)) {
+
1170  rx_empty();
+
1171  for (uint32_t i = 0; i < len; i++) {
+
1172  m_puart->write(buffer[i]);
+
1173  }
+
1174  return recvFind("SEND OK", 10000);
+
1175  }
+
1176  return false;
+
1177 }
+
1178 bool ESP8266::sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len)
+
1179 {
+
1180  rx_empty();
+
1181  m_puart->print("AT+CIPSEND=");
+
1182  m_puart->print(mux_id);
+
1183  m_puart->print(",");
+
1184  m_puart->println(len);
+
1185  if (recvFind(">", 5000)) {
+
1186  rx_empty();
+
1187  for (uint32_t i = 0; i < len; i++) {
+
1188  m_puart->write(buffer[i]);
+
1189  }
+
1190  return recvFind("SEND OK", 10000);
+
1191  }
+
1192  return false;
+
1193 }
+
1194 bool ESP8266::sATCIPCLOSEMulitple(uint8_t mux_id)
+
1195 {
+
1196  String data;
+
1197  rx_empty();
+
1198  m_puart->print("AT+CIPCLOSE=");
+
1199  m_puart->println(mux_id);
+
1200 
+
1201  data = recvString("OK", "link is not", 5000);
+
1202  if (data.indexOf("OK") != -1 || data.indexOf("link is not") != -1) {
+
1203  return true;
+
1204  }
+
1205  return false;
+
1206 }
+
1207 bool ESP8266::eATCIPCLOSESingle(void)
+
1208 {
+
1209  rx_empty();
+
1210  m_puart->println("AT+CIPCLOSE");
+
1211  return recvFind("OK", 5000);
+
1212 }
+
1213 bool ESP8266::eATCIFSR(String &list)
+
1214 {
+
1215  rx_empty();
+
1216  m_puart->println("AT+CIFSR");
+
1217  return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
+
1218 }
+
1219 bool ESP8266::sATCIPMUX(uint8_t mode)
+
1220 {
+
1221  String data;
+
1222  rx_empty();
+
1223  m_puart->print("AT+CIPMUX=");
+
1224  m_puart->println(mode);
+
1225 
+
1226  data = recvString("OK", "Link is builded");
+
1227  if (data.indexOf("OK") != -1) {
+
1228  return true;
+
1229  }
+
1230  return false;
+
1231 }
+
1232 bool ESP8266::sATCIPSERVER(uint8_t mode, uint32_t port)
+
1233 {
+
1234  String data;
+
1235  if (mode) {
+
1236  rx_empty();
+
1237  m_puart->print("AT+CIPSERVER=1,");
+
1238  m_puart->println(port);
+
1239 
+
1240  data = recvString("OK", "no change");
+
1241  if (data.indexOf("OK") != -1 || data.indexOf("no change") != -1) {
+
1242  return true;
+
1243  }
+
1244  return false;
+
1245  } else {
+
1246  rx_empty();
+
1247  m_puart->println("AT+CIPSERVER=0");
+
1248  return recvFind("\r\r\n");
+
1249  }
+
1250 }
+
1251 
+
1252 
+
1253 bool ESP8266::sATCIPMODE(uint8_t mode)
+
1254 {
+
1255  String data;
+
1256  if(mode>1||mode<0){
+
1257  return false;
+
1258  }
+
1259  rx_empty();
+
1260  m_puart->print("AT+CIPMODE=");
+
1261  m_puart->println(mode);
+
1262 
+
1263  data = recvString("OK", "Link is builded",2000);
+
1264  if (data.indexOf("OK") != -1 ) {
+
1265  return true;
+
1266  }
+
1267  return false;
+
1268 }
+
1269 
+
1270 
+
1271 
+
1272 
+
1273 bool ESP8266::eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port)
+
1274 {
+
1275 
+
1276  String data;
+
1277  rx_empty();
+
1278  m_puart->print("AT+SAVETRANSLINK=");
+
1279  m_puart->print(mode);
+
1280  m_puart->print(",\"");
+
1281  m_puart->print(ip);
+
1282  m_puart->print("\",");
+
1283  m_puart->println(port);
+
1284  data = recvString("OK", "ERROR",2000);
+
1285  if (data.indexOf("OK") != -1 ) {
+
1286  return true;
+
1287  }
+
1288  return false;
+
1289 }
+
1290 
+
1291 
+
1292 
+
1293 bool ESP8266::eATPING(String ip)
+
1294 {
+
1295  rx_empty();
+
1296  m_puart->print("AT+PING=");
+
1297  m_puart->print("\"");
+
1298  m_puart->print(ip);
+
1299  m_puart->println("\"");
+
1300  return recvFind("OK",2000);
+
1301 }
+
1302 
+
1303 
+
1304 
+
1305 bool ESP8266::sATCIPSTO(uint32_t timeout)
+
1306 {
+
1307  rx_empty();
+
1308  m_puart->print("AT+CIPSTO=");
+
1309  m_puart->println(timeout);
+
1310  return recvFind("OK");
+
1311 }
+
1312 
+
bool setAutoConnect(uint8_t en)
make boot automatically connected.
Definition: ESP8266.cpp:220
+
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:386
+
String getStationIp(uint8_t pattern=3)
Get the station's IP.
Definition: ESP8266.cpp:237
+
bool setPing(String ip)
PING COMMAND.
Definition: ESP8266.cpp:368
+
bool joinAP(String ssid, String pwd, uint8_t pattern=3)
Join in AP.
Definition: ESP8266.cpp:178
String getVersion(void)
Get the version of AT Command Set.
Definition: ESP8266.cpp:80
-
bool releaseTCP(void)
Release TCP connection in single mode.
Definition: ESP8266.cpp:196
-
uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000)
Receive data from TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:271
-
bool enableMUX(void)
Enable IP MUX(multiple connection mode).
Definition: ESP8266.cpp:181
-
String getLocalIP(void)
Get the IP address of ESP8266.
Definition: ESP8266.cpp:174
-
bool setOprToSoftAP(void)
Set operation mode to softap.
Definition: ESP8266.cpp:104
+
bool releaseTCP(void)
Release TCP connection in single mode.
Definition: ESP8266.cpp:303
+
uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000)
Receive data from TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:396
+
bool setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4, uint8_t pattern=3)
Set SoftAP parameters.
Definition: ESP8266.cpp:197
+
String getDHCP(uint8_t pattern=3)
Get the current state of DHCP.
Definition: ESP8266.cpp:209
+
bool setOprToSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to softap.
Definition: ESP8266.cpp:129
+
bool setStationMac(String mac, uint8_t pattern=3)
Set the station's MAC address.
Definition: ESP8266.cpp:232
+
String getNowConecAp(uint8_t pattern=3)
Search and returns the current connect AP.
Definition: ESP8266.cpp:163
+
bool setStationIp(String ip, String gateway, String netmask, uint8_t pattern=3)
Set the station's IP.
Definition: ESP8266.cpp:244
+
bool enableMUX(void)
Enable IP MUX(multiple connection mode).
Definition: ESP8266.cpp:288
+
bool setUart(uint32_t baudrate, uint8_t pattern)
Set up a serial port configuration.
Definition: ESP8266.cpp:96
+
String getWifiModeList(void)
Get the model values list.
Definition: ESP8266.cpp:123
+
bool setAPIp(String ip, uint8_t pattern=3)
Set the AP IP.
Definition: ESP8266.cpp:256
+
String getLocalIP(void)
Get the IP address of ESP8266.
Definition: ESP8266.cpp:281
+
bool deepSleep(uint32_t time)
Start function of deep sleep.
Definition: ESP8266.cpp:101
The definition of class ESP8266.
-
bool setOprToStationSoftAP(void)
Set operation mode to station + softap.
Definition: ESP8266.cpp:121
-
bool createTCP(String addr, uint32_t port)
Create TCP connection in single mode.
Definition: ESP8266.cpp:191
-
bool unregisterUDP(void)
Unregister UDP port number in single mode.
Definition: ESP8266.cpp:206
-
bool startServer(uint32_t port=333)
Start Server(Only in multiple mode).
Definition: ESP8266.cpp:251
-
bool stopTCPServer(void)
Stop TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:244
-
bool stopServer(void)
Stop Server(Only in multiple mode).
Definition: ESP8266.cpp:256
-
bool disableMUX(void)
Disable IP MUX(single connection mode).
Definition: ESP8266.cpp:186
+
String getSoftAPParam(uint8_t pattern=3)
get SoftAP parameters.
Definition: ESP8266.cpp:188
+
bool createTCP(String addr, uint32_t port)
Create TCP connection in single mode.
Definition: ESP8266.cpp:298
+
bool unregisterUDP(void)
Unregister UDP port number in single mode.
Definition: ESP8266.cpp:313
+
bool startServer(uint32_t port=333)
Start Server(Only in multiple mode).
Definition: ESP8266.cpp:376
+
bool saveTransLink(uint8_t mode, String ip, uint32_t port)
Save the passthrough links.
Definition: ESP8266.cpp:363
+
bool stopTCPServer(void)
Stop TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:351
+
bool setEcho(uint8_t mode)
Switch the echo function.
Definition: ESP8266.cpp:87
+
bool startSmartConfig(uint8_t type)
start smartconfig.
Definition: ESP8266.cpp:261
+
bool stopServer(void)
Stop Server(Only in multiple mode).
Definition: ESP8266.cpp:381
+
bool disableMUX(void)
Disable IP MUX(single connection mode).
Definition: ESP8266.cpp:293
+
bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3)
Set the state of DHCP.
Definition: ESP8266.cpp:215
bool restart(void)
Restart ESP8266 by "AT+RST".
Definition: ESP8266.cpp:63
bool kick(void)
Verify ESP8266 whether live or not.
Definition: ESP8266.cpp:58
-
bool joinAP(String ssid, String pwd)
Join in AP.
Definition: ESP8266.cpp:145
-
bool registerUDP(String addr, uint32_t port)
Register UDP port number in single mode.
Definition: ESP8266.cpp:201
-
bool leaveAP(void)
Leave AP joined before.
Definition: ESP8266.cpp:150
-
bool setTCPServerTimeout(uint32_t timeout=180)
Set the timeout of TCP Server.
Definition: ESP8266.cpp:231
-
bool startTCPServer(uint32_t port=333)
Start TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:236
-
bool setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4)
Set SoftAP parameters.
Definition: ESP8266.cpp:155
-
bool setOprToStation(void)
Set operation mode to staion.
Definition: ESP8266.cpp:87
-
String getAPList(void)
Search available AP list and return it.
Definition: ESP8266.cpp:138
-
String getIPStatus(void)
Get the current status of connection(UDP and TCP).
Definition: ESP8266.cpp:167
-
String getJoinedDeviceIP(void)
Get the IP list of devices connected to SoftAP.
Definition: ESP8266.cpp:160
+
bool setCIPMODE(uint8_t mode)
Set the module transfer mode.
Definition: ESP8266.cpp:358
+
bool registerUDP(String addr, uint32_t port)
Register UDP port number in single mode.
Definition: ESP8266.cpp:308
+
bool restore(void)
Restore factory.
Definition: ESP8266.cpp:92
+
bool setOprToStationSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station + softap.
Definition: ESP8266.cpp:146
+
bool leaveAP(void)
Leave AP joined before.
Definition: ESP8266.cpp:183
+
bool setTCPServerTimeout(uint32_t timeout=180)
Set the timeout of TCP Server.
Definition: ESP8266.cpp:338
+
String getAPIp(uint8_t pattern=3)
Get the AP's IP.
Definition: ESP8266.cpp:249
+
bool stopSmartConfig(void)
stop smartconfig.
Definition: ESP8266.cpp:266
+
bool startTCPServer(uint32_t port=333)
Start TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:343
+
String getAPList(void)
Search available AP list and return it.
Definition: ESP8266.cpp:171
+
String getStationMac(uint8_t pattern=3)
Get the station's MAC address.
Definition: ESP8266.cpp:224
+
String getIPStatus(void)
Get the current status of connection(UDP and TCP).
Definition: ESP8266.cpp:274
+
bool setOprToStation(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station.
Definition: ESP8266.cpp:107
+
String getJoinedDeviceIP(void)
Get the IP list of devices connected to SoftAP.
Definition: ESP8266.cpp:202
diff --git a/doc/API-html/_e_s_p8266_8h.html b/doc/API-html/_e_s_p8266_8h.html index 56375e9..009719a 100644 --- a/doc/API-html/_e_s_p8266_8h.html +++ b/doc/API-html/_e_s_p8266_8h.html @@ -40,12 +40,14 @@
+Classes | +Macros
ESP8266.h File Reference
@@ -62,6 +64,13 @@ class  ESP8266  Provide an easy-to-use way to manipulate ESP8266. More...
  + + + + +

+Macros

+#define USER_SEL_VERSION   VERSION_18
 You can modify the macro to choose a different version.
 

Detailed Description

The definition of class ESP8266.

@@ -77,7 +86,7 @@
diff --git a/doc/API-html/_e_s_p8266_8h_source.html b/doc/API-html/_e_s_p8266_8h_source.html index 1103d6e..2eff255 100644 --- a/doc/API-html/_e_s_p8266_8h_source.html +++ b/doc/API-html/_e_s_p8266_8h_source.html @@ -40,6 +40,7 @@ @@ -54,223 +55,316 @@
23 
24 #include "Arduino.h"
25 
-
26 
-
27 //#define ESP8266_USE_SOFTWARE_SERIAL
-
28 
+
26 #ifdef ESP8266_USE_SOFTWARE_SERIAL
+
27 #include "SoftwareSerial.h"
+
28 #endif
29 
-
30 #ifdef ESP8266_USE_SOFTWARE_SERIAL
-
31 #include "SoftwareSerial.h"
-
32 #endif
-
33 
-
34 
-
38 class ESP8266 {
-
39  public:
-
40 
-
41 #ifdef ESP8266_USE_SOFTWARE_SERIAL
-
42  /*
-
43  * Constuctor.
-
44  *
-
45  * @param uart - an reference of SoftwareSerial object.
-
46  * @param baud - the buad rate to communicate with ESP8266(default:9600).
-
47  *
-
48  * @warning parameter baud depends on the AT firmware. 9600 is an common value.
-
49  */
-
50  ESP8266(SoftwareSerial &uart, uint32_t baud = 9600);
-
51 #else /* HardwareSerial */
-
52  /*
-
53  * Constuctor.
-
54  *
-
55  * @param uart - an reference of HardwareSerial object.
-
56  * @param baud - the buad rate to communicate with ESP8266(default:9600).
-
57  *
-
58  * @warning parameter baud depends on the AT firmware. 9600 is an common value.
-
59  */
-
60  ESP8266(HardwareSerial &uart, uint32_t baud = 9600);
-
61 #endif
-
62 
-
63 
-
72  bool kick(void);
-
73 
-
82  bool restart(void);
-
83 
-
89  String getVersion(void);
-
90 
-
97  bool setOprToStation(void);
+
30 #define VERSION_18 0X18
+
31 #define VERSION_22 0X22
+
32 
+
37 #define USER_SEL_VERSION VERSION_18
+
38 
+
42 class ESP8266 {
+
43  public:
+
44 
+
45 #ifdef ESP8266_USE_SOFTWARE_SERIAL
+
46  /*
+
47  * Constuctor.
+
48  *
+
49  * @param uart - an reference of SoftwareSerial object.
+
50  * @param baud - the buad rate to communicate with ESP8266(default:9600).
+
51  *
+
52  * @warning parameter baud depends on the AT firmware. 9600 is an common value.
+
53  */
+
54 #if (USER_SEL_VERSION == VERSION_22)
+
55  ESP8266(SoftwareSerial &uart, uint32_t baud = 115200);
+
56 #elif (USER_SEL_VERSION == VERSION_18)
+
57  ESP8266(SoftwareSerial &uart, uint32_t baud = 9600);
+
58 #endif /* #if(USER_SEL_VERSION==VERSION_22) */
+
59 
+
60 #else /* HardwareSerial */
+
61  /*
+
62  * Constuctor.
+
63  *
+
64  * @param uart - an reference of HardwareSerial object.
+
65  * @param baud - the buad rate to communicate with ESP8266(default:9600).
+
66  *
+
67  * @warning parameter baud depends on the AT firmware. 9600 is an common value.
+
68  */
+
69 #if (USER_SEL_VERSION == VERSION_22)
+
70  ESP8266(HardwareSerial &uart, uint32_t baud = 115200);
+
71 #elif (USER_SEL_VERSION == VERSION_18)
+
72  ESP8266(HardwareSerial &uart, uint32_t baud = 9600);
+
73 #endif /* #if(USER_SEL_VERSION == VERSION_22) */
+
74 
+
75 
+
76 #endif /* #ifdef ESP8266_USE_SOFTWARE_SERIAL */
+
77 
+
78 
+
87  bool kick(void);
+
88 
+
97  bool restart(void);
98 
-
105  bool setOprToSoftAP(void);
-
106 
-
113  bool setOprToStationSoftAP(void);
-
114 
-
122  String getAPList(void);
-
123 
-
133  bool joinAP(String ssid, String pwd);
-
134 
-
141  bool leaveAP(void);
-
142 
-
153  bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4);
-
154 
-
161  String getJoinedDeviceIP(void);
+
104  String getVersion(void);
+
105 
+
114  bool deepSleep(uint32_t time);
+
115 
+
124  bool setEcho(uint8_t mode);
+
125 
+
132  bool restore(void);
+
133 
+
143  bool setUart(uint32_t baudrate,uint8_t pattern);
+
144 
+
154  bool setOprToStation(uint8_t pattern1=3,uint8_t pattern2=3);
+
155 
+
161  String getWifiModeList(void);
162 
-
168  String getIPStatus(void);
-
169 
-
175  String getLocalIP(void);
-
176 
-
186  bool enableMUX(void);
-
187 
-
196  bool disableMUX(void);
-
197 
-
198 
-
207  bool createTCP(String addr, uint32_t port);
-
208 
-
215  bool releaseTCP(void);
-
216 
-
225  bool registerUDP(String addr, uint32_t port);
-
226 
-
233  bool unregisterUDP(void);
-
234 
-
244  bool createTCP(uint8_t mux_id, String addr, uint32_t port);
-
245 
-
253  bool releaseTCP(uint8_t mux_id);
-
254 
-
264  bool registerUDP(uint8_t mux_id, String addr, uint32_t port);
-
265 
-
273  bool unregisterUDP(uint8_t mux_id);
-
274 
-
275 
-
283  bool setTCPServerTimeout(uint32_t timeout = 180);
-
284 
-
300  bool startTCPServer(uint32_t port = 333);
-
301 
-
308  bool stopTCPServer(void);
-
309 
-
320  bool startServer(uint32_t port = 333);
-
321 
-
328  bool stopServer(void);
-
329 
-
338  bool send(const uint8_t *buffer, uint32_t len);
-
339 
-
349  bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
-
350 
-
359  uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
-
360 
-
370  uint32_t recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
-
371 
-
384  uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
-
385 
-
386  private:
-
387 
-
388  /*
-
389  * Empty the buffer or UART RX.
-
390  */
-
391  void rx_empty(void);
-
392 
-
393  /*
-
394  * Recvive data from uart. Return all received data if target found or timeout.
-
395  */
-
396  String recvString(String target, uint32_t timeout = 1000);
-
397 
-
398  /*
-
399  * Recvive data from uart. Return all received data if one of target1 and target2 found or timeout.
-
400  */
-
401  String recvString(String target1, String target2, uint32_t timeout = 1000);
+
171  bool setOprToSoftAP(uint8_t pattern1=3,uint8_t pattern2=3);
+
172 
+
181  bool setOprToStationSoftAP(uint8_t pattern1=3,uint8_t pattern2=3);
+
182 
+
190  String getAPList(void);
+
191 
+
198  String getNowConecAp(uint8_t pattern=3);
+
199 
+
210  bool joinAP(String ssid, String pwd,uint8_t pattern=3);
+
211 
+
218  bool leaveAP(void);
+
219 
+
233  bool setSoftAPParam(String ssid, String pwd, uint8_t chl = 7, uint8_t ecn = 4,uint8_t pattern=3);
+
234 
+
241  String getSoftAPParam(uint8_t pattern=3);
+
242 
+
249  String getJoinedDeviceIP(void);
+
250 
+
258  String getDHCP(uint8_t pattern=3);
+
259 
+
268  bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3);
+
269 
+
276  bool setAutoConnect(uint8_t en);
+
277 
+
284  String getStationMac(uint8_t pattern=3);
+
285 
+
293  bool setStationMac(String mac,uint8_t pattern=3);
+
294 
+
301  String getStationIp(uint8_t pattern=3);
+
302 
+
313  bool setStationIp(String ip,String gateway,String netmask,uint8_t pattern=3);
+
314 
+
322  String getAPIp(uint8_t pattern=3);
+
323 
+
332  bool setAPIp(String ip,uint8_t pattern=3);
+
333 
+
340  bool startSmartConfig(uint8_t type);
+
341 
+
348  bool stopSmartConfig(void);
+
349 
+
355  String getIPStatus(void);
+
356 
+
362  String getLocalIP(void);
+
363 
+
373  bool enableMUX(void);
+
374 
+
383  bool disableMUX(void);
+
384 
+
393  bool createTCP(String addr, uint32_t port);
+
394 
+
401  bool releaseTCP(void);
402 
-
403  /*
-
404  * Recvive data from uart. Return all received data if one of target1, target2 and target3 found or timeout.
-
405  */
-
406  String recvString(String target1, String target2, String target3, uint32_t timeout = 1000);
-
407 
-
408  /*
-
409  * Recvive data from uart and search first target. Return true if target found, false for timeout.
-
410  */
-
411  bool recvFind(String target, uint32_t timeout = 1000);
+
411  bool registerUDP(String addr, uint32_t port);
412 
-
413  /*
-
414  * Recvive data from uart and search first target and cut out the substring between begin and end(excluding begin and end self).
-
415  * Return true if target found, false for timeout.
-
416  */
-
417  bool recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout = 1000);
-
418 
-
419  /*
-
420  * Receive a package from uart.
-
421  *
-
422  * @param buffer - the buffer storing data.
-
423  * @param buffer_size - guess what!
-
424  * @param data_len - the length of data actually received(maybe more than buffer_size, the remained data will be abandoned).
-
425  * @param timeout - the duration waitting data comming.
-
426  * @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple.
-
427  */
-
428  uint32_t recvPkg(uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id);
-
429 
-
430 
-
431  bool eAT(void);
-
432  bool eATRST(void);
-
433  bool eATGMR(String &version);
-
434 
-
435  bool qATCWMODE(uint8_t *mode);
-
436  bool sATCWMODE(uint8_t mode);
-
437  bool sATCWJAP(String ssid, String pwd);
-
438  bool eATCWLAP(String &list);
-
439  bool eATCWQAP(void);
-
440  bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn);
-
441  bool eATCWLIF(String &list);
-
442 
-
443  bool eATCIPSTATUS(String &list);
-
444  bool sATCIPSTARTSingle(String type, String addr, uint32_t port);
-
445  bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port);
-
446  bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len);
-
447  bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
-
448  bool sATCIPCLOSEMulitple(uint8_t mux_id);
-
449  bool eATCIPCLOSESingle(void);
-
450  bool eATCIFSR(String &list);
-
451  bool sATCIPMUX(uint8_t mode);
-
452  bool sATCIPSERVER(uint8_t mode, uint32_t port = 333);
-
453  bool sATCIPSTO(uint32_t timeout);
-
454 
-
455  /*
-
456  * +IPD,len:data
-
457  * +IPD,id,len:data
-
458  */
-
459 
-
460 #ifdef ESP8266_USE_SOFTWARE_SERIAL
-
461  SoftwareSerial *m_puart; /* The UART to communicate with ESP8266 */
-
462 #else
-
463  HardwareSerial *m_puart; /* The UART to communicate with ESP8266 */
-
464 #endif
-
465 };
-
466 
-
467 #endif /* #ifndef __ESP8266_H__ */
-
468 
-
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:261
+
419  bool unregisterUDP(void);
+
420 
+
430  bool createTCP(uint8_t mux_id, String addr, uint32_t port);
+
431 
+
439  bool releaseTCP(uint8_t mux_id);
+
440 
+
450  bool registerUDP(uint8_t mux_id, String addr, uint32_t port);
+
451 
+
459  bool unregisterUDP(uint8_t mux_id);
+
460 
+
468  bool setTCPServerTimeout(uint32_t timeout = 180);
+
469 
+
485  bool startTCPServer(uint32_t port = 333);
+
486 
+
493  bool stopTCPServer(void);
+
494 
+
501  bool setCIPMODE(uint8_t mode);
+
502 
+
513  bool startServer(uint32_t port = 333);
+
514 
+
521  bool stopServer(void);
+
528  bool saveTransLink (uint8_t mode,String ip,uint32_t port);
+
529 
+
536  bool setPing(String ip);
+
537 
+
546  bool send(const uint8_t *buffer, uint32_t len);
+
547 
+
557  bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
+
558 
+
567  uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
+
568 
+
578  uint32_t recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
+
579 
+
592  uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
+
593 
+
594  private:
+
595 
+
596  /*
+
597  * Empty the buffer or UART RX.
+
598  */
+
599  void rx_empty(void);
+
600 
+
601  /*
+
602  * Recvive data from uart. Return all received data if target found or timeout.
+
603  */
+
604  String recvString(String target, uint32_t timeout = 1000);
+
605 
+
606  /*
+
607  * Recvive data from uart. Return all received data if one of target1 and target2 found or timeout.
+
608  */
+
609  String recvString(String target1, String target2, uint32_t timeout = 1000);
+
610 
+
611  /*
+
612  * Recvive data from uart. Return all received data if one of target1, target2 and target3 found or timeout.
+
613  */
+
614  String recvString(String target1, String target2, String target3, uint32_t timeout = 1000);
+
615 
+
616  /*
+
617  * Recvive data from uart and search first target. Return true if target found, false for timeout.
+
618  */
+
619  bool recvFind(String target, uint32_t timeout = 1000);
+
620 
+
621  /*
+
622  * Recvive data from uart and search first target and cut out the substring between begin and end(excluding begin and end self).
+
623  * Return true if target found, false for timeout.
+
624  */
+
625  bool recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout = 1000);
+
626 
+
627  /*
+
628  * Receive a package from uart.
+
629  *
+
630  * @param buffer - the buffer storing data.
+
631  * @param buffer_size - guess what!
+
632  * @param data_len - the length of data actually received(maybe more than buffer_size, the remained data will be abandoned).
+
633  * @param timeout - the duration waitting data comming.
+
634  * @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple.
+
635  */
+
636  uint32_t recvPkg(uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id);
+
637 
+
638 
+
639  bool eAT(void);
+
640  bool eATRST(void);
+
641  bool eATGMR(String &version);
+
642  bool eATGSLP(uint32_t time);
+
643  bool eATE(uint8_t mode);
+
644  bool eATRESTORE(void);
+
645  bool eATSETUART(uint32_t baudrate,uint8_t pattern);
+
646 
+
647  bool qATCWMODE(uint8_t *mode,uint8_t pattern=3);
+
648  bool eATCWMODE(String &list) ;
+
649  bool sATCWMODE(uint8_t mode,uint8_t pattern=3);
+
650  bool qATCWJAP(String &ssid,uint8_t pattern=3) ;
+
651  bool sATCWJAP(String ssid, String pwd,uint8_t pattern=3);
+
652  bool eATCWLAP(String &list);
+
653  bool eATCWQAP(void);
+
654  bool qATCWSAP(String &List,uint8_t pattern=3);
+
655  bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn,uint8_t pattern=3);
+
656  bool eATCWLIF(String &list);
+
657  bool qATCWDHCP(String &List,uint8_t pattern=3);
+
658  bool sATCWDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3);
+
659  bool eATCWAUTOCONN(uint8_t en);
+
660  bool qATCIPSTAMAC(String &mac,uint8_t pattern=3);
+
661  bool eATCIPSTAMAC(String mac,uint8_t pattern=3);
+
662  bool qATCIPSTAIP(String &ip,uint8_t pattern=3);
+
663  bool eATCIPSTAIP(String ip,String gateway,String netmask,uint8_t pattern=3);
+
664  bool qATCIPAP(String &ip,uint8_t pattern=3);
+
665  bool eATCIPAP(String ip,uint8_t pattern=3);
+
666  bool eCWSTARTSMART(uint8_t type);
+
667  bool eCWSTOPSMART(void);
+
668 
+
669 
+
670  bool eATCIPSTATUS(String &list);
+
671  bool sATCIPSTARTSingle(String type, String addr, uint32_t port);
+
672  bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port);
+
673  bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len);
+
674  bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
+
675  bool sATCIPCLOSEMulitple(uint8_t mux_id);
+
676  bool eATCIPCLOSESingle(void);
+
677  bool eATCIFSR(String &list);
+
678  bool sATCIPMUX(uint8_t mode);
+
679  bool sATCIPSERVER(uint8_t mode, uint32_t port = 333);
+
680  bool sATCIPMODE(uint8_t mode);
+
681  bool eATSAVETRANSLINK(uint8_t mode,String ip,uint32_t port);
+
682  bool eATPING(String ip);
+
683  bool sATCIPSTO(uint32_t timeout);
+
684 
+
685  /*
+
686  * +IPD,len:data
+
687  * +IPD,id,len:data
+
688  */
+
689 
+
690 #ifdef ESP8266_USE_SOFTWARE_SERIAL
+
691  SoftwareSerial *m_puart; /* The UART to communicate with ESP8266 */
+
692 #else
+
693  HardwareSerial *m_puart; /* The UART to communicate with ESP8266 */
+
694 #endif
+
695 };
+
696 
+
697 #endif /* #ifndef __ESP8266_H__ */
+
698 
+
bool setAutoConnect(uint8_t en)
make boot automatically connected.
Definition: ESP8266.cpp:220
+
bool send(const uint8_t *buffer, uint32_t len)
Send data based on TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:386
+
String getStationIp(uint8_t pattern=3)
Get the station's IP.
Definition: ESP8266.cpp:237
+
bool setPing(String ip)
PING COMMAND.
Definition: ESP8266.cpp:368
+
bool joinAP(String ssid, String pwd, uint8_t pattern=3)
Join in AP.
Definition: ESP8266.cpp:178
String getVersion(void)
Get the version of AT Command Set.
Definition: ESP8266.cpp:80
-
bool releaseTCP(void)
Release TCP connection in single mode.
Definition: ESP8266.cpp:196
-
uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000)
Receive data from TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:271
-
bool enableMUX(void)
Enable IP MUX(multiple connection mode).
Definition: ESP8266.cpp:181
-
String getLocalIP(void)
Get the IP address of ESP8266.
Definition: ESP8266.cpp:174
-
bool setOprToSoftAP(void)
Set operation mode to softap.
Definition: ESP8266.cpp:104
-
bool setOprToStationSoftAP(void)
Set operation mode to station + softap.
Definition: ESP8266.cpp:121
-
bool createTCP(String addr, uint32_t port)
Create TCP connection in single mode.
Definition: ESP8266.cpp:191
-
bool unregisterUDP(void)
Unregister UDP port number in single mode.
Definition: ESP8266.cpp:206
-
bool startServer(uint32_t port=333)
Start Server(Only in multiple mode).
Definition: ESP8266.cpp:251
-
bool stopTCPServer(void)
Stop TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:244
-
bool stopServer(void)
Stop Server(Only in multiple mode).
Definition: ESP8266.cpp:256
-
bool disableMUX(void)
Disable IP MUX(single connection mode).
Definition: ESP8266.cpp:186
+
bool releaseTCP(void)
Release TCP connection in single mode.
Definition: ESP8266.cpp:303
+
uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000)
Receive data from TCP or UDP builded already in single mode.
Definition: ESP8266.cpp:396
+
bool setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4, uint8_t pattern=3)
Set SoftAP parameters.
Definition: ESP8266.cpp:197
+
String getDHCP(uint8_t pattern=3)
Get the current state of DHCP.
Definition: ESP8266.cpp:209
+
bool setOprToSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to softap.
Definition: ESP8266.cpp:129
+
bool setStationMac(String mac, uint8_t pattern=3)
Set the station's MAC address.
Definition: ESP8266.cpp:232
+
String getNowConecAp(uint8_t pattern=3)
Search and returns the current connect AP.
Definition: ESP8266.cpp:163
+
bool setStationIp(String ip, String gateway, String netmask, uint8_t pattern=3)
Set the station's IP.
Definition: ESP8266.cpp:244
+
bool enableMUX(void)
Enable IP MUX(multiple connection mode).
Definition: ESP8266.cpp:288
+
bool setUart(uint32_t baudrate, uint8_t pattern)
Set up a serial port configuration.
Definition: ESP8266.cpp:96
+
String getWifiModeList(void)
Get the model values list.
Definition: ESP8266.cpp:123
+
bool setAPIp(String ip, uint8_t pattern=3)
Set the AP IP.
Definition: ESP8266.cpp:256
+
String getLocalIP(void)
Get the IP address of ESP8266.
Definition: ESP8266.cpp:281
+
bool deepSleep(uint32_t time)
Start function of deep sleep.
Definition: ESP8266.cpp:101
+
String getSoftAPParam(uint8_t pattern=3)
get SoftAP parameters.
Definition: ESP8266.cpp:188
+
bool createTCP(String addr, uint32_t port)
Create TCP connection in single mode.
Definition: ESP8266.cpp:298
+
bool unregisterUDP(void)
Unregister UDP port number in single mode.
Definition: ESP8266.cpp:313
+
bool startServer(uint32_t port=333)
Start Server(Only in multiple mode).
Definition: ESP8266.cpp:376
+
bool saveTransLink(uint8_t mode, String ip, uint32_t port)
Save the passthrough links.
Definition: ESP8266.cpp:363
+
bool stopTCPServer(void)
Stop TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:351
+
bool setEcho(uint8_t mode)
Switch the echo function.
Definition: ESP8266.cpp:87
+
bool startSmartConfig(uint8_t type)
start smartconfig.
Definition: ESP8266.cpp:261
+
bool stopServer(void)
Stop Server(Only in multiple mode).
Definition: ESP8266.cpp:381
+
bool disableMUX(void)
Disable IP MUX(single connection mode).
Definition: ESP8266.cpp:293
+
bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3)
Set the state of DHCP.
Definition: ESP8266.cpp:215
bool restart(void)
Restart ESP8266 by "AT+RST".
Definition: ESP8266.cpp:63
bool kick(void)
Verify ESP8266 whether live or not.
Definition: ESP8266.cpp:58
-
bool joinAP(String ssid, String pwd)
Join in AP.
Definition: ESP8266.cpp:145
-
bool registerUDP(String addr, uint32_t port)
Register UDP port number in single mode.
Definition: ESP8266.cpp:201
-
bool leaveAP(void)
Leave AP joined before.
Definition: ESP8266.cpp:150
-
bool setTCPServerTimeout(uint32_t timeout=180)
Set the timeout of TCP Server.
Definition: ESP8266.cpp:231
-
Provide an easy-to-use way to manipulate ESP8266.
Definition: ESP8266.h:38
-
bool startTCPServer(uint32_t port=333)
Start TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:236
-
bool setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4)
Set SoftAP parameters.
Definition: ESP8266.cpp:155
-
bool setOprToStation(void)
Set operation mode to staion.
Definition: ESP8266.cpp:87
-
String getAPList(void)
Search available AP list and return it.
Definition: ESP8266.cpp:138
-
String getIPStatus(void)
Get the current status of connection(UDP and TCP).
Definition: ESP8266.cpp:167
-
String getJoinedDeviceIP(void)
Get the IP list of devices connected to SoftAP.
Definition: ESP8266.cpp:160
+
bool setCIPMODE(uint8_t mode)
Set the module transfer mode.
Definition: ESP8266.cpp:358
+
bool registerUDP(String addr, uint32_t port)
Register UDP port number in single mode.
Definition: ESP8266.cpp:308
+
bool restore(void)
Restore factory.
Definition: ESP8266.cpp:92
+
bool setOprToStationSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station + softap.
Definition: ESP8266.cpp:146
+
bool leaveAP(void)
Leave AP joined before.
Definition: ESP8266.cpp:183
+
bool setTCPServerTimeout(uint32_t timeout=180)
Set the timeout of TCP Server.
Definition: ESP8266.cpp:338
+
String getAPIp(uint8_t pattern=3)
Get the AP's IP.
Definition: ESP8266.cpp:249
+
bool stopSmartConfig(void)
stop smartconfig.
Definition: ESP8266.cpp:266
+
Provide an easy-to-use way to manipulate ESP8266.
Definition: ESP8266.h:42
+
bool startTCPServer(uint32_t port=333)
Start TCP Server(Only in multiple mode).
Definition: ESP8266.cpp:343
+
String getAPList(void)
Search available AP list and return it.
Definition: ESP8266.cpp:171
+
String getStationMac(uint8_t pattern=3)
Get the station's MAC address.
Definition: ESP8266.cpp:224
+
String getIPStatus(void)
Get the current status of connection(UDP and TCP).
Definition: ESP8266.cpp:274
+
bool setOprToStation(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station.
Definition: ESP8266.cpp:107
+
String getJoinedDeviceIP(void)
Get the IP list of devices connected to SoftAP.
Definition: ESP8266.cpp:202
diff --git a/doc/API-html/_h_t_t_p_g_e_t_8ino-example.html b/doc/API-html/_h_t_t_p_g_e_t_8ino-example.html index d1730ad..7186885 100644 --- a/doc/API-html/_h_t_t_p_g_e_t_8ino-example.html +++ b/doc/API-html/_h_t_t_p_g_e_t_8ino-example.html @@ -68,13 +68,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP:");
@@ -127,7 +127,7 @@ diff --git a/doc/API-html/_h_t_t_p_g_e_t_8ino_source.html b/doc/API-html/_h_t_t_p_g_e_t_8ino_source.html index 46ae768..1566b94 100644 --- a/doc/API-html/_h_t_t_p_g_e_t_8ino_source.html +++ b/doc/API-html/_h_t_t_p_g_e_t_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_r_e_a_d_m_e_8md_source.html b/doc/API-html/_r_e_a_d_m_e_8md_source.html index bf50340..7f54b1a 100644 --- a/doc/API-html/_r_e_a_d_m_e_8md_source.html +++ b/doc/API-html/_r_e_a_d_m_e_8md_source.html @@ -40,6 +40,7 @@ @@ -155,83 +156,96 @@
105  - [Iteaduino UNO](http://imall.iteadstudio.com/im130312001.html)
106  - [WBoard Pro](http://imall.iteadstudio.com/im141125005.html)
107 
-
108 # Using SoftwareSerial
+
108 # Select the version of ESP8266 AT Firmware
109 
-
110 If you want to use SoftwareSerial to communicate with ESP8266, you need to modify
-
111 the line in file `ESP8266.h`:
+
110 At present, this library supports ESP8266 AT 0.18 version and 0.22 version. You
+
111 can select one of them to fit your module by modifing this line in `ESP8266.h`:
112 
-
113  //#define ESP8266_USE_SOFTWARE_SERIAL
+
113  #define USER_SEL_VERSION VERSION_18
114 
-
115 After modification, it should be:
+
115 If you want to select 0.22 version, it should be like below after modification:
116 
-
117  #define ESP8266_USE_SOFTWARE_SERIAL
+
117  #define USER_SEL_VERSION VERSION_22
118 
119 
-
120 # Hardware Connection
+
120 # Using SoftwareSerial
121 
-
122 WeeESP8266 library only needs an uart for hardware connection. All communications
-
123 are done via uart. In each example, you must specify the uart used by mainboard
-
124 to communicate with ESP8266 flashed AT firmware.
-
125 
-
126 ## MEGA and WBoard Pro
-
127 
-
128 For MEGA and WBoard Pro, `Serial1` will be used if you create an object (named wifi)
-
129 of class ESP8266 in your code like this:
+
122 If you want to use SoftwareSerial to communicate with ESP8266, you need to modify
+
123 the line in file `ESP8266.h`:
+
124 
+
125  //#define ESP8266_USE_SOFTWARE_SERIAL
+
126 
+
127 After modification, it should be:
+
128 
+
129  #define ESP8266_USE_SOFTWARE_SERIAL
130 
-
131  #include "ESP8266.h"
-
132  ESP8266 wifi(Serial1);
+
131 
+
132 # Hardware Connection
133 
-
134 The connection should be like these:
-
135 
-
136  ESP8266_TX->RX1(D19)
-
137  ESP8266_RX->TX1(D18)
-
138  ESP8266_CH_PD->3.3V
-
139  ESP8266_VCC->3.3V
-
140  ESP8266_GND->GND
-
141 
-
142 ## UNO
-
143 
-
144 To use SoftwareSerial, `mySerial` will be used if you create an object (named wifi)
-
145 of class ESP8266 in your code like this:
-
146 
-
147  #include "ESP8266.h"
-
148  #include <SoftwareSerial.h>
-
149 
-
150  SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
-
151  ESP8266 wifi(mySerial);
-
152 
-
153 The connection should be like these:
-
154 
-
155  ESP8266_TX->RX(D3)
-
156  ESP8266_RX->TX(D2)
-
157  ESP8266_CH_PD->3.3V
-
158  ESP8266_VCC->3.3V
-
159  ESP8266_GND->GND
-
160 
-
161 # Attention
-
162 
-
163 The size of data from ESP8266 is too big for arduino sometimes, so the library can't
-
164 receive the whole buffer because the size of the hardware serial buffer which is
-
165 defined in HardwareSerial.h is too small.
+
134 WeeESP8266 library only needs an uart for hardware connection. All communications
+
135 are done via uart. In each example, you must specify the uart used by mainboard
+
136 to communicate with ESP8266 flashed AT firmware.
+
137 
+
138 ## MEGA and WBoard Pro
+
139 
+
140 For MEGA and WBoard Pro, `Serial1` will be used if you create an object (named wifi)
+
141 of class ESP8266 in your code like this:
+
142 
+
143  #include "ESP8266.h"
+
144  ESP8266 wifi(Serial1);
+
145 
+
146 The connection should be like these:
+
147 
+
148  ESP8266_TX->RX1(D19)
+
149  ESP8266_RX->TX1(D18)
+
150  ESP8266_CH_PD->3.3V
+
151  ESP8266_VCC->3.3V
+
152  ESP8266_GND->GND
+
153 
+
154 ## UNO
+
155 
+
156 To use SoftwareSerial, `mySerial` will be used if you create an object (named wifi)
+
157 of class ESP8266 in your code like this:
+
158 
+
159  #include "ESP8266.h"
+
160  #include <SoftwareSerial.h>
+
161 
+
162  SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
+
163  ESP8266 wifi(mySerial);
+
164 
+
165 The connection should be like these:
166 
-
167 Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`.
-
168 See the follow line in the HardwareSerial.h file.
-
169 
-
170  #define SERIAL_BUFFER_SIZE 64
-
171 
-
172 The default size of the buffer is 64. Change it into a bigger number, like 256 or more.
-
173 
+
167  ESP8266_TX->RX(D3)
+
168  ESP8266_RX->TX(D2)
+
169  ESP8266_CH_PD->3.3V
+
170  ESP8266_VCC->3.3V
+
171  ESP8266_GND->GND
+
172 
+
173 # Attention
174 
-
175 -------------------------------------------------------------------------------
-
176 
-
177 # The End!
+
175 The size of data from ESP8266 is too big for arduino sometimes, so the library can't
+
176 receive the whole buffer because the size of the hardware serial buffer which is
+
177 defined in HardwareSerial.h is too small.
178 
-
179 -------------------------------------------------------------------------------
-
Provide an easy-to-use way to manipulate ESP8266.
Definition: ESP8266.h:38
+
179 Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`.
+
180 See the follow line in the HardwareSerial.h file.
+
181 
+
182  #define SERIAL_BUFFER_SIZE 64
+
183 
+
184 The default size of the buffer is 64. Change it into a bigger number, like 256 or more.
+
185 
+
186 
+
187 -------------------------------------------------------------------------------
+
188 
+
189 # The End!
+
190 
+
191 -------------------------------------------------------------------------------
+
Provide an easy-to-use way to manipulate ESP8266.
Definition: ESP8266.h:42
+
#define USER_SEL_VERSION
You can modify the macro to choose a different version.
Definition: ESP8266.h:37
diff --git a/doc/API-html/_t_c_p_client_multiple_8ino-example.html b/doc/API-html/_t_c_p_client_multiple_8ino-example.html index e0912ce..f5171e3 100644 --- a/doc/API-html/_t_c_p_client_multiple_8ino-example.html +++ b/doc/API-html/_t_c_p_client_multiple_8ino-example.html @@ -55,7 +55,7 @@
#define SSID "ITEAD"
#define PASSWORD "12345678"
-
#define HOST_NAME "172.16.5.12"
+
#define HOST_NAME "192.168.1.1"
#define HOST_PORT (8090)
ESP8266 wifi(Serial1);
@@ -69,13 +69,13 @@
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
@@ -144,7 +144,7 @@ diff --git a/doc/API-html/_t_c_p_client_multiple_8ino_source.html b/doc/API-html/_t_c_p_client_multiple_8ino_source.html index e115f40..400ddda 100644 --- a/doc/API-html/_t_c_p_client_multiple_8ino_source.html +++ b/doc/API-html/_t_c_p_client_multiple_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_t_c_p_client_single_8ino-example.html b/doc/API-html/_t_c_p_client_single_8ino-example.html index 45b202d..3719be1 100644 --- a/doc/API-html/_t_c_p_client_single_8ino-example.html +++ b/doc/API-html/_t_c_p_client_single_8ino-example.html @@ -68,13 +68,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP:");
Serial.println( wifi.getLocalIP().c_str());
@@ -124,7 +124,7 @@ diff --git a/doc/API-html/_t_c_p_client_single_8ino_source.html b/doc/API-html/_t_c_p_client_single_8ino_source.html index 3553c47..5838d02 100644 --- a/doc/API-html/_t_c_p_client_single_8ino_source.html +++ b/doc/API-html/_t_c_p_client_single_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_t_c_p_client_single_u_n_o_8ino-example.html b/doc/API-html/_t_c_p_client_single_u_n_o_8ino-example.html index f44562f..c7f026e 100644 --- a/doc/API-html/_t_c_p_client_single_u_n_o_8ino-example.html +++ b/doc/API-html/_t_c_p_client_single_u_n_o_8ino-example.html @@ -70,13 +70,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP:");
Serial.println( wifi.getLocalIP().c_str());
@@ -126,7 +126,7 @@ diff --git a/doc/API-html/_t_c_p_client_single_u_n_o_8ino_source.html b/doc/API-html/_t_c_p_client_single_u_n_o_8ino_source.html index 20b7c76..1cc8501 100644 --- a/doc/API-html/_t_c_p_client_single_u_n_o_8ino_source.html +++ b/doc/API-html/_t_c_p_client_single_u_n_o_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_t_c_p_server_8ino-example.html b/doc/API-html/_t_c_p_server_8ino-example.html index 0acd05c..f220543 100644 --- a/doc/API-html/_t_c_p_server_8ino-example.html +++ b/doc/API-html/_t_c_p_server_8ino-example.html @@ -66,13 +66,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
@@ -144,7 +144,7 @@ diff --git a/doc/API-html/_t_c_p_server_8ino_source.html b/doc/API-html/_t_c_p_server_8ino_source.html index dfdb1a8..dcfbcec 100644 --- a/doc/API-html/_t_c_p_server_8ino_source.html +++ b/doc/API-html/_t_c_p_server_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_u_d_p_client_multiple_8ino-example.html b/doc/API-html/_u_d_p_client_multiple_8ino-example.html index 1f17964..8748c5d 100644 --- a/doc/API-html/_u_d_p_client_multiple_8ino-example.html +++ b/doc/API-html/_u_d_p_client_multiple_8ino-example.html @@ -68,13 +68,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
@@ -137,7 +137,7 @@ diff --git a/doc/API-html/_u_d_p_client_multiple_8ino_source.html b/doc/API-html/_u_d_p_client_multiple_8ino_source.html index 9167ff9..8aa087f 100644 --- a/doc/API-html/_u_d_p_client_multiple_8ino_source.html +++ b/doc/API-html/_u_d_p_client_multiple_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/_u_d_p_client_single_8ino-example.html b/doc/API-html/_u_d_p_client_single_8ino-example.html index dc9b440..b50a8f0 100644 --- a/doc/API-html/_u_d_p_client_single_8ino-example.html +++ b/doc/API-html/_u_d_p_client_single_8ino-example.html @@ -68,13 +68,13 @@
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
-
if (wifi.setOprToStationSoftAP()) {
+
if (wifi.setOprToStationSoftAP()) {
Serial.print("to station + softap ok\r\n");
} else {
Serial.print("to station + softap err\r\n");
}
-
if (wifi.joinAP(SSID, PASSWORD)) {
+
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
@@ -124,7 +124,7 @@ diff --git a/doc/API-html/_u_d_p_client_single_8ino_source.html b/doc/API-html/_u_d_p_client_single_8ino_source.html index 1d22a60..6ba6348 100644 --- a/doc/API-html/_u_d_p_client_single_8ino_source.html +++ b/doc/API-html/_u_d_p_client_single_8ino_source.html @@ -40,6 +40,7 @@ diff --git a/doc/API-html/annotated.html b/doc/API-html/annotated.html index d0e5d27..cd7347f 100644 --- a/doc/API-html/annotated.html +++ b/doc/API-html/annotated.html @@ -58,7 +58,7 @@ diff --git a/doc/API-html/class_e_s_p8266-members.html b/doc/API-html/class_e_s_p8266-members.html index fe90950..9ad36f5 100644 --- a/doc/API-html/class_e_s_p8266-members.html +++ b/doc/API-html/class_e_s_p8266-members.html @@ -55,14 +55,22 @@ - - + + + + - - - - - + + + + + + + + + + + @@ -73,23 +81,36 @@ + + - - - - + + + + + + + + + + + + - + + + - - - + + + +
createTCP(String addr, uint32_t port)ESP8266
createTCP(uint8_t mux_id, String addr, uint32_t port)ESP8266
disableMUX(void)ESP8266
enableMUX(void)ESP8266
deepSleep(uint32_t time)ESP8266
disableMUX(void)ESP8266
enableMUX(void)ESP8266
getAPIp(uint8_t pattern=3)ESP8266
getAPList(void)ESP8266
getIPStatus(void)ESP8266
getJoinedDeviceIP(void)ESP8266
getLocalIP(void)ESP8266
getVersion(void)ESP8266
joinAP(String ssid, String pwd)ESP8266
getDHCP(uint8_t pattern=3)ESP8266
getIPStatus(void)ESP8266
getJoinedDeviceIP(void)ESP8266
getLocalIP(void)ESP8266
getNowConecAp(uint8_t pattern=3)ESP8266
getSoftAPParam(uint8_t pattern=3)ESP8266
getStationIp(uint8_t pattern=3)ESP8266
getStationMac(uint8_t pattern=3)ESP8266
getVersion(void)ESP8266
getWifiModeList(void)ESP8266
joinAP(String ssid, String pwd, uint8_t pattern=3)ESP8266
kick(void)ESP8266
leaveAP(void)ESP8266
recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000)ESP8266
releaseTCP(void)ESP8266
releaseTCP(uint8_t mux_id)ESP8266
restart(void)ESP8266
restore(void)ESP8266
saveTransLink(uint8_t mode, String ip, uint32_t port)ESP8266
send(const uint8_t *buffer, uint32_t len)ESP8266
send(uint8_t mux_id, const uint8_t *buffer, uint32_t len)ESP8266
setOprToSoftAP(void)ESP8266
setOprToStation(void)ESP8266
setOprToStationSoftAP(void)ESP8266
setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4)ESP8266
setAPIp(String ip, uint8_t pattern=3)ESP8266
setAutoConnect(uint8_t en)ESP8266
setCIPMODE(uint8_t mode)ESP8266
setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3)ESP8266
setEcho(uint8_t mode)ESP8266
setOprToSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)ESP8266
setOprToStation(uint8_t pattern1=3, uint8_t pattern2=3)ESP8266
setOprToStationSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)ESP8266
setPing(String ip)ESP8266
setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4, uint8_t pattern=3)ESP8266
setStationIp(String ip, String gateway, String netmask, uint8_t pattern=3)ESP8266
setStationMac(String mac, uint8_t pattern=3)ESP8266
setTCPServerTimeout(uint32_t timeout=180)ESP8266
startServer(uint32_t port=333)ESP8266
setUart(uint32_t baudrate, uint8_t pattern)ESP8266
startServer(uint32_t port=333)ESP8266
startSmartConfig(uint8_t type)ESP8266
startTCPServer(uint32_t port=333)ESP8266
stopServer(void)ESP8266
stopTCPServer(void)ESP8266
unregisterUDP(void)ESP8266
unregisterUDP(uint8_t mux_id)ESP8266
stopSmartConfig(void)ESP8266
stopTCPServer(void)ESP8266
unregisterUDP(void)ESP8266
unregisterUDP(uint8_t mux_id)ESP8266
diff --git a/doc/API-html/class_e_s_p8266.html b/doc/API-html/class_e_s_p8266.html index df93c23..c43e893 100644 --- a/doc/API-html/class_e_s_p8266.html +++ b/doc/API-html/class_e_s_p8266.html @@ -70,30 +70,84 @@ String getVersion (void)  Get the version of AT Command Set. More...
  -bool setOprToStation (void) - Set operation mode to staion. More...
-  -bool setOprToSoftAP (void) - Set operation mode to softap. More...
-  -bool setOprToStationSoftAP (void) - Set operation mode to station + softap. More...
-  +bool deepSleep (uint32_t time) + Start function of deep sleep. More...
+  +bool setEcho (uint8_t mode) + Switch the echo function. More...
+  +bool restore (void) + Restore factory. More...
+  +bool setUart (uint32_t baudrate, uint8_t pattern) + Set up a serial port configuration. More...
+  +bool setOprToStation (uint8_t pattern1=3, uint8_t pattern2=3) + Set operation mode to station. More...
+  +String getWifiModeList (void) + Get the model values list. More...
+  +bool setOprToSoftAP (uint8_t pattern1=3, uint8_t pattern2=3) + Set operation mode to softap. More...
+  +bool setOprToStationSoftAP (uint8_t pattern1=3, uint8_t pattern2=3) + Set operation mode to station + softap. More...
+  String getAPList (void)  Search available AP list and return it. More...
  -bool joinAP (String ssid, String pwd) - Join in AP. More...
-  +String getNowConecAp (uint8_t pattern=3) + Search and returns the current connect AP. More...
+  +bool joinAP (String ssid, String pwd, uint8_t pattern=3) + Join in AP. More...
+  bool leaveAP (void)  Leave AP joined before. More...
  -bool setSoftAPParam (String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4) - Set SoftAP parameters. More...
-  +bool setSoftAPParam (String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4, uint8_t pattern=3) + Set SoftAP parameters. More...
+  +String getSoftAPParam (uint8_t pattern=3) + get SoftAP parameters. More...
+  String getJoinedDeviceIP (void)  Get the IP list of devices connected to SoftAP. More...
  +String getDHCP (uint8_t pattern=3) + Get the current state of DHCP. More...
+  +bool setDHCP (uint8_t mode, uint8_t en, uint8_t pattern=3) + Set the state of DHCP. More...
+  +bool setAutoConnect (uint8_t en) + make boot automatically connected. More...
+  +String getStationMac (uint8_t pattern=3) + Get the station's MAC address. More...
+  +bool setStationMac (String mac, uint8_t pattern=3) + Set the station's MAC address. More...
+  +String getStationIp (uint8_t pattern=3) + Get the station's IP. More...
+  +bool setStationIp (String ip, String gateway, String netmask, uint8_t pattern=3) + Set the station's IP. More...
+  +String getAPIp (uint8_t pattern=3) + Get the AP's IP. More...
+  +bool setAPIp (String ip, uint8_t pattern=3) + Set the AP IP. More...
+  +bool startSmartConfig (uint8_t type) + start smartconfig. More...
+  +bool stopSmartConfig (void) + stop smartconfig. More...
+  String getIPStatus (void)  Get the current status of connection(UDP and TCP). More...
  @@ -139,12 +193,21 @@ bool stopTCPServer (void)  Stop TCP Server(Only in multiple mode). More...
  +bool setCIPMODE (uint8_t mode) + Set the module transfer mode. More...
+  bool startServer (uint32_t port=333)  Start Server(Only in multiple mode). More...
  bool stopServer (void)  Stop Server(Only in multiple mode). More...
  +bool saveTransLink (uint8_t mode, String ip, uint32_t port) + Save the passthrough links. More...
+  +bool setPing (String ip) + PING COMMAND. More...
+  bool send (const uint8_t *buffer, uint32_t len)  Send data based on TCP or UDP builded already in single mode. More...
  @@ -163,9 +226,9 @@

Detailed Description

Provide an easy-to-use way to manipulate ESP8266.

-
Examples:
ConnectWiFi.ino, HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
+
Examples:
ConnectWiFi.ino, HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, test.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 38 of file ESP8266.h.

+

Definition at line 42 of file ESP8266.h.

Member Function Documentation

@@ -208,7 +271,7 @@
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, and TCPClientSingleUNO.ino.
-

Definition at line 191 of file ESP8266.cpp.

+

Definition at line 298 of file ESP8266.cpp.

@@ -259,7 +322,41 @@ -

Definition at line 211 of file ESP8266.cpp.

+

Definition at line 318 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
bool ESP8266::deepSleep (uint32_t time)
+
+ +

Start function of deep sleep.

+
Parameters
+ + +
time- the sleep time.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Note
the feature requires hardware support.
+ +

Definition at line 101 of file ESP8266.cpp.

@@ -288,7 +385,7 @@
Examples:
HTTPGET.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, and UDPClientSingle.ino.
-

Definition at line 186 of file ESP8266.cpp.

+

Definition at line 293 of file ESP8266.cpp.

@@ -317,7 +414,36 @@
Examples:
TCPClientMultiple.ino, TCPServer.ino, and UDPClientMultiple.ino.
-

Definition at line 181 of file ESP8266.cpp.

+

Definition at line 288 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
String ESP8266::getAPIp (uint8_t pattern = 3)
+
+ +

Get the AP's IP.

+
Parameters
+ + +
pattern-1 send "AT+CIPAP_DEF?" -2 send "AT+CIPAP_CUR?" -3 send "AT+CIPAP?".
+
+
+
Returns
ap's ip.
+
Note
This method should not be called when station mode.
+
Examples:
test.ino.
+
+

Definition at line 249 of file ESP8266.cpp.

@@ -338,8 +464,37 @@

Search available AP list and return it.

Returns
the list of available APs.
Note
This method will occupy a lot of memeory(hundreds of Bytes to a couple of KBytes). Do not call this method unless you must and ensure that your board has enough memery left.
+
Examples:
test.ino.
+
+

Definition at line 171 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
String ESP8266::getDHCP (uint8_t pattern = 3)
+
-

Definition at line 138 of file ESP8266.cpp.

+

Get the current state of DHCP.

+
Parameters
+ + +
pattern-1 send "AT+CWDHCP_DEF?" -2 send "AT+CWDHCP_CUR?" -3 send "AT+CWDHCP?".
+
+
+
Returns
the state of DHCP.
+
Examples:
test.ino.
+
+

Definition at line 209 of file ESP8266.cpp.

@@ -359,9 +514,9 @@

Get the current status of connection(UDP and TCP).

Returns
the status.
-
Examples:
TCPServer.ino.
+
Examples:
TCPServer.ino, and test.ino.
-

Definition at line 167 of file ESP8266.cpp.

+

Definition at line 274 of file ESP8266.cpp.

@@ -382,8 +537,9 @@

Get the IP list of devices connected to SoftAP.

Returns
the list of IP.
Note
This method should not be called when station mode.
- -

Definition at line 160 of file ESP8266.cpp.

+
Examples:
test.ino.
+
+

Definition at line 202 of file ESP8266.cpp.

@@ -405,7 +561,121 @@
Returns
the IP list.
Examples:
ConnectWiFi.ino, HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 174 of file ESP8266.cpp.

+

Definition at line 281 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
String ESP8266::getNowConecAp (uint8_t pattern = 3)
+
+ +

Search and returns the current connect AP.

+
Parameters
+ + +
pattern-1, send "AT+CWJAP_DEF?",-2,send "AT+CWJAP_CUR?",-3,send "AT+CWJAP?".
+
+
+
Returns
the ssid of AP connected now.
+
Examples:
test.ino.
+
+

Definition at line 163 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + +
String ESP8266::getSoftAPParam (uint8_t pattern = 3)
+
+ +

get SoftAP parameters.

+
Parameters
+ + +
pattern-1 send "AT+CWSAP_DEF?" -2 send "AT+CWSAP_CUR?" -3 send "AT+CWSAP?".
+
+
+
Note
This method should not be called when station mode.
+
Examples:
test.ino.
+
+

Definition at line 188 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + +
String ESP8266::getStationIp (uint8_t pattern = 3)
+
+ +

Get the station's IP.

+
Parameters
+ + +
pattern-1 send "AT+CIPSTA_DEF?" -2 send "AT+CIPSTA_CUR?" -3 send "AT+CIPSTA?".
+
+
+
Returns
the station's IP.
+
Note
This method should not be called when ap mode.
+
Examples:
test.ino.
+
+

Definition at line 237 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + +
String ESP8266::getStationMac (uint8_t pattern = 3)
+
+ +

Get the station's MAC address.

+
Parameters
+ + +
pattern-1 send "AT+CIPSTAMAC_DEF?=" -2 send "AT+CIPSTAMAC_CUR?" -3 send "AT+CIPSTAMAC?".
+
+
+
Returns
mac address.
+
Note
This method should not be called when ap mode.
+
Examples:
test.ino.
+
+

Definition at line 224 of file ESP8266.cpp.

@@ -431,7 +701,29 @@ - + +
+
+ + + + + + + + +
String ESP8266::getWifiModeList (void )
+
+ +

Get the model values list.

+
Returns
the list of model.
+
Examples:
test.ino.
+
+

Definition at line 123 of file ESP8266.cpp.

+ +
+
+
@@ -445,7 +737,13 @@ - + + + + + + + @@ -458,6 +756,7 @@

Join in AP.

Parameters
String pwd pwd,
uint8_t pattern = 3 
+
pattern-1 send "AT+CWJAP_DEF=" -2 send "AT+CWJAP_CUR=" -3 send "AT+CWJAP=".
ssid- SSID of AP to join in.
pwd- Password of AP to join in.
@@ -471,9 +770,9 @@
Note
This method will take a couple of seconds.
-
Examples:
ConnectWiFi.ino, HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
+
Examples:
ConnectWiFi.ino, HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, test.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 145 of file ESP8266.cpp.

+

Definition at line 178 of file ESP8266.cpp.

@@ -527,8 +826,9 @@
- -

Definition at line 150 of file ESP8266.cpp.

+
Examples:
test.ino.
+
+

Definition at line 183 of file ESP8266.cpp.

@@ -574,7 +874,7 @@
Returns
the length of data received actually.
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 271 of file ESP8266.cpp.

+

Definition at line 396 of file ESP8266.cpp.

@@ -626,7 +926,7 @@
Returns
the length of data received actually.
-

Definition at line 276 of file ESP8266.cpp.

+

Definition at line 401 of file ESP8266.cpp.

@@ -679,7 +979,7 @@
Returns
the length of data received actually.
-

Definition at line 287 of file ESP8266.cpp.

+

Definition at line 412 of file ESP8266.cpp.

@@ -724,7 +1024,7 @@
Examples:
UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 201 of file ESP8266.cpp.

+

Definition at line 308 of file ESP8266.cpp.

@@ -775,7 +1075,7 @@ -

Definition at line 221 of file ESP8266.cpp.

+

Definition at line 328 of file ESP8266.cpp.

@@ -803,7 +1103,7 @@
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, and TCPServer.ino.
-

Definition at line 196 of file ESP8266.cpp.

+

Definition at line 303 of file ESP8266.cpp.

@@ -836,7 +1136,7 @@ -

Definition at line 216 of file ESP8266.cpp.

+

Definition at line 323 of file ESP8266.cpp.

@@ -866,6 +1166,78 @@

Definition at line 63 of file ESP8266.cpp.

+ + + +
+
+ + + + + + + + +
bool ESP8266::restore (void )
+
+ +

Restore factory.

+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Note
The operation can lead to restart the machine.
+ +

Definition at line 92 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool ESP8266::saveTransLink (uint8_t mode,
String ip,
uint32_t port 
)
+
+ +

Save the passthrough links.

+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 363 of file ESP8266.cpp.

+
@@ -909,7 +1281,7 @@
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 261 of file ESP8266.cpp.

+

Definition at line 386 of file ESP8266.cpp.

@@ -960,25 +1332,42 @@ -

Definition at line 266 of file ESP8266.cpp.

+

Definition at line 391 of file ESP8266.cpp.

- +
- + - - + + + + + + + + + + + +
bool ESP8266::setOprToSoftAP bool ESP8266::setAPIp (void )String ip,
uint8_t pattern = 3 
)
-

Set operation mode to softap.

+

Set the AP IP.

+
Parameters
+ + + +
pattern-1 send "AT+CIPAP_DEF=" -2 send "AT+CIPAP_CUR=" -3 send "AT+CIPAP=".
ip- the ip of AP.
+
+
Return values
@@ -986,26 +1375,113 @@
true- success.
+
Note
This method should not be called when station mode.
+
Examples:
test.ino.
+
+

Definition at line 256 of file ESP8266.cpp.

-

Definition at line 104 of file ESP8266.cpp.

+
+
+ +
+
+ + + + + + + + +
bool ESP8266::setAutoConnect (uint8_t en)
+
+ +

make boot automatically connected.

+
Parameters
+ + +
en-1 enable -0 disable.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 220 of file ESP8266.cpp.

- +
- + - - + + + + +
bool ESP8266::setOprToStation bool ESP8266::setCIPMODE (void )uint8_t mode)
+
+ +

Set the module transfer mode.

+
Return values
+ + + +
true- success.
false- failure.
+
+
+ +

Definition at line 358 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
bool ESP8266::setDHCP (uint8_t mode,
uint8_t en,
uint8_t pattern = 3 
)
-

Set operation mode to staion.

+

Set the state of DHCP.

+
Parameters
+ + + + +
pattern-1 send "AT+CWDHCP_DEF=" -2 send "AT+CWDHCP_CUR=" -3 send "AT+CWDHCP=".
mode- set ap or set station or set ap + station.
en- 0 disable DHCP - 1 enable DHCP.
+
+
Return values
@@ -1013,27 +1489,167 @@
true- success.
-
Examples:
ConnectWiFi.ino.
+
Examples:
test.ino.
+
+

Definition at line 215 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + +
bool ESP8266::setEcho (uint8_t mode)
+
+ +

Switch the echo function.

+
Parameters
+ + +
mode- 1 start echo -0 stop echo
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+

Definition at line 87 of file ESP8266.cpp.

- + +
+
+ + + + + + + + + + + + + + + + + + +
bool ESP8266::setOprToSoftAP (uint8_t pattern1 = 3,
uint8_t pattern2 = 3 
)
+
+ +

Set operation mode to softap.

+
Parameters
+ + + +
pattern1-1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
pattern2-1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 129 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
bool ESP8266::setOprToStation (uint8_t pattern1 = 3,
uint8_t pattern2 = 3 
)
+
+ +

Set operation mode to station.

+
Parameters
+ + + +
pattern1-1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
pattern2-1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
ConnectWiFi.ino, and test.ino.
+
+

Definition at line 107 of file ESP8266.cpp.

+ +
+
+
- - + + + + + + + + + + + +
bool ESP8266::setOprToStationSoftAP (void )uint8_t pattern1 = 3,
uint8_t pattern2 = 3 
)

Set operation mode to station + softap.

+
Parameters
+ + + +
pattern1-1, send "AT+CWMODE_DEF?",-2,send "AT+CWMODE_CUR?",-3,send "AT+CWMODE?".
pattern2-1, send "AT+CWMODE_DEF=",-2,send "AT+CWMODE_CUR=",-3,send "AT+CWMODE=".
+
+
Return values
@@ -1041,13 +1657,40 @@
true- success.
-
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
+
Examples:
HTTPGET.ino, TCPClientMultiple.ino, TCPClientSingle.ino, TCPClientSingleUNO.ino, TCPServer.ino, test.ino, UDPClientMultiple.ino, and UDPClientSingle.ino.
+
+

Definition at line 146 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + +
bool ESP8266::setPing (String ip)
+
+ +

PING COMMAND.

+
Return values
+ + + +
true- success.
false- failure.
+
-

Definition at line 121 of file ESP8266.cpp.

+ +

Definition at line 368 of file ESP8266.cpp.

- +
@@ -1073,7 +1716,13 @@ - + + + + + + + @@ -1086,6 +1735,7 @@

Set SoftAP parameters.

Parameters
uint8_t ecn = 4 ecn = 4,
uint8_t pattern = 3 
+ @@ -1093,9 +1743,122 @@
pattern-1 send "AT+CWSAP_DEF=" -2 send "AT+CWSAP_CUR=" -3 send "AT+CWSAP=".
ssid- SSID of SoftAP.
pwd- PASSWORD of SoftAP.
chl- the channel (1 - 13, default: 7).
+
Return values
+ + + +
true- success.
false- failure.
+
+
Note
This method should not be called when station mode.
+
Examples:
test.ino.
+
+

Definition at line 197 of file ESP8266.cpp.

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool ESP8266::setStationIp (String ip,
String gateway,
String netmask,
uint8_t pattern = 3 
)
+
+ +

Set the station's IP.

+
Parameters
+ + + + + +
pattern-1 send "AT+CIPSTA_DEF=" -2 send "AT+CIPSTA_CUR=" -3 send "AT+CIPSTA=".
ip- the ip of station.
gateway-the gateway of station.
netmask-the netmask of station.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Note
This method should not be called when ap mode.
+
Examples:
test.ino.
+
+

Definition at line 244 of file ESP8266.cpp.

-

Definition at line 155 of file ESP8266.cpp.

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
bool ESP8266::setStationMac (String mac,
uint8_t pattern = 3 
)
+
+ +

Set the station's MAC address.

+
Parameters
+ + + +
pattern-1 send "AT+CIPSTAMAC_DEF=" -2 send "AT+CIPSTAMAC_CUR=" -3 send "AT+CIPSTAMAC=".
mac- the mac address of station.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 232 of file ESP8266.cpp.

@@ -1129,7 +1892,53 @@
Examples:
TCPServer.ino.
-

Definition at line 231 of file ESP8266.cpp.

+

Definition at line 338 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + + + + + + + + + + + +
bool ESP8266::setUart (uint32_t baudrate,
uint8_t pattern 
)
+
+ +

Set up a serial port configuration.

+
Parameters
+ + + +
pattern-1 send "AT+UART=", -2 send "AT+UART_CUR=", -3 send "AT+UART_DEF=".
baudrate- the uart baudrate.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Note
Only allows baud rate design, for the other parameters:databits- 8,stopbits -1,parity -0,flow control -0 .
+
Examples:
test.ino.
+
+

Definition at line 96 of file ESP8266.cpp.

@@ -1165,7 +1974,41 @@
uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
-

Definition at line 251 of file ESP8266.cpp.

+

Definition at line 376 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
bool ESP8266::startSmartConfig (uint8_t type)
+
+ +

start smartconfig.

+
Parameters
+ + +
type-1:ESP_TOUCH -2:AirKiss.
+
+
+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 261 of file ESP8266.cpp.

@@ -1205,7 +2048,7 @@ bool releaseTCP(uint8_t mux_id);
Examples:
TCPServer.ino.
-

Definition at line 236 of file ESP8266.cpp.

+

Definition at line 343 of file ESP8266.cpp.

@@ -1232,7 +2075,35 @@ -

Definition at line 256 of file ESP8266.cpp.

+

Definition at line 381 of file ESP8266.cpp.

+ + + + +
+
+ + + + + + + + +
bool ESP8266::stopSmartConfig (void )
+
+ +

stop smartconfig.

+
Return values
+ + + +
true- success.
false- failure.
+
+
+
Examples:
test.ino.
+
+

Definition at line 266 of file ESP8266.cpp.

@@ -1259,7 +2130,7 @@ -

Definition at line 244 of file ESP8266.cpp.

+

Definition at line 351 of file ESP8266.cpp.

@@ -1287,7 +2158,7 @@
Examples:
UDPClientMultiple.ino, and UDPClientSingle.ino.
-

Definition at line 206 of file ESP8266.cpp.

+

Definition at line 313 of file ESP8266.cpp.

@@ -1320,7 +2191,7 @@ -

Definition at line 226 of file ESP8266.cpp.

+

Definition at line 333 of file ESP8266.cpp.

@@ -1331,7 +2202,7 @@ diff --git a/doc/API-html/classes.html b/doc/API-html/classes.html index fee65dc..a48a7b9 100644 --- a/doc/API-html/classes.html +++ b/doc/API-html/classes.html @@ -62,7 +62,7 @@ diff --git a/doc/API-html/dir_0fe9cd1e19620fd79d7a86ad96ecfe64.html b/doc/API-html/dir_0fe9cd1e19620fd79d7a86ad96ecfe64.html new file mode 100644 index 0000000..5db04e1 --- /dev/null +++ b/doc/API-html/dir_0fe9cd1e19620fd79d7a86ad96ecfe64.html @@ -0,0 +1,64 @@ + + + + + + +API: examples/test Directory Reference + + + + + + +
+
+ + + + + + + +
+
API +
+
For Arduino developers
+
+
+ + + + +
+
+
+
test Directory Reference
+
+
+ + + + +

+Files

file  test.ino [code]
 
+
+ + + + diff --git a/doc/API-html/dir_5890e445ff7904d5f0f55dc78452c21e.html b/doc/API-html/dir_5890e445ff7904d5f0f55dc78452c21e.html index adee4e0..b76a47d 100644 --- a/doc/API-html/dir_5890e445ff7904d5f0f55dc78452c21e.html +++ b/doc/API-html/dir_5890e445ff7904d5f0f55dc78452c21e.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_7baf3e2c0fad72d16e1aad0d74b4aab1.html b/doc/API-html/dir_7baf3e2c0fad72d16e1aad0d74b4aab1.html index 459f75b..9ffa6a0 100644 --- a/doc/API-html/dir_7baf3e2c0fad72d16e1aad0d74b4aab1.html +++ b/doc/API-html/dir_7baf3e2c0fad72d16e1aad0d74b4aab1.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_8897193998642bcd5bfc513741e45982.html b/doc/API-html/dir_8897193998642bcd5bfc513741e45982.html index 78d0a85..8ef2051 100644 --- a/doc/API-html/dir_8897193998642bcd5bfc513741e45982.html +++ b/doc/API-html/dir_8897193998642bcd5bfc513741e45982.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_8d6221cc4158f181d53b350a968e25f7.html b/doc/API-html/dir_8d6221cc4158f181d53b350a968e25f7.html index 8675871..83b822b 100644 --- a/doc/API-html/dir_8d6221cc4158f181d53b350a968e25f7.html +++ b/doc/API-html/dir_8d6221cc4158f181d53b350a968e25f7.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_d28a4824dc47e487b107a5db32ef43c4.html b/doc/API-html/dir_d28a4824dc47e487b107a5db32ef43c4.html index d35f168..17a8625 100644 --- a/doc/API-html/dir_d28a4824dc47e487b107a5db32ef43c4.html +++ b/doc/API-html/dir_d28a4824dc47e487b107a5db32ef43c4.html @@ -62,6 +62,8 @@   directory  TCPServer   +directory  test +  directory  UDPClientMultiple   directory  UDPClientSingle @@ -70,7 +72,7 @@ diff --git a/doc/API-html/dir_d2ed1861e8b23cc7f6c17b3a49969805.html b/doc/API-html/dir_d2ed1861e8b23cc7f6c17b3a49969805.html index 19ee32f..bba702f 100644 --- a/doc/API-html/dir_d2ed1861e8b23cc7f6c17b3a49969805.html +++ b/doc/API-html/dir_d2ed1861e8b23cc7f6c17b3a49969805.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_db2b6df4be8fe245a288f3ee89789028.html b/doc/API-html/dir_db2b6df4be8fe245a288f3ee89789028.html index 3db9c66..516e6dd 100644 --- a/doc/API-html/dir_db2b6df4be8fe245a288f3ee89789028.html +++ b/doc/API-html/dir_db2b6df4be8fe245a288f3ee89789028.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_e77b6112596a040608ac3c23911cc719.html b/doc/API-html/dir_e77b6112596a040608ac3c23911cc719.html index 3494957..37a284a 100644 --- a/doc/API-html/dir_e77b6112596a040608ac3c23911cc719.html +++ b/doc/API-html/dir_e77b6112596a040608ac3c23911cc719.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/dir_f7dc4f4aec738992f977d5b3021cb4e4.html b/doc/API-html/dir_f7dc4f4aec738992f977d5b3021cb4e4.html index c75fb5e..d2b3509 100644 --- a/doc/API-html/dir_f7dc4f4aec738992f977d5b3021cb4e4.html +++ b/doc/API-html/dir_f7dc4f4aec738992f977d5b3021cb4e4.html @@ -56,7 +56,7 @@ diff --git a/doc/API-html/doxygen_8h.html b/doc/API-html/doxygen_8h.html index a340bed..17cc21e 100644 --- a/doc/API-html/doxygen_8h.html +++ b/doc/API-html/doxygen_8h.html @@ -40,6 +40,7 @@ @@ -64,7 +65,7 @@ diff --git a/doc/API-html/doxygen_8h_source.html b/doc/API-html/doxygen_8h_source.html index 707ac49..8180d13 100644 --- a/doc/API-html/doxygen_8h_source.html +++ b/doc/API-html/doxygen_8h_source.html @@ -40,6 +40,7 @@ @@ -52,13 +53,11 @@
16 #ifndef __IOTGO_DOXYGEN_H__
17 #define __IOTGO_DOXYGEN_H__
18 
-
19 
-
20 
-
21 #endif /* #ifndef __IOTGO_DOXYGEN_H__ */
+
19 #endif /* #ifndef __IOTGO_DOXYGEN_H__ */
diff --git a/doc/API-html/examples.html b/doc/API-html/examples.html index 93d1958..319f712 100644 --- a/doc/API-html/examples.html +++ b/doc/API-html/examples.html @@ -56,6 +56,8 @@
  • TCPServer.ino
  • +
  • test.ino
  • +
  • UDPClientMultiple.ino
  • UDPClientSingle.ino
  • @@ -64,7 +66,7 @@ diff --git a/doc/API-html/files.html b/doc/API-html/files.html index dc9dc59..2e8e0c0 100644 --- a/doc/API-html/files.html +++ b/doc/API-html/files.html @@ -40,6 +40,7 @@ @@ -63,10 +64,12 @@  TCPClientSingleUNO.ino   TCPServer  TCPServer.ino -  UDPClientMultiple - UDPClientMultiple.ino -  UDPClientSingle - UDPClientSingle.ino +  test + test.ino +  UDPClientMultiple + UDPClientMultiple.ino +  UDPClientSingle + UDPClientSingle.ino  doxygen.hDefine modules in API doc  ESP8266.cppThe implementation of class ESP8266  ESP8266.hThe definition of class ESP8266 @@ -75,7 +78,7 @@ diff --git a/doc/API-html/functions.html b/doc/API-html/functions.html index f2258d3..2087967 100644 --- a/doc/API-html/functions.html +++ b/doc/API-html/functions.html @@ -76,6 +76,9 @@

    - c -