diff --git a/ports/nrf/drivers/bluetooth/ble_uart.c b/ports/nrf/drivers/bluetooth/ble_uart.c index 0e0e147c2..f10e6d4d7 100644 --- a/ports/nrf/drivers/bluetooth/ble_uart.c +++ b/ports/nrf/drivers/bluetooth/ble_uart.c @@ -31,6 +31,7 @@ #include "ringbuffer.h" #include "mphalport.h" #include "lib/utils/interrupt_char.h" +#include "py/runtime.h" #include "wdt.h" #if MICROPY_PY_BLE_NUS @@ -93,15 +94,21 @@ static ubluepy_advertise_data_t m_adv_data_uart_service; static ubluepy_advertise_data_t m_adv_data_eddystone_url; #endif // BLUETOOTH_WEBBLUETOOTH_REPL +static void relax(void) { + mp_handle_pending(); + wdt_feed(false); + __WFI(); +} + int mp_hal_stdin_rx_chr(void) { wdt_feed(false); while (!ble_uart_enabled()) { // wait for connection - wdt_feed(false); + relax(); } while (isBufferEmpty(mp_rx_ring_buffer)) { - wdt_feed(false); + relax(); } uint8_t byte;