Skip to content

Commit b0f3ae5

Browse files
committed
extmod/modwebrepl: Add rate-limiting workaround for broken network drivers.
Like ESP8266 has.
1 parent 8811b0a commit b0f3ae5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

extmod/modwebrepl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
#include "py/runtime.h"
3535
#include "py/stream.h"
3636
#include "py/builtin.h"
37+
#ifdef MICROPY_PY_WEBREPL_DELAY
38+
#include "py/mphal.h"
39+
#endif
3740
#include "extmod/modwebsocket.h"
3841

3942
#if MICROPY_PY_WEBREPL
@@ -221,6 +224,14 @@ STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t size, int
221224
DEBUG_printf("webrepl: Finished writing file\n");
222225
write_webrepl_resp(self->sock, 0);
223226
}
227+
228+
#ifdef MICROPY_PY_WEBREPL_DELAY
229+
// Some platforms may have broken drivers and easily gets
230+
// overloaded with modest traffic WebREPL file transfers
231+
// generate. The basic workaround is a crude rate control
232+
// done in such way.
233+
mp_hal_delay_ms(MICROPY_PY_WEBREPL_DELAY);
234+
#endif
224235
}
225236

226237
return -2;

0 commit comments

Comments
 (0)