From b4a9684a7438e0dd1a425703982b5a65156a3072 Mon Sep 17 00:00:00 2001 From: mishafarms Date: Mon, 20 Jan 2020 12:34:57 -0800 Subject: [PATCH] Fix SerialBT.flush (#3579) * Fix flush flush should not flush the read buffer, it should wait till all output is drained from the write buffer. * Update BluetoothSerial.cpp Co-authored-by: Me No Dev --- libraries/BluetoothSerial/src/BluetoothSerial.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index 5b554f0d..a52e48d8 100755 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -660,7 +660,11 @@ size_t BluetoothSerial::write(const uint8_t *buffer, size_t size) void BluetoothSerial::flush() { - while(read() >= 0){} + if (_spp_tx_queue != NULL){ + while(uxQueueMessagesWaiting(_spp_tx_queue) > 0){ + delay(5); + } + } } void BluetoothSerial::end()