# bleak.backends.p4android package

## Submodules

## bleak.backends.p4android.client module

BLE Client for python-for-android

class bleak.backends.p4android.client.BleakClientP4Android(address_or_ble_device: BLEDevice | str, services: set[UUID] | None, **kwargs)

  Bases: `BaseBleakClient`

  A python-for-android Bleak Client

  Parameters:

    - address_or_ble_device – The Bluetooth address of the BLE peripheral to connect to or the `BLEDevice` object representing it.

    - services – Optional set of services UUIDs to filter.

  async connect(pair: bool, **kwargs) → None

    Connect to the specified GATT server.

  async disconnect() → None

    Disconnect from the specified GATT server.

  property is_connected: bool

    Check connection status between this client and the server.

    Returns:

      Boolean representing connection status.

  property mtu_size: int

    Gets the negotiated MTU.

  async pair(*args, **kwargs) → None

    Pair with the peripheral.

    You can use ConnectDevice method if you already know the MAC address of the device. Else you need to StartDiscovery, Trust, Pair and Connect in sequence.

  async read_gatt_char(characteristic: BleakGATTCharacteristic, *, use_cached: bool = False, **kwargs: Any) → bytearray

    Perform read operation on the specified GATT characteristic.

    Parameters:

      characteristic (BleakGATTCharacteristic) – The characteristic to read from.

    Returns:

      (bytearray) The read data.

  async read_gatt_descriptor(descriptor: BleakGATTDescriptor, *, use_cached: bool = False, **kwargs: Any) → bytearray

    Perform read operation on the specified GATT descriptor.

    Parameters:

      - descriptor – The descriptor to read from.

      - use_cached – Whether to use cached value.

    Returns:

      The read data.

  async start_notify(characteristic: BleakGATTCharacteristic, callback: Callable[[bytearray], None], **kwargs) → None

    Activate notifications/indications on a characteristic.

  async stop_notify(characteristic: BleakGATTCharacteristic) → None

    Deactivate notification/indication on a specified characteristic.

    Parameters:

      characteristic (BleakGATTCharacteristic) – The characteristic to deactivate notification/indication on,.

  async unpair() → None

    Unpair with the peripheral.

  async write_gatt_char(characteristic: BleakGATTCharacteristic, data: bytearray, response: bool) → None

    Perform a write operation on the specified GATT characteristic.

    Parameters:

      - characteristic – The characteristic to write to.

      - data – The data to send.

      - response – If write-with-response operation should be done.

  async write_gatt_descriptor(desc_specifier: BleakGATTDescriptor | str | UUID, data: bytearray) → None

    Perform a write operation on the specified GATT descriptor.

    Parameters:

      - desc_specifier (BleakGATTDescriptor, str or UUID) – The descriptor to write to, specified by either UUID or directly by the BleakGATTDescriptor object representing it.

      - data (bytes or bytearray) – The data to send.

## bleak.backends.p4android.defs module

class bleak.backends.p4android.defs.ScanFailed(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

  Bases: `IntEnum`

## bleak.backends.p4android.scanner module

class bleak.backends.p4android.scanner.BleakScannerP4Android(detection_callback: Callable[[BLEDevice, AdvertisementData], Coroutine[Any, Any, None] | None] | None, service_uuids: list[str] | None, scanning_mode: Literal['active', 'passive'], **kwargs)

  Bases: `BaseBleakScanner`

  The python-for-android Bleak BLE Scanner.

  Parameters:

    - detection_callback – Optional function that will be called each time a device is discovered or advertising data has changed.

    - service_uuids – Optional list of service UUIDs to filter on. Only advertisements containing this advertising data will be received. Specifying this also enables scanning while the screen is off on Android.

    - scanning_mode – Set to `"passive"` to avoid the `"active"` scanning mode.

  async start() → None

    Start scanning for devices

  async stop() → None

    Stop scanning for devices

## bleak.backends.p4android.utils module

class bleak.backends.p4android.utils.AsyncJavaCallbacks(*args: Any, **kwargs: Any)

  Bases: `PythonJavaClass`

  async perform_and_wait(dispatchApi, dispatchParams, resultApi, resultExpected=(), unless_already=False, return_indicates_status=True)

## Module contents