From ab96650b6a63534cae1ce740f72111114cd66ecf Mon Sep 17 00:00:00 2001 From: mishafarms Date: Tue, 17 Dec 2019 08:59:30 -0800 Subject: [PATCH 1/2] Fix flush flush should not flush the read buffer, it should wait till all output is drained from the write buffer. --- 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 88cfad0693c..4629eb3d9ab 100755 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -652,7 +652,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(50); + } + } } void BluetoothSerial::end() From f859a91689a596e019593e97f4b1f7f82bd41524 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Mon, 20 Jan 2020 22:20:37 +0200 Subject: [PATCH 2/2] Update BluetoothSerial.cpp --- libraries/BluetoothSerial/src/BluetoothSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index 4629eb3d9ab..f1deb17b3d6 100755 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -654,7 +654,7 @@ void BluetoothSerial::flush() { if (_spp_tx_queue != NULL){ while(uxQueueMessagesWaiting(_spp_tx_queue) > 0){ - delay(50); + delay(5); } } }