mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #4990 from akosthekiss/ble-uart-flush
Add flush to the BLE UART Servicepull/5217/head
commit
f0a10750d7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue