mirror of
https://github.com/esphome/esphome.git
synced 2026-05-30 07:16:11 +08:00
[ble_nus] make ble_nus timeout shorter than watchdog (#14619)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
This commit is contained in:
@@ -71,6 +71,9 @@ bool BLENUS::read_array(uint8_t *data, size_t len) {
|
|||||||
this->has_peek_ = false;
|
this->has_peek_ = false;
|
||||||
data++;
|
data++;
|
||||||
if (--len == 0) { // Decrement len first, then check it...
|
if (--len == 0) { // Decrement len first, then check it...
|
||||||
|
#ifdef USE_UART_DEBUGGER
|
||||||
|
this->debug_callback_.call(uart::UART_DIRECTION_RX, this->peek_buffer_);
|
||||||
|
#endif
|
||||||
return true; // No more to read
|
return true; // No more to read
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,10 +104,10 @@ size_t BLENUS::available() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uart::FlushResult BLENUS::flush() {
|
uart::FlushResult BLENUS::flush() {
|
||||||
constexpr uint32_t timeout_5sec = 5000;
|
constexpr uint32_t timeout_500ms = 500;
|
||||||
uint32_t start = millis();
|
uint32_t start = millis();
|
||||||
while (atomic_get(&this->tx_status_) != TX_DISABLED && !ring_buf_is_empty(&global_ble_tx_ring_buf)) {
|
while (atomic_get(&this->tx_status_) != TX_DISABLED && !ring_buf_is_empty(&global_ble_tx_ring_buf)) {
|
||||||
if (millis() - start > timeout_5sec) {
|
if (millis() - start > timeout_500ms) {
|
||||||
ESP_LOGW(TAG, "Flush timeout");
|
ESP_LOGW(TAG, "Flush timeout");
|
||||||
return uart::FlushResult::TIMEOUT;
|
return uart::FlushResult::TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user