![](https://www.jesusninoc.com/wp-content/uploads/2024/09/conexion-ble-remota-bombilla.png)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import asyncio from bleak import BleakClient # Replace with your device address DEVICE_ADDRESS = "AAAAAAAA-BBBBBB-33333-55555-asdfasfadsf" async def connect_device(): try: async with BleakClient(DEVICE_ADDRESS) as client: print(f"Connected to {client.address}") # Optionally, you can check if the device is connected if client.is_connected: print("Device is connected.") else: print("Device is not connected.") except Exception as e: print(f"Failed to connect to the device: {e}") if __name__ == "__main__": asyncio.run(connect_device()) |