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.

Parameters:
  • 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(nbytes=None)

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
readinto(buf)

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)
readline()

Read a line, ending in a newline character.

Returns:the line read
Return type:int or None
in_waiting

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

reset_input_buffer()

Discard any unread characters in the input buffer.

deinit()

Disable permanently.