Skip to content

Commit b4a9684

Browse files
mishafarmsme-no-dev
andcommitted
Fix SerialBT.flush (espressif#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 <[email protected]>
1 parent 1977370 commit b4a9684

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libraries/BluetoothSerial/src/BluetoothSerial.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,11 @@ size_t BluetoothSerial::write(const uint8_t *buffer, size_t size)
660660

661661
void BluetoothSerial::flush()
662662
{
663-
while(read() >= 0){}
663+
if (_spp_tx_queue != NULL){
664+
while(uxQueueMessagesWaiting(_spp_tx_queue) > 0){
665+
delay(5);
666+
}
667+
}
664668
}
665669

666670
void BluetoothSerial::end()

0 commit comments

Comments
 (0)