Truncates TCP stream and NACKs UDP datagram when sending too much data

ESP8266 maximum packet size when sending is 2048 bytes.
pull/8841/head
Veijo Pesonen 2018-11-23 12:22:20 +02:00
parent c0f9e65af6
commit fefef0d855
1 changed files with 8 additions and 1 deletions

View File

@ -549,7 +549,14 @@ bool ESP8266::dns_lookup(const char *name, char *ip)
nsapi_error_t ESP8266::send(int id, const void *data, uint32_t amount)
{
// +CIPSEND supports up to 2048 bytes at a time
amount = amount > 2048 ? 2048 : amount;
// Data stream can be truncated
if (amount > 2048 && _sock_i[id].proto == NSAPI_TCP) {
amount = 2048;
// Datagram must stay intact
} else if (amount > 2048 && _sock_i[id].proto == NSAPI_UDP) {
tr_debug("UDP datagram maximum size is 2048");
return NSAPI_ERROR_PARAMETER;
}
//May take a second try if device is busy
for (unsigned i = 0; i < 2; i++) {