nRF52 BLE improvements

This commit is contained in:
jacob.eva 2024-10-10 14:40:57 +01:00
parent 8639765679
commit 03893c2793
No known key found for this signature in database
GPG key ID: 0B92E083BBCCAA1E
3 changed files with 173 additions and 119 deletions

View file

@ -668,6 +668,19 @@ void serial_write(uint8_t byte) {
Serial.write(byte);
} else {
SerialBT.write(byte);
#if MCU_VARIANT == MCU_NRF52 && HAS_BLE
// This ensures that the TX buffer is flushed after a frame is queued in serial.
// serial_in_frame is used to ensure that the flush only happens at the end of the frame
if (serial_in_frame && byte == FEND) {
SerialBT.flushTXD();
serial_in_frame = false;
}
else if (!serial_in_frame && byte == FEND) {
serial_in_frame = true;
}
#endif
}
#else
Serial.write(byte);