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

Hub disconnects on first write? #16

Open coezbek opened 4 years ago

coezbek commented 4 years ago

When connecting to the MoveHub on Raspi 4 it seems that upon first write the MoveHub disconnects (LED starts white blinking after solid blue). Any idea why this could be?

INFO:BLE Event Q.0:Connected to device Idas gitare:00:16:53:B4:DC:8F
INFO:robot.6:Waiting for peripheral motor_r to attach to a port
DEBUG:robot.6:starting peripheral message loop
DEBUG:robot.6:peripheral msg: hub_btn.1 attach
DEBUG:bricknil.sockets:{"hub": "robot", "peripheral_type": "Button", "peripheral_name": "hub_btn", "peripheral_port": 255, "message": "Activate button reports: port 255"}
DEBUG:BLE Event Q.0:Got msg: Activate button reports: port 255 = [0, 1, 2, 2]
DEBUG:BLE Event Q.0:Got msg: req mode info on 255 = [0, 33, 255, 1]
INFO:robot.6:Waiting for peripheral motor_r to attach to a port
DEBUG:bleak.backends.bluezdbus.discovery:dev_00_16_53_B4_DC_8F, 00:16:53:B4:DC:8F (-67 dBm), Object Path: /org/bluez/hci0/dev_00_16_53_B4_DC_8F
Traceback (most recent call last):
  File "list_ports_boost_hub.py", line 38, in <module>
    start(system)
  File "/usr/local/lib/python3.7/dist-packages/bricknil/bricknil.py", line 214, in start
    ble.run()
  File "/usr/local/lib/python3.7/dist-packages/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 "/usr/local/lib/python3.7/dist-packages/bricknil/bleak_interface.py", line 75, in asyncio_loop
    await device.write_gatt_char(char_uuid, msg_bytes)
  File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 252, in write_gatt_char
    self.loop
txdbus.error.RemoteError: org.bluez.Error.Failed: Not connected
INFO:robot.6:Waiting for peripheral motor_r to attach to a port
INFO:robot.6:Waiting for peripheral motor_r to attach to a port