Skip to content

Commit 710e762

Browse files
committed
AT2 support: small improvements
- EspATDrv.init doesn't fail for SYSSTORE (for CheckFirmware.ino) - WiFi.fwVersion size to 15 for AT 2 version strings - possibility to enable AT 2 with -D
1 parent 58c0982 commit 710e762

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/WiFi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "utility/EspAtDrv.h"
2222

2323
// this statics are removed by compiler if not used
24-
char WiFiClass::fwVersion[10] = {0};
24+
char WiFiClass::fwVersion[15] = {0};
2525
char WiFiClass::ssid[33] = {0};
2626
char WiFiClass::name[33] = {0}; // hostname
2727
WiFiApData WiFiClass::apDataInternal[WIFIESPAT_INTERNAL_AP_LIST_SIZE];

src/utility/EspAtDrv.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,17 @@ bool EspAtDrvClass::reset(int8_t resetPin) {
9696
}
9797
if (!simpleCommand(PSTR("ATE0")) || // turn off echo. must work
9898
!simpleCommand(PSTR("AT+CIPMUX=1")) || // Enable multiple connections.
99-
#ifndef WIFIESPAT1 //AT2
100-
!simpleCommand(PSTR("AT+SYSSTORE=0")) || // our default is persistent false
101-
#endif
10299
!simpleCommand(PSTR("AT+CIPRECVMODE=1"))) // Set TCP Receive Mode - passive
103100
return false;
104101

102+
#ifndef WIFIESPAT1 //AT2
103+
if (!simpleCommand(PSTR("AT+SYSSTORE=0"))) {// our default is persistent false
104+
persistent = true;
105+
LOG_WARN_PRINT_PREFIX();
106+
LOG_WARN_PRINTLN(F("Error setting store mode. Is the firmware AT2?"));
107+
}
108+
#endif
109+
105110
// read default wifi mode
106111
cmd->print(F("AT+CWMODE?"));
107112
if (!sendCommand(PSTR("+CWMODE")))
@@ -1093,7 +1098,7 @@ size_t EspAtDrvClass::sendData(uint8_t linkId, Stream& file, const char* udpHost
10931098
lastErrorCode = EspAtDrvError::LINK_NOT_ACTIVE;
10941099
return 0;
10951100
}
1096-
size_t len = 0;
1101+
uint32_t len = 0;
10971102
while (file.available()) {
10981103
size_t l = file.available();
10991104
if (l > MAX_SEND_LENGTH) {
@@ -1109,22 +1114,32 @@ size_t EspAtDrvClass::sendData(uint8_t linkId, Stream& file, const char* udpHost
11091114
cmd->print(F("\","));
11101115
cmd->print(udpPort);
11111116
}
1112-
if (!sendCommand(PSTR(">")))
1117+
if (!sendCommand(PSTR(">"))) {
1118+
LOG_ERROR_PRINT_PREFIX();
1119+
LOG_ERROR_PRINT(F("CIPSEND failed at "));
1120+
LOG_ERROR_PRINTLN(len);
1121+
lastErrorCode = EspAtDrvError::SEND;
11131122
return 0;
1123+
}
11141124
for (size_t i = 0; i < l; i++) {
11151125
serial->write(file.read());
11161126
}
11171127
if (!readRX(PSTR("Recv ")))
11181128
return 0;
1119-
len += atol(buffer + strlen("Recv "));
1120-
if (!readRX(PSTR("SEND "))) // SEND OK or SEND FAIL
1121-
return 0;
1122-
if (strcmp_P(buffer + strlen("SEND "), OK) != 0) {// FAIL
1129+
size_t sl = atol(buffer + strlen("Recv "));
1130+
len += sl;
1131+
if (!readRX(PSTR("SEND ")) || strcmp_P(buffer + strlen("SEND "), OK) != 0) {// FAIL
11231132
LOG_ERROR_PRINT_PREFIX();
1124-
LOG_ERROR_PRINTLN(F("failed to send data"));
1133+
LOG_ERROR_PRINT(F("failed to send data at "));
1134+
LOG_ERROR_PRINTLN(len);
11251135
lastErrorCode = EspAtDrvError::SEND;
11261136
return 0;
11271137
}
1138+
if (l == MAX_SEND_LENGTH && sl < MAX_SEND_LENGTH) {
1139+
LOG_WARN_PRINT_PREFIX();
1140+
LOG_WARN_PRINT(F("Retardment of sending data at "));
1141+
LOG_WARN_PRINTLN(len);
1142+
}
11281143
}
11291144
LOG_INFO_PRINT_PREFIX();
11301145
LOG_INFO_PRINT(F("\tsent "));

src/utility/EspAtDrvTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
#include <stddef.h>
2424

25+
#ifndef WIFIESPAT2 // for -D
2526
#define WIFIESPAT1
27+
#endif
2628

2729
const uint8_t WIFIESPAT_LINKS_COUNT = 5;
2830
const uint8_t WIFIESPAT_NO_LINK = 255;

0 commit comments

Comments
 (0)