question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error "Attempt to disconnect device failed: Connection was closed cleanly." causes async client context to never exit

See original GitHub issue
  • bleak version: 0.6.4
  • Python version: 3.7.3
  • Operating System: Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l GNU/Linux / Raspbian GNU/Linux 10 (buster)
  • BlueZ version (bluetoothctl -v) in case of Linux: bluetoothctl: 5.50

Description

I’ve written some sample code to demonstrate:

import sys
import asyncio
import logging
from bleak import BleakClient

logging.root.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
FORMAT = "%(asctime)-15s %(name)-8s %(levelname)s: %(message)s"
handler.setFormatter(logging.Formatter(fmt=FORMAT))
logging.root.addHandler(handler)

async def run(loop):
    print("Running")
    async with BleakClient("9B0F0A71-568C-4DB5-9002-F1D09B240D0A" if sys.platform == "darwin" else "00:1c:97:1a:a0:2f", loop=loop) as client:
        print("Created")
        await client.is_connected()
        print("Connected")
        await asyncio.sleep(3)
        await client.disconnect()
        print("Disconnected")
    print("Done")

loop = asyncio.get_event_loop()
loop.run_until_complete(run(loop))
loop.run_forever()

So, I’m connecting to an Acaia Lunar scale, or rather disconnecting from one, and on Linux, disconnecting gives me a weird error (ERROR:bleak.backends.bluezdbus.client:Attempt to disconnect device failed: Connection was closed cleanly.) and then the BleakClient context never exits. On OS X it works fine.

What I Did

Output on OS X:

/Users/magnusnordlander/Developer/silvia-pi/venv/bin/python /Users/magnusnordlander/Developer/silvia-pi/BleakTest.py
2020-06-14 23:33:20,364 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Bluetooth powered on
Running
2020-06-14 23:33:20,381 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 3D963F76-BE4B-4600-ADA1-C289B2E476A6: Unknown @ RSSI: -80 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,382 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 3D963F76-BE4B-4600-ADA1-C289B2E476A6: Unknown @ RSSI: -80 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,392 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 2865E8B9-A672-420A-8692-E720493E11F9: Unknown @ RSSI: -72 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,394 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 2865E8B9-A672-420A-8692-E720493E11F9: Unknown @ RSSI: -72 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
2020-06-14 23:33:20,400 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 3FFCE2ED-2AC5-4FD8-84FF-0F4E8802CFF2: Unknown @ RSSI: -86 (kCBAdvData <nsdict_keys(['kCBAdvDataManufacturerData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,408 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 9B8CC7D2-EF3B-46E9-95A2-0360F1DD7073: HK Onyx Studio 4 @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,411 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 31CBF837-B976-4FFC-A84B-DD2A86016A8C: Unknown @ RSSI: -68 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,413 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device E33DEB5D-6ECC-4052-A262-49627F7B7356: Unknown @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,414 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device E33DEB5D-6ECC-4052-A262-49627F7B7356: Unknown @ RSSI: -82 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,418 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 50785798-19F9-4EF0-B0BE-59AA822B5351: Unknown @ RSSI: -49 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,423 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 7346DF6F-6953-4D59-94C7-D0C0659D220D: Unknown @ RSSI: -75 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,424 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 7346DF6F-6953-4D59-94C7-D0C0659D220D: Unknown @ RSSI: -75 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,427 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 522F6BC9-7E4A-4F7D-9AA2-7BE1923B8049: Unknown @ RSSI: -94 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,429 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 522F6BC9-7E4A-4F7D-9AA2-7BE1923B8049: Unknown @ RSSI: -94 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
2020-06-14 23:33:20,491 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device FA2EE6B3-9775-442A-92BA-BC0C0B49BADB: Unknown @ RSSI: -52 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,492 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device FA2EE6B3-9775-442A-92BA-BC0C0B49BADB: Unknown @ RSSI: -52 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,508 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 9B8CC7D2-EF3B-46E9-95A2-0360F1DD7073: HK Onyx Studio 4 @ RSSI: -85 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,768 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 61C334B4-CB32-40FF-881A-EE12EE81ADE5: ScootyPuffJr @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,771 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 61C334B4-CB32-40FF-881A-EE12EE81ADE5: ScootyPuffJr @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,773 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 47F3B9C7-C9EC-4BD0-B7F7-4B4A8DF1449D: Unknown @ RSSI: -55 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,774 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 47F3B9C7-C9EC-4BD0-B7F7-4B4A8DF1449D: Unknown @ RSSI: -55 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,777 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 9B0F0A71-568C-4DB5-9002-F1D09B240D0A: ACAIAL1A02F @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,778 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 9B0F0A71-568C-4DB5-9002-F1D09B240D0A: ACAIAL1A02F @ RSSI: -41 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,782 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 4370BF20-66B9-411D-9B80-748D65A15F7D: Unknown @ RSSI: -87 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
2020-06-14 23:33:20,786 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device B366E7AC-66B9-4378-983F-AD2056200551: Unknown @ RSSI: -70 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,788 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device B366E7AC-66B9-4378-983F-AD2056200551: Unknown @ RSSI: -70 (kCBAdvData <nsdict_keys(['kCBAdvDataLocalName', 'kCBAdvDataChannel', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,798 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 0C9020FD-EC93-485E-B433-B569D956A84E: Unknown @ RSSI: -99 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
2020-06-14 23:33:20,801 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 28BDF942-4376-4177-AE71-F41929F8585B: Unknown @ RSSI: -86 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,802 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 28BDF942-4376-4177-AE71-F41929F8585B: Unknown @ RSSI: -86 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,805 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 8EA153A3-01F3-49FF-AA04-4468F5BD43D8: Unknown @ RSSI: -74 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,807 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 756EA73D-4E2A-40C4-86F0-F67A4EE5FDD4: Unknown @ RSSI: -60 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,808 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 756EA73D-4E2A-40C4-86F0-F67A4EE5FDD4: Unknown @ RSSI: -60 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:20,812 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 2790A923-F568-49B9-A068-162FFB76F2C9: Unknown @ RSSI: -85 (kCBAdvData <nsdict_keys(['kCBAdvDataServiceData', 'kCBAdvDataChannel', 'kCBAdvDataServiceUUIDs', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:20,823 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 483E4E07-7E90-40B2-A2B9-52181F1EBBC6: Unknown @ RSSI: -94 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData'])>)
2020-06-14 23:33:21,069 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device B5544443-957C-4F69-B3BE-6A8065B2E3AC: Unknown @ RSSI: -68 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:21,073 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device D1EBD728-958E-48AC-9BBC-551A2D091B67: Unknown @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:21,073 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device D1EBD728-958E-48AC-9BBC-551A2D091B67: Unknown @ RSSI: -88 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:21,091 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 3FFCE2ED-2AC5-4FD8-84FF-0F4E8802CFF2: Unknown @ RSSI: -88 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataLocalName', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:21,108 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 6FFF3E5A-8A89-4CDE-8A06-48DB63D3B73E: Unknown @ RSSI: -74 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:21,109 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 6FFF3E5A-8A89-4CDE-8A06-48DB63D3B73E: Unknown @ RSSI: -74 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:21,687 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 14824B86-9232-4058-838B-573922D9719B: Unknown @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:21,687 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 14824B86-9232-4058-838B-573922D9719B: Unknown @ RSSI: -83 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:22,007 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 7A54AD70-98A1-4D2B-86BB-B28C755D4B34: Unknown @ RSSI: -95 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:22,285 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device E850E162-B0A0-4846-B54A-3F06E3FBB929: Unknown @ RSSI: -95 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:22,304 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 58B94BC4-38C5-4F95-B444-FD90FF6FF3C4: Unknown @ RSSI: -52 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:22,305 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device 58B94BC4-38C5-4F95-B444-FD90FF6FF3C4: Unknown @ RSSI: -52 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:22,318 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device CD5B0066-20E0-4DEE-B2D4-00A57E87E87E: Unknown @ RSSI: -89 (kCBAdvData <nsdict_keys(['kCBAdvDataAppleMfgData', 'kCBAdvDataChannel', 'kCBAdvDataManufacturerData', 'kCBAdvDataTxPowerLevel', 'kCBAdvDataIsConnectable'])>)
2020-06-14 23:33:22,318 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Discovered device CD5B0066-20E0-4DEE-B2D4-00A57E87E87E: Unknown @ RSSI: -88 (kCBAdvData <nsdict_keys(['kCBAdvDataIsConnectable', 'kCBAdvDataChannel'])>)
2020-06-14 23:33:22,367 bleak.backends.corebluetooth.client DEBUG: Connecting to BLE device @ 9B0F0A71-568C-4DB5-9002-F1D09B240D0A
2020-06-14 23:33:22,595 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Successfully connected to device uuid 9B0F0A71-568C-4DB5-9002-F1D09B240D0A
2020-06-14 23:33:22,595 bleak.backends.corebluetooth.PeripheralDelegate WARNING: PeripheralDelegate is not compliant
2020-06-14 23:33:22,595 bleak.backends.corebluetooth.client DEBUG: Retrieving services...
2020-06-14 23:33:22,596 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Services discovered
2020-06-14 23:33:22,597 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 1820
2020-06-14 23:33:22,714 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2020-06-14 23:33:22,714 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A80
2020-06-14 23:33:22,774 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A80
2020-06-14 23:33:22,774 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 180F
2020-06-14 23:33:22,804 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2020-06-14 23:33:22,804 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A19
2020-06-14 23:33:22,834 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A19
2020-06-14 23:33:22,834 bleak.backends.corebluetooth.client DEBUG: Retrieving characteristics for service 180A
2020-06-14 23:33:22,924 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Characteristics discovered
2020-06-14 23:33:22,924 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A25
2020-06-14 23:33:22,925 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A25
2020-06-14 23:33:22,925 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A27
2020-06-14 23:33:22,925 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A27
2020-06-14 23:33:22,926 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A26
2020-06-14 23:33:22,926 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A26
2020-06-14 23:33:22,926 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A28
2020-06-14 23:33:22,927 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A28
2020-06-14 23:33:22,927 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A29
2020-06-14 23:33:22,927 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A29
2020-06-14 23:33:22,927 bleak.backends.corebluetooth.client DEBUG: Retrieving descriptors for characteristic 2A50
2020-06-14 23:33:22,954 bleak.backends.corebluetooth.PeripheralDelegate DEBUG: Descriptor discovered 2A50
Created
Connected
2020-06-14 23:33:25,990 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Peripheral Device disconnected!
Disconnected
2020-06-14 23:33:25,998 bleak.backends.corebluetooth.CentralManagerDelegate DEBUG: Peripheral Device disconnected!
Done

Output on Linux:

pi@raspberrypi:~/silvia-pi $ python3 BleakTest.py 
2020-06-14 22:34:29,738 asyncio  DEBUG: Using selector: EpollSelector
Running
2020-06-14 22:34:30,567 bleak.backends.bluezdbus.discovery INFO: ACAIAL1A02F, 00:1C:97:1A:A0:2F (-76 dBm), Object Path: /org/bluez/hci0/dev_00_1C_97_1A_A0_2F
2020-06-14 22:34:30,765 bleak.backends.bluezdbus.discovery INFO: dev_4C_FE_F6_6F_8A_DB, 4C:FE:F6:6F:8A:DB (-64 dBm), Object Path: /org/bluez/hci0/dev_4C_FE_F6_6F_8A_DB
2020-06-14 22:34:30,927 bleak.backends.bluezdbus.discovery INFO: dev_57_88_DC_DA_3B_AF, 57:88:DC:DA:3B:AF (-59 dBm), Object Path: /org/bluez/hci0/dev_57_88_DC_DA_3B_AF
2020-06-14 22:34:31,009 bleak.backends.bluezdbus.discovery INFO: dev_90_DD_5D_BF_22_F7, 90:DD:5D:BF:22:F7 (-53 dBm), Object Path: /org/bluez/hci0/dev_90_DD_5D_BF_22_F7
2020-06-14 22:34:31,077 bleak.backends.bluezdbus.discovery INFO: dev_DF_6A_B5_DF_5B_A8, DF:6A:B5:DF:5B:A8 (-80 dBm), Object Path: /org/bluez/hci0/dev_DF_6A_B5_DF_5B_A8
2020-06-14 22:34:31,261 bleak.backends.bluezdbus.discovery INFO: dev_78_D5_9A_8E_16_EF, 78:D5:9A:8E:16:EF (-67 dBm), Object Path: /org/bluez/hci0/dev_78_D5_9A_8E_16_EF
2020-06-14 22:34:31,544 bleak.backends.bluezdbus.discovery INFO: dev_FE_D5_74_F7_30_F1, FE:D5:74:F7:30:F1 (-73 dBm), Object Path: /org/bluez/hci0/dev_FE_D5_74_F7_30_F1
2020-06-14 22:34:31,652 bleak.backends.bluezdbus.discovery INFO: dev_D8_13_99_92_AC_22, D8:13:99:92:AC:22 (-85 dBm), Object Path: /org/bluez/hci0/dev_D8_13_99_92_AC_22
2020-06-14 22:34:32,175 bleak.backends.bluezdbus.discovery INFO: dev_7B_B7_6C_79_2F_D8, 7B:B7:6C:79:2F:D8 (-66 dBm), Object Path: /org/bluez/hci0/dev_7B_B7_6C_79_2F_D8
2020-06-14 22:34:32,595 bleak.backends.bluezdbus.discovery INFO: dev_E7_68_0E_74_24_9C, E7:68:0E:74:24:9C (? dBm), Object Path: /org/bluez/hci0/dev_E7_68_0E_74_24_9C
2020-06-14 22:34:32,630 bleak.backends.bluezdbus.discovery INFO: dev_4C_FE_F6_6F_8A_DB, 4C:FE:F6:6F:8A:DB (-64 dBm), Object Path: /org/bluez/hci0/dev_4C_FE_F6_6F_8A_DB
2020-06-14 22:34:32,655 bleak.backends.bluezdbus.discovery INFO: dev_37_92_79_88_45_98, 37:92:79:88:45:98 (? dBm), Object Path: /org/bluez/hci0/dev_37_92_79_88_45_98
2020-06-14 22:34:32,674 bleak.backends.bluezdbus.discovery INFO: dev_7B_B7_6C_79_2F_D8, 7B:B7:6C:79:2F:D8 (-66 dBm), Object Path: /org/bluez/hci0/dev_7B_B7_6C_79_2F_D8
2020-06-14 22:34:32,691 bleak.backends.bluezdbus.discovery INFO: dev_DF_6A_B5_DF_5B_A8, DF:6A:B5:DF:5B:A8 (-80 dBm), Object Path: /org/bluez/hci0/dev_DF_6A_B5_DF_5B_A8
2020-06-14 22:34:32,701 bleak.backends.bluezdbus.discovery INFO: dev_FE_D5_74_F7_30_F1, FE:D5:74:F7:30:F1 (-73 dBm), Object Path: /org/bluez/hci0/dev_FE_D5_74_F7_30_F1
2020-06-14 22:34:32,717 bleak.backends.bluezdbus.discovery INFO: dev_43_E0_8C_BC_D9_5D, 43:E0:8C:BC:D9:5D (? dBm), Object Path: /org/bluez/hci0/dev_43_E0_8C_BC_D9_5D
2020-06-14 22:34:32,728 bleak.backends.bluezdbus.discovery INFO: dev_D8_13_99_92_AC_22, D8:13:99:92:AC:22 (-85 dBm), Object Path: /org/bluez/hci0/dev_D8_13_99_92_AC_22
2020-06-14 22:34:32,740 bleak.backends.bluezdbus.discovery INFO: dev_7D_74_72_C8_43_56, 7D:74:72:C8:43:56 (? dBm), Object Path: /org/bluez/hci0/dev_7D_74_72_C8_43_56
2020-06-14 22:34:32,750 bleak.backends.bluezdbus.discovery INFO: dev_42_E0_C7_45_23_27, 42:E0:C7:45:23:27 (? dBm), Object Path: /org/bluez/hci0/dev_42_E0_C7_45_23_27
2020-06-14 22:34:32,761 bleak.backends.bluezdbus.discovery INFO: dev_06_A5_19_07_04_2D, 06:A5:19:07:04:2D (? dBm), Object Path: /org/bluez/hci0/dev_06_A5_19_07_04_2D
2020-06-14 22:34:32,773 bleak.backends.bluezdbus.discovery INFO: dev_4A_42_2E_DB_98_08, 4A:42:2E:DB:98:08 (? dBm), Object Path: /org/bluez/hci0/dev_4A_42_2E_DB_98_08
2020-06-14 22:34:32,791 bleak.backends.bluezdbus.discovery INFO: dev_5B_50_C3_A8_28_63, 5B:50:C3:A8:28:63 (? dBm), Object Path: /org/bluez/hci0/dev_5B_50_C3_A8_28_63
2020-06-14 22:34:32,807 bleak.backends.bluezdbus.discovery INFO: dev_78_D5_9A_8E_16_EF, 78:D5:9A:8E:16:EF (-67 dBm), Object Path: /org/bluez/hci0/dev_78_D5_9A_8E_16_EF
2020-06-14 22:34:32,823 bleak.backends.bluezdbus.discovery INFO: dev_5C_FD_E1_8A_00_AB, 5C:FD:E1:8A:00:AB (? dBm), Object Path: /org/bluez/hci0/dev_5C_FD_E1_8A_00_AB
2020-06-14 22:34:32,839 bleak.backends.bluezdbus.discovery INFO: dev_26_9E_C2_03_C9_E2, 26:9E:C2:03:C9:E2 (? dBm), Object Path: /org/bluez/hci0/dev_26_9E_C2_03_C9_E2
2020-06-14 22:34:32,855 bleak.backends.bluezdbus.discovery INFO: dev_77_14_77_DA_A8_8D, 77:14:77:DA:A8:8D (? dBm), Object Path: /org/bluez/hci0/dev_77_14_77_DA_A8_8D
2020-06-14 22:34:32,871 bleak.backends.bluezdbus.discovery INFO: dev_04_FE_A1_D6_71_65, 04:FE:A1:D6:71:65 (? dBm), Object Path: /org/bluez/hci0/dev_04_FE_A1_D6_71_65
2020-06-14 22:34:32,881 bleak.backends.bluezdbus.discovery INFO: dev_57_88_DC_DA_3B_AF, 57:88:DC:DA:3B:AF (-59 dBm), Object Path: /org/bluez/hci0/dev_57_88_DC_DA_3B_AF
2020-06-14 22:34:32,892 bleak.backends.bluezdbus.discovery INFO: dev_2B_C7_B9_2C_A3_EF, 2B:C7:B9:2C:A3:EF (? dBm), Object Path: /org/bluez/hci0/dev_2B_C7_B9_2C_A3_EF
2020-06-14 22:34:32,903 bleak.backends.bluezdbus.discovery INFO: dev_02_DE_B4_A3_EA_2B, 02:DE:B4:A3:EA:2B (? dBm), Object Path: /org/bluez/hci0/dev_02_DE_B4_A3_EA_2B
2020-06-14 22:34:32,915 bleak.backends.bluezdbus.discovery INFO: dev_1D_06_34_18_03_73, 1D:06:34:18:03:73 (? dBm), Object Path: /org/bluez/hci0/dev_1D_06_34_18_03_73
2020-06-14 22:34:32,925 bleak.backends.bluezdbus.discovery INFO: dev_40_9B_4A_DF_9F_57, 40:9B:4A:DF:9F:57 (? dBm), Object Path: /org/bluez/hci0/dev_40_9B_4A_DF_9F_57
2020-06-14 22:34:32,935 bleak.backends.bluezdbus.discovery INFO: dev_90_DD_5D_BF_22_F7, 90:DD:5D:BF:22:F7 (-53 dBm), Object Path: /org/bluez/hci0/dev_90_DD_5D_BF_22_F7
2020-06-14 22:34:32,945 bleak.backends.bluezdbus.discovery INFO: dev_7E_5E_40_43_4A_1A, 7E:5E:40:43:4A:1A (? dBm), Object Path: /org/bluez/hci0/dev_7E_5E_40_43_4A_1A
2020-06-14 22:34:32,956 bleak.backends.bluezdbus.discovery INFO: dev_B8_09_8A_CD_30_22, B8:09:8A:CD:30:22 (? dBm), Object Path: /org/bluez/hci0/dev_B8_09_8A_CD_30_22
2020-06-14 22:34:32,966 bleak.backends.bluezdbus.discovery INFO: dev_DC_19_EE_67_F7_80, DC:19:EE:67:F7:80 (? dBm), Object Path: /org/bluez/hci0/dev_DC_19_EE_67_F7_80
2020-06-14 22:34:32,977 bleak.backends.bluezdbus.discovery INFO: dev_41_0A_C7_71_83_F6, 41:0A:C7:71:83:F6 (? dBm), Object Path: /org/bluez/hci0/dev_41_0A_C7_71_83_F6
2020-06-14 22:34:32,987 bleak.backends.bluezdbus.discovery INFO: dev_E7_A7_69_33_61_5A, E7:A7:69:33:61:5A (? dBm), Object Path: /org/bluez/hci0/dev_E7_A7_69_33_61_5A
2020-06-14 22:34:32,997 bleak.backends.bluezdbus.discovery INFO: ACAIAL1A02F, 00:1C:97:1A:A0:2F (-76 dBm), Object Path: /org/bluez/hci0/dev_00_1C_97_1A_A0_2F
2020-06-14 22:34:33,008 bleak.backends.bluezdbus.discovery INFO: dev_AC_BC_32_6D_83_C1, AC:BC:32:6D:83:C1 (? dBm), Object Path: /org/bluez/hci0/dev_AC_BC_32_6D_83_C1
2020-06-14 22:34:33,018 bleak.backends.bluezdbus.discovery INFO: dev_06_2E_62_95_8C_3C, 06:2E:62:95:8C:3C (? dBm), Object Path: /org/bluez/hci0/dev_06_2E_62_95_8C_3C
2020-06-14 22:34:33,133 bleak.backends.bluezdbus.client DEBUG: Connecting to BLE device @ 00:1c:97:1a:a0:2f with hci0
2020-06-14 22:34:33,723 bleak.backends.bluezdbus.client DEBUG: Connection successful.
2020-06-14 22:34:34,827 bleak.backends.bluezdbus.client DEBUG: Get Services...
2020-06-14 22:34:35,305 bleak.backends.bluezdbus.client DEBUG: 
Primary Service
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013
	0000180a-0000-1000-8000-00805f9b34fb
	Device Information
2020-06-14 22:34:35,317 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char001e
	00002a50-0000-1000-8000-00805f9b34fb
	PnP ID
2020-06-14 22:34:35,323 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char001c
	00002a29-0000-1000-8000-00805f9b34fb
	Manufacturer Name String
2020-06-14 22:34:35,334 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char001a
	00002a28-0000-1000-8000-00805f9b34fb
	Software Revision String
2020-06-14 22:34:35,340 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char0018
	00002a26-0000-1000-8000-00805f9b34fb
	Firmware Revision String
2020-06-14 22:34:35,348 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char0016
	00002a27-0000-1000-8000-00805f9b34fb
	Hardware Revision String
2020-06-14 22:34:35,358 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service0013/char0014
	00002a25-0000-1000-8000-00805f9b34fb
	Serial Number String
2020-06-14 22:34:35,363 bleak.backends.bluezdbus.client DEBUG: 
Primary Service
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service000b
	00001820-0000-1000-8000-00805f9b34fb
	Internet Protocol Support
2020-06-14 22:34:35,369 bleak.backends.bluezdbus.client DEBUG: 
Characteristic
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service000b/char000c
	00002a80-0000-1000-8000-00805f9b34fb
	Age
2020-06-14 22:34:35,374 bleak.backends.bluezdbus.client DEBUG: 
Descriptor
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service000b/char000c/desc000e
	00002902-0000-1000-8000-00805f9b34fb
	Client Characteristic Configuration
2020-06-14 22:34:35,383 bleak.backends.bluezdbus.client DEBUG: 
Primary Service
	/org/bluez/hci0/dev_00_1C_97_1A_A0_2F/service000a
	00001801-0000-1000-8000-00805f9b34fb
	Generic Attribute Profile
Created
Connected
2020-06-14 22:34:38,486 bleak.backends.bluezdbus.client DEBUG: Disconnecting from BLE device...
2020-06-14 22:34:38,489 bleak.backends.bluezdbus.client DEBUG: Removing rule PropChanged, ID: 1
Disconnected
2020-06-14 22:34:38,842 bleak.backends.bluezdbus.client DEBUG: Disconnecting from BLE device...
2020-06-14 22:34:38,864 bleak.backends.bluezdbus.client ERROR: Attempt to disconnect device failed: Connection was closed cleanly.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hbldhcommented, Jun 24, 2020

This inconsistency will be addressed shortly and a fix will be included in version 0.7.0. Thank you for reporting it!

0reactions
magnusnordlandercommented, Jun 20, 2020

So basically, I’m not having any direct issues, but if there is inconsistency between platforms around being able to call disconnect twice, that’s not great.

I haven’t actually tested it, but it looks like 8794eac would solve all those issues, even if it’s not the most elegant of solutions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RuntimeError: The connection pool was closed while 6 HTTP ...
I was able to finally find a solution to this problem. For some reason the context manager: async with httpx.AsyncClient() as client fails...
Read more >
Making Android BLE work — part 2 - Medium
The device will disconnect, but you may never receive the callback with the 'disconnected' state. This is because disconnect() is asynchronous ...
Read more >
Cisco Secure Firewall ASA Series Syslog Messages
Explanation An SVC session was terminated for the given reason. This behavior may be normal, or you may be having trouble connecting. reason—The ......
Read more >
Troubleshoot Azure IoT Edge common errors - Microsoft Learn
Use this article to identify and resolve common issues when using IoT Edge solutions. If you need information on how to find logs...
Read more >
Common Mistakes Using Python3 asyncio
The cause of this problem is that the EventLoop closed right after canceling pending tasks. Because the Task.cancel() "arranges for a CancelledError to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found