CharacteristicBuffer – BLE Service incoming values buffer.

Accumulates a Characteristic’s incoming values in a FIFO buffer.

class _bleio.CharacteristicBuffer(characteristic, *, timeout=1, buffer_size=64)

Monitor the given Characteristic. Each time a new value is written to the Characteristic add the newly-written bytes to a FIFO buffer.

  • characteristic (Characteristic) – The Characteristic to monitor. It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic in a remote Service that a Central has connected to.
  • timeout (int) – the timeout in seconds to wait for the first character and between subsequent characters.
  • buffer_size (int) – Size of ring buffer that stores incoming data coming from client. Must be >= 1.

Read characters. If nbytes is specified then read at most that many bytes. Otherwise, read everything that arrives until the connection times out. Providing the number of bytes expected is highly recommended because it will be faster.

Returns:Data read
Return type:bytes or None

Read bytes into the buf. Read at most len(buf) bytes.

Returns:number of bytes read and stored into buf
Return type:int or None (on a non-blocking error)

Read a line, ending in a newline character.

Returns:the line read
Return type:int or None

The number of bytes in the input buffer, available to be read


Discard any unread characters in the input buffer.


Disable permanently.