Skip to content

Commit fefef0d

Browse files
author
Veijo Pesonen
committed
Truncates TCP stream and NACKs UDP datagram when sending too much data
ESP8266 maximum packet size when sending is 2048 bytes.
1 parent c0f9e65 commit fefef0d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/wifi/esp8266-driver/ESP8266/ESP8266.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,14 @@ bool ESP8266::dns_lookup(const char *name, char *ip)
549549
nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
550550
{
551551
// +CIPSEND supports up to 2048 bytes at a time
552-
amount = amount > 2048 ? 2048 : amount;
552+
// Data stream can be truncated
553+
if (amount > 2048 && _sock_i[id].proto == NSAPI_TCP) {
554+
amount = 2048;
555+
// Datagram must stay intact
556+
} else if (amount > 2048 && _sock_i[id].proto == NSAPI_UDP) {
557+
tr_debug("UDP datagram maximum size is 2048");
558+
return NSAPI_ERROR_PARAMETER;
559+
}
553560

554561
//May take a second try if device is busy
555562
for (unsigned i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)