virantha / bricknil

Control LEGO Bluetooth Sensors and Motors with Python
https://virantha.github.io/bricknil
Apache License 2.0
142 stars 39 forks source link

Technic Control+ Hub gets disconnected on "notify" (raspberry pi 4) #21

Open MrFus10n opened 4 years ago

MrFus10n commented 4 years ago

I'm trying to connect to my 4100 excavator from raspberry pi 4, but it gets disconnected right after connection. What I discovered is that connection won't drop until "notify" message is sent to socket, but I can't find out why it happens. No error or other clue appears. I'm starting to think there is race condition because it got connected once and started controlling motors. After I turned off bluetooth on raspberry, turned it on again and restarted my script with no code changes, it doesn't connect again. Here are logs:

DEBUG:vext:zope not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:zope not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:zope not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:zope not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:win32api not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:win32api not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:win32api not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:win32api not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:found module OpenSSL in sitedir or subdirectory [/usr/lib/python3/dist-packages]
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:found module OpenSSL in sitedir or subdirectory [/usr/lib/python3/dist-packages]
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:found module OpenSSL in sitedir or subdirectory [/usr/lib/python3/dist-packages]
DEBUG:asyncio:Using selector: EpollSelector
started thread for curio
inside curio run loop
INFO:BLE Event Q.0:using bleak
DEBUG:truck.2:Decorating class ExcavatorBase with CPlusXLMotor
INFO:BLE Event Q.0:Starting scan for UART 00001623-1212-efde-1623-785feabcd123
INFO:BLE Event Q.0:Looking for first matching hub
Awaiting on bleak discover
DEBUG:vext:cPickle not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:cPickle not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:cPickle not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:cPickle not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:OpenSSL not found in: /home/pi/dev/lego:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/home/pi/dev/lego_venv/lib/python3.7/site-packages
DEBUG:vext:found module OpenSSL in sitedir or subdirectory [/usr/lib/python3/dist-packages]
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (60 tries left)
Awaiting on bleak discover
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
Done Awaiting on bleak discover
INFO:BLE Event Q.0:checking manufacturer ID for device named Technic Hub for Control+ Hub
INFO:BLE Event Q.0:found device Technic Hub
DEBUG:bleak.backends.bluezdbus.client:Connecting to BLE device @ 90:84:2B:4E:A1:92 with hci0
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.client:Connection successful.
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.client:Get Services...
DEBUG:bleak.backends.bluezdbus.client:
Primary Service
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c
    00001623-1212-efde-1623-785feabcd123
    Unknown
DEBUG:bleak.backends.bluezdbus.client:
Characteristic
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d
    00001624-1212-efde-1623-785feabcd123
    Unknown
DEBUG:bleak.backends.bluezdbus.client:
Descriptor
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d/desc000f
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
DEBUG:bleak.backends.bluezdbus.client:
Primary Service
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001
    00001801-0000-1000-8000-00805f9b34fb
    Generic Attribute Profile
DEBUG:bleak.backends.bluezdbus.client:
Characteristic
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002
    00002a05-0000-1000-8000-00805f9b34fb
    Service Changed
DEBUG:bleak.backends.bluezdbus.client:
Descriptor
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002/desc0004
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
INFO:BLE Event Q.0:Device advertised: {'00001624-1212-efde-1623-785feabcd123': {'UUID': '00001624-1212-efde-1623-785feabcd123', 'Service': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c', 'Value': [15, 0, 4, 1, 1, 47, 0, 0, 16, 0, 0, 0, 16, 0, 0], 'Notifying': False, 'Flags': ['read', 'write-without-response', 'write', 'notify'], 'WriteAcquired': False, 'NotifyAcquired': False, 'Path': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d'}, '00002a05-0000-1000-8000-00805f9b34fb': {'UUID': '00002a05-0000-1000-8000-00805f9b34fb', 'Service': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001', 'Value': [], 'Notifying': False, 'Flags': ['indicate'], 'Path': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002'}}
INFO:BLE Event Q.0:Connected to device Technic Hub:90:84:2B:4E:A1:92
INFO:BLE Event Q.0:Waiting for hubs to end
DEBUG:truck.2:starting peripheral message loop
INFO:truck.2:Running
DEBUG:BLE Event Q.0:Got msg: req mode info on 255 = [0, 33, 255, 1]
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-62 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
Traceback (most recent call last):
  File "main.py", line 53, in <module>
    start(system)
  File "/home/pi/dev/lego/bricknil/bricknil.py", line 214, in start
    ble.run()
  File "/home/pi/dev/lego/bricknil/bleak_interface.py", line 52, in run
    self.loop.run_until_complete(self.asyncio_loop())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/pi/dev/lego/bricknil/bleak_interface.py", line 75, in asyncio_loop
    await device.write_gatt_char(char_uuid, msg_bytes)
  File "/home/pi/dev/lego_venv/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 252, in write_gatt_char
    self.loop
txdbus.error.RemoteError: org.bluez.Error.Failed: Not connected

If I comment out line line 112 in bricknil.ble_queue (await self.ble.in_queue.put( ('notify', (device, char_uuid, bleak_received) ))), it doesn't disconnect, but motors don't move. Can anyone help?

MrFus10n commented 4 years ago

Tried to delete vext and vext.pi. It got connected once again and after just a restart stopped working again. Here are logs without vext for the case it helps somehow:

DEBUG:asyncio:Using selector: EpollSelector
started thread for curio
inside curio run loop
INFO:BLE Event Q.0:using bleak
DEBUG:excavator.2:Decorating class ExcavatorBase with CPlusXLMotor
INFO:BLE Event Q.0:Starting scan for UART 00001623-1212-efde-1623-785feabcd123
INFO:BLE Event Q.0:Looking for first matching hub
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (60 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (59 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (58 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (57 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (56 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (55 tries left)
Awaiting on bleak discover
Done Awaiting on bleak discover
INFO:BLE Event Q.0:Rescanning for 00001623-1212-efde-1623-785feabcd123 (54 tries left)
Awaiting on bleak discover
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
Done Awaiting on bleak discover
INFO:BLE Event Q.0:checking manufacturer ID for device named Technic Hub for Control+ Hub
INFO:BLE Event Q.0:found device Technic Hub
DEBUG:bleak.backends.bluezdbus.client:Connecting to BLE device @ 90:84:2B:4E:A1:92 with hci0
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.client:Connection successful.
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.client:Get Services...
DEBUG:bleak.backends.bluezdbus.client:
Primary Service
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c
    00001623-1212-efde-1623-785feabcd123
    Unknown
DEBUG:bleak.backends.bluezdbus.client:
Characteristic
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d
    00001624-1212-efde-1623-785feabcd123
    Unknown
DEBUG:bleak.backends.bluezdbus.client:
Descriptor
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d/desc000f
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
DEBUG:bleak.backends.bluezdbus.client:
Primary Service
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001
    00001801-0000-1000-8000-00805f9b34fb
    Generic Attribute Profile
DEBUG:bleak.backends.bluezdbus.client:
Characteristic
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002
    00002a05-0000-1000-8000-00805f9b34fb
    Service Changed
DEBUG:bleak.backends.bluezdbus.client:
Descriptor
    /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002/desc0004
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
INFO:BLE Event Q.0:Device advertised: {'00001624-1212-efde-1623-785feabcd123': {'UUID': '00001624-1212-efde-1623-785feabcd123', 'Service': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c', 'Value': [15, 0, 4, 0, 1, 47, 0, 0, 16, 0, 0, 0, 16, 0, 0], 'Notifying': False, 'Flags': ['read', 'write-without-response', 'write', 'notify'], 'WriteAcquired': False, 'NotifyAcquired': False, 'Path': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d'}, '00002a05-0000-1000-8000-00805f9b34fb': {'UUID': '00002a05-0000-1000-8000-00805f9b34fb', 'Service': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001', 'Value': [], 'Notifying': False, 'Flags': ['indicate'], 'Path': '/org/bluez/hci0/dev_90_84_2B_4E_A1_92/service0001/char0002'}}
INFO:BLE Event Q.0:Connected to device Technic Hub:90:84:2B:4E:A1:92
INFO:BLE Event Q.0:Waiting for hubs to end
DEBUG:excavator.2:starting peripheral message loop
INFO:excavator.2:Running
DEBUG:BLE Event Q.0:Got msg: req mode info on 255 = [0, 33, 255, 1]
DEBUG:bleak.backends.bluezdbus.client:GATT Char Properties Changed: /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d | [{'Value': [15, 0, 4, 0, 1, 47, 0, 0, 16, 0, 0, 0, 16, 0, 0]}, []]
DEBUG:BLE Event Q.0:Bleak Raw data received: bytearray(b'\x0f\x00\x04\x00\x01/\x00\x00\x10\x00\x00\x00\x10\x00\x00')
DEBUG:BLE Event Q.0:excavator Received: Attached IO Port:0 Technic Control+ XL Motor HW:0x0.0x0.0x100x0 SW:0x0.0x0.0x100x0
DEBUG:excavator.2:peripheral msg: right_drive.1 attach
DEBUG:BLE Event Q.0:Got msg: req mode info on 0 = [0, 33, 0, 1]
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.discovery:dev_90_84_2B_4E_A1_92, 90:84:2B:4E:A1:92 (-63 dBm), Object Path: /org/bluez/hci0/dev_90_84_2B_4E_A1_92
DEBUG:bleak.backends.bluezdbus.client:Write Characteristic 00001624-1212-efde-1623-785feabcd123 | /org/bluez/hci0/dev_90_84_2B_4E_A1_92/service000c/char000d: bytearray(b'\x05\x00!\xff\x01')
Traceback (most recent call last):
  File "main.py", line 53, in <module>
    start(system)
  File "/home/pi/dev/lego/bricknil/bricknil.py", line 214, in start
    ble.run()
  File "/home/pi/dev/lego/bricknil/bleak_interface.py", line 52, in run
    self.loop.run_until_complete(self.asyncio_loop())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/pi/dev/lego/bricknil/bleak_interface.py", line 75, in asyncio_loop
    await device.write_gatt_char(char_uuid, msg_bytes)
  File "/home/pi/dev/lego_venv/lib/python3.7/site-packages/bleak/backends/bluezdbus/client.py", line 252, in write_gatt_char
    self.loop
txdbus.error.RemoteError: org.bluez.Error.Failed: Not connected
justxi commented 3 years ago

Hi, I managed to get my 42100 to work using the fork from janvrany. But I observed communication problems too. If I have problems currently only stopping bluetooth and removing the usb dongle resets the system in a way that allows to run the python program again.