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.- deinit()
Override this method to do any explicit cleanup necessary on connection close.
circuitpython
This module provides Services defined by CircuitPython. Out of date.
- 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.- deinit()
The characteristic buffers must be deinitialized when no longer needed. Otherwise they will leak storage.
- 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
. Ifnbytes
is specified then read at most that many bytes. Otherwise, read at mostlen(buf)
bytes.- Returns:
number of bytes read and stored into
buf
- Return type:
int or None (on a non-blocking error)