mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
fix(serial): no 300 ms stall per frame with no USB host
With the phone not connected, every frame (each packet heard, each advert) went to the USB port. With nobody holding it open the core either drops the bytes or lets its buffer fill, and streamWriteUntil() then spun out its whole timeout. Skip the write when the native USB Serial has no host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,13 @@ size_t ArduinoSerialInterface::writeFrame(const uint8_t src[], size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A native USB port with no host holding it open: the core drops the bytes
|
||||
// (nRF52 TinyUSB, ESP32 USBCDC) or lets its buffer fill, and either way
|
||||
// streamWriteUntil() would spin out the whole timeout on every frame -- the
|
||||
// loop stalled 300 ms per packet heard while no phone was connected. A UART
|
||||
// bridge's Serial always reads true, so those boards are unaffected.
|
||||
if (_serial == (Stream*)&Serial && !Serial) return 0;
|
||||
|
||||
uint8_t hdr[3];
|
||||
hdr[0] = '>';
|
||||
hdr[1] = (len & 0xFF); // LSB
|
||||
|
||||
Reference in New Issue
Block a user