Cross-platform Bluetooth Low Energy GATT client library for asynchronous BLE communication
Overall
score
97%
A robust Bluetooth Low Energy device connection manager that implements comprehensive error handling for BLE operations.
The system must check if Bluetooth is available before attempting any BLE operations.
The system must discover BLE devices and handle discovery failures appropriately.
The system must read device characteristics and handle characteristic-related errors.
The system must handle base BLE errors that don't fall into specific categories.
@generates
from typing import Optional, Dict, Any
def check_bluetooth_availability() -> Dict[str, Any]:
"""
Check if Bluetooth is available on the system.
Returns:
Dict with 'available' (bool) and optionally 'error_type' (str) keys.
Error types: 'no_adapter', 'powered_off', 'permission_denied'
"""
pass
def find_device_by_address(address: str, timeout: float = 5.0) -> Optional[Dict[str, str]]:
"""
Find a BLE device by its address.
Args:
address: The Bluetooth device address to find
timeout: Discovery timeout in seconds
Returns:
Dict with device info ('address', 'name') if found, None if not found
"""
pass
def read_device_characteristic(address: str, characteristic_uuid: str) -> Dict[str, Any]:
"""
Connect to a device and read a characteristic value.
Args:
address: The Bluetooth device address
characteristic_uuid: UUID of the characteristic to read
Returns:
Dict with 'success' (bool), and either 'value' (bytes) or 'error' (str)
Error types: 'characteristic_not_found', 'ble_error', 'connection_failed'
"""
passProvides cross-platform Bluetooth Low Energy support with comprehensive exception handling.
Install with Tessl CLI
npx tessl i tessl/pypi-bleakdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9