Created
November 8, 2021 14:48
-
-
Save adrianlzt/92b46d4a86844a0caeda625d49d22a12 to your computer and use it in GitHub Desktop.
Get services, characteristics and descriptors for a BLE device
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 characters
| """ | |
| Get services, characteristics and descriptors for a BLE device | |
| """ | |
| import sys | |
| import asyncio | |
| import platform | |
| from bleak import BleakClient | |
| ADDRESS = ( "20:C3:8F:8A:5B:EA") | |
| async def main(address: str): | |
| async with BleakClient(address) as client: | |
| svcs = await client.get_services() | |
| print("Services:") | |
| for service in svcs: | |
| print(f"SERVICE: {service}") | |
| for c in service.characteristics: | |
| print(f" CHARACTERISTIC: uuid: {c.uuid}, handle: {c.handle}, properties: {c.properties}") | |
| for d in c.descriptors: | |
| print(f" DESCRIPTOR: {d}") | |
| print("\n") | |
| if __name__ == "__main__": | |
| asyncio.run(main(sys.argv[1] if len(sys.argv) == 2 else ADDRESS)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment