mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Cut up log lines into 20-byte BLE packets
This commit is contained in:
parent
3386db1b80
commit
d4fbc17d43
1 changed files with 12 additions and 2 deletions
|
|
@ -31,8 +31,18 @@ class BLELogInterface : public Print, BLEServerCallbacks {
|
|||
|
||||
void flushLine() {
|
||||
if (_line_len > 0 && _connected) {
|
||||
_tx_char->setValue((uint8_t*)_line_buf, _line_len);
|
||||
_tx_char->notify();
|
||||
// BLE notifications are capped at ATT_MTU-3 bytes; MTU negotiation is not
|
||||
// guaranteed, so always chunk at 20 bytes (the safe minimum) to ensure the
|
||||
// full line is delivered regardless of the negotiated MTU.
|
||||
const int CHUNK = 20;
|
||||
int offset = 0;
|
||||
while (offset < _line_len) {
|
||||
int n = _line_len - offset;
|
||||
if (n > CHUNK) n = CHUNK;
|
||||
_tx_char->setValue((uint8_t*)_line_buf + offset, n);
|
||||
_tx_char->notify();
|
||||
offset += n;
|
||||
}
|
||||
}
|
||||
_line_len = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue