File tree Expand file tree Collapse file tree 5 files changed +14
-2
lines changed
libraries/WiFi/src/include Expand file tree Collapse file tree 5 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ extern void interrupts();
21
21
#define MEM_LIBC_MALLOC 0
22
22
23
23
#define MEM_ALIGNMENT 4
24
- #define MEM_SIZE 4000
24
+ #define MEM_SIZE 8192
25
25
#define MEMP_NUM_TCP_SEG 32
26
26
#define MEMP_NUM_ARP_QUEUE 10
27
27
#define PBUF_POOL_SIZE 24
Original file line number Diff line number Diff line change @@ -491,6 +491,7 @@ class ClientContext {
491
491
DEBUGV (" :wr %d %d\r\n " , _datalen - _written, _written);
492
492
493
493
bool has_written = false ;
494
+ int scale = 0 ;
494
495
495
496
while (_written < _datalen) {
496
497
if (state () == CLOSED) {
@@ -501,6 +502,10 @@ class ClientContext {
501
502
{
502
503
LWIPMutex m; // Block the timer sys_check_timeouts call, just for this call
503
504
next_chunk_size = std::min ((size_t )tcp_sndbuf (_pcb), remaining);
505
+ // Potentially reduce transmit size if we are tight on memory, but only if it doesn't return a 0 chunk size
506
+ if (next_chunk_size > (size_t )(1 << scale)) {
507
+ next_chunk_size >>= scale;
508
+ }
504
509
}
505
510
if (!next_chunk_size) {
506
511
break ;
@@ -531,6 +536,13 @@ class ClientContext {
531
536
if (err == ERR_OK) {
532
537
_written += next_chunk_size;
533
538
has_written = true ;
539
+ } else if (err == ERR_MEM) {
540
+ if (scale < 4 ) {
541
+ // Retry sending at 1/2 the chunk size
542
+ scale ++;
543
+ } else {
544
+ break ;
545
+ }
534
546
} else {
535
547
// ERR_MEM(-1) is a valid error meaning
536
548
// "come back later". It leaves state() opened
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ extern void interrupts();
21
21
#define MEM_LIBC_MALLOC 0
22
22
23
23
#define MEM_ALIGNMENT 4
24
- #define MEM_SIZE 4000
24
+ #define MEM_SIZE 8192
25
25
#define MEMP_NUM_TCP_SEG 32
26
26
#define MEMP_NUM_ARP_QUEUE 10
27
27
#define PBUF_POOL_SIZE 24
You can’t perform that action at this time.
0 commit comments