Merge pull request #4990 from akosthekiss/ble-uart-flush

Add flush to the BLE UART Service
pull/5217/head
Jimmy Brisson 2017-09-28 14:01:15 -05:00 committed by GitHub
commit f0a10750d7
1 changed files with 13 additions and 0 deletions

View File

@ -140,6 +140,19 @@ public:
return write(str, strlen(str));
}
/**
* Flush sendBuffer, i.e., forcefully write its contents to the UART RX
* characteristic even if the buffer is not full.
*/
void flush() {
if (ble.getGapState().connected) {
if (sendBufferIndex != 0) {
ble.gattServer().write(getRXCharacteristicHandle(), static_cast<const uint8_t *>(sendBuffer), sendBufferIndex);
sendBufferIndex = 0;
}
}
}
/**
* Override for Stream::_putc().
* @param c