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?