mirror of
https://github.com/esphome/esphome.git
synced 2026-03-24 23:25:00 +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,7 +71,10 @@ bool BLENUS::read_array(uint8_t *data, size_t len) {
|
||||
this->has_peek_ = false;
|
||||
data++;
|
||||
if (--len == 0) { // Decrement len first, then check it...
|
||||
return true; // No more to read
|
||||
#ifdef USE_UART_DEBUGGER
|
||||
this->debug_callback_.call(uart::UART_DIRECTION_RX, this->peek_buffer_);
|
||||
#endif
|
||||
return true; // No more to read
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +104,10 @@ size_t BLENUS::available() {
|
||||
}
|
||||
|
||||
uart::FlushResult BLENUS::flush() {
|
||||
constexpr uint32_t timeout_5sec = 5000;
|
||||
constexpr uint32_t timeout_500ms = 500;
|
||||
uint32_t start = millis();
|
||||
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");
|
||||
return uart::FlushResult::TIMEOUT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user