Created
July 30, 2025 10:58
-
-
Save adrianlzt/00b03c5e7ceba5111f2024f4af9ac7ac to your computer and use it in GitHub Desktop.
Revisions
-
adrianlzt created this gist
Jul 30, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ #!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.10" # dependencies = [ # "bleak", # ] # [tool.uv] # exclude-newer = "2025-07-03T00:00:00Z" # /// import asyncio import sys from bleak import BleakClient async def main(mac_address): def disconnected_callback(client): print("Disconnected callback called") async with BleakClient( mac_address, timeout=15, disconnected_callback=disconnected_callback ) as client: print(f"Connected to {mac_address}") print("Services and characteristics:") for service in client.services: print(f" Service: {service}") for char in service.characteristics: print( f" Characteristic: {char}, properties: {char.properties}" ) # Para poder lanzarlo manualmente if __name__ == "__main__": if len(sys.argv) < 2: print(f"Usage: {sys.argv[0]} <MAC_ADDRESS>") sys.exit(1) mac = sys.argv[1] asyncio.run(main(mac))