services

This module provides the top level Service definition.

class Service(*, service: Service | None = None, secondary: bool = False, **initial_values)

Top level Service class that handles the hard work of binding to a local or remote service.

Providers of a local service should instantiate their Service with service=None, the default. The local Service’s characteristics will be lazily made available to clients as they are used locally. In other words, a characteristic won’t be available to remote clients until it has been read or written locally.

To use a remote Service, get the item with the key of the Service type on the BLEConnection. For example, connection[UartService] will return the UartService instance for the connection’s peer.

property remote: bool

True if the service is provided by a peer and accessed remotely.

circuitpython

This module provides Services defined by CircuitPython. Out of date.

class CircuitPythonUUID(uuid16: int)

UUIDs with the CircuitPython base UUID.

class CircuitPythonService(*, service: Service | None = None, secondary: bool = False, **initial_values)

Core CircuitPython service that allows for file modification and REPL access. Unimplemented.

nordic

This module provides Services used by Nordic Semiconductors.

class UARTService(service: _bleio.Service | None = None)

Provide UART-like functionality via the Nordic NUS service.

See examples/ble_uart_echo_test.py for a usage example.

read(nbytes: int | None = None) bytes | 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: WriteableBuffer, nbytes: int | None = None) int | None

Read bytes into the buf. If nbytes is specified then read at most that many bytes. Otherwise, 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() bytes | None

Read a line, ending in a newline character.

Returns:

the line read

Return type:

bytes or None

property in_waiting: int

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

reset_input_buffer() None

Discard any unread characters in the input buffer.

write(buf: ReadableBuffer) None

Write a buffer of bytes.