Skip to content

After reading gatt characteristic by aioble, is it necessary to disconnect by hand? #707

@rivendell1984

Description

@rivendell1984

Hello,
I'm using aioble like the sample, and I want to disconnect immediately after reading the value.

    try:
        connection = await device.connect()
    except asyncio.TimeoutError:
        print("Timeout during connection")
        return

    async with connection:
        try:
            temp_service = await connection.service(_ENV_SENSE_UUID)
            temp_characteristic = await temp_service.characteristic(_ENV_SENSE_TEMP_UUID)
            temp = await temp_characteristic.read()
        except asyncio.TimeoutError:
            print("Timeout discovering services/characteristics")
            return

    #is it necessary to disconnect it like this? 
    try:
        await connection.disconnect(timeout_ms=1000)
     except asyncio.TimeoutError:
         print("Timeout disconnected services/characteristics")
        return

When I use await connection.disconnect(timeout_ms=1000), I always get TimeoutError
So, what's the good way to disconnect immediately?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions