@@ -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 (" \t sent " ));
0 commit comments