Added support for commands without _CUR for ESP
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -149,8 +149,12 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
if (waitResponse() != 1) { return false; }
|
if (waitResponse() != 1) { return false; }
|
||||||
sendAT(GF("+CIPMUX=1")); // Enable Multiple Connections
|
sendAT(GF("+CIPMUX=1")); // Enable Multiple Connections
|
||||||
if (waitResponse() != 1) { return false; }
|
if (waitResponse() != 1) { return false; }
|
||||||
sendAT(GF("+CWMODE_CUR=1")); // Put into "station" mode
|
sendAT(GF("+CWMODE=1")); // Put into "station" mode
|
||||||
|
if (waitResponse() != 1) {
|
||||||
|
sendAT(GF("+CWMODE_CUR=1")); // Attempt "current" station mode command
|
||||||
|
// for some firmware variants if needed
|
||||||
if (waitResponse() != 1) { return false; }
|
if (waitResponse() != 1) { return false; }
|
||||||
|
}
|
||||||
DBG(GF("### Modem:"), getModemName());
|
DBG(GF("### Modem:"), getModemName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -161,6 +165,15 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
|
|
||||||
void setBaudImpl(uint32_t baud) {
|
void setBaudImpl(uint32_t baud) {
|
||||||
sendAT(GF("+UART_CUR="), baud, "8,1,0,0");
|
sendAT(GF("+UART_CUR="), baud, "8,1,0,0");
|
||||||
|
if (waitResponse() != 1) {
|
||||||
|
sendAT(GF("+UART="), baud,
|
||||||
|
"8,1,0,0"); // Really old firmwares might need this
|
||||||
|
// if (waitResponse() != 1) {
|
||||||
|
// sendAT(GF("+IPR="), baud); // First release firmwares might need
|
||||||
|
// this
|
||||||
|
waitResponse();
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool factoryDefaultImpl() {
|
bool factoryDefaultImpl() {
|
||||||
@@ -218,12 +231,18 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
int8_t getSignalQualityImpl() {
|
int8_t getSignalQualityImpl() {
|
||||||
sendAT(GF("+CWJAP_CUR?"));
|
sendAT(GF("+CWJAP?"));
|
||||||
|
int8_t res1 = waitResponse(GF("No AP"), GF("+CWJAP:"));
|
||||||
|
if (res1 != 2) {
|
||||||
|
waitResponse();
|
||||||
|
sendAT(GF("+CWJAP_CUR?")); // attempt "current" as used by some firmware
|
||||||
|
// versions
|
||||||
int8_t res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:"));
|
int8_t res1 = waitResponse(GF("No AP"), GF("+CWJAP_CUR:"));
|
||||||
if (res1 != 2) {
|
if (res1 != 2) {
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
streamSkipUntil(','); // Skip SSID
|
streamSkipUntil(','); // Skip SSID
|
||||||
streamSkipUntil(','); // Skip BSSID/MAC address
|
streamSkipUntil(','); // Skip BSSID/MAC address
|
||||||
streamSkipUntil(','); // Skip Chanel number
|
streamSkipUntil(','); // Skip Chanel number
|
||||||
@@ -250,10 +269,18 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getLocalIPImpl() {
|
String getLocalIPImpl() {
|
||||||
|
// attempt with and without 'current' flag
|
||||||
|
sendAT(GF("+CIPSTA?"));
|
||||||
|
int8_t res1 = waitResponse(GF("ERROR"), GF("+CIPSTA:"));
|
||||||
|
if (res1 != 2) {
|
||||||
sendAT(GF("+CIPSTA_CUR?"));
|
sendAT(GF("+CIPSTA_CUR?"));
|
||||||
int8_t res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:"));
|
res1 = waitResponse(GF("ERROR"), GF("+CIPSTA_CUR:"));
|
||||||
if (res1 != 2) { return ""; }
|
if (res1 != 2) { return ""; }
|
||||||
String res2 = stream.readStringUntil('"');
|
}
|
||||||
|
String res2 = stream.readStringUntil('\n');
|
||||||
|
res2.replace("ip:", ""); // newer firmwares have this
|
||||||
|
res2.replace("\"", "");
|
||||||
|
res2.trim();
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
@@ -263,10 +290,15 @@ class TinyGsmESP8266 : public TinyGsmModem<TinyGsmESP8266>,
|
|||||||
*/
|
*/
|
||||||
protected:
|
protected:
|
||||||
bool networkConnectImpl(const char* ssid, const char* pwd) {
|
bool networkConnectImpl(const char* ssid, const char* pwd) {
|
||||||
|
// attempt first without than with the 'current' flag used in some firmware
|
||||||
|
// versions
|
||||||
|
sendAT(GF("+CWJAP=\""), ssid, GF("\",\""), pwd, GF("\""));
|
||||||
|
if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) {
|
||||||
sendAT(GF("+CWJAP_CUR=\""), ssid, GF("\",\""), pwd, GF("\""));
|
sendAT(GF("+CWJAP_CUR=\""), ssid, GF("\",\""), pwd, GF("\""));
|
||||||
if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) {
|
if (waitResponse(30000L, GFP(GSM_OK), GF(GSM_NL "FAIL" GSM_NL)) != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user