Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BluetoothSerial::flush() takes too long #9868

Closed
1 task done
vincadrn opened this issue Jun 15, 2024 · 2 comments · Fixed by #9905
Closed
1 task done

BluetoothSerial::flush() takes too long #9868

vincadrn opened this issue Jun 15, 2024 · 2 comments · Fixed by #9905
Assignees
Labels
Type: Feature request Feature request for Arduino ESP32

Comments

@vincadrn
Copy link
Contributor

Related area

Classic Bluetooth

Hardware specification

All ESP32 boards

Is your feature request related to a problem?

For a small but frequent Bluetooth serial data, using delay of 100 ms in flush() degrade the performance very much.

void BluetoothSerial::flush() {
if (_spp_tx_queue != NULL) {
while (uxQueueMessagesWaiting(_spp_tx_queue) > 0) {
delay(100);
}
}
}

Describe the solution you'd like

I'd suggest that the delay is reduced to 1 ms. By using much smaller delay, it can accomodate different kinds of serial data.

Describe alternatives you've considered

Currently I have no alternative approaches in mind that is as efficient and minimal in changes.

Additional context

When I try without using flush() for my project, typically the data is sent in its entirety in about 5 - 20 ms. However, when I try to use flush(), the data would be sent entirely in > 100 ms. For a bigger serial data, the loop in the function would cause other 100 ms of delay(s). To avoid the problem altogether, one can avoid using flush() at all. But then, there is no way to know and make sure that the transmission buffer is cleared.

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.
@me-no-dev
Copy link
Member

As far as I see from the code, the message will not be sent in 100ms, but rather flush() will return after 100ms. delay(2) would be better. Can you please try?

@vincadrn
Copy link
Contributor Author

Yes, sure. I'll raise a PR to address this issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature request Feature request for Arduino ESP32
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants