undera / pylgbst

Python library for LEGO® PoweredUp devices
MIT License
552 stars 121 forks source link

Lego Boost reconnection issue #106

Open Lamb0524 opened 2 years ago

Lamb0524 commented 2 years ago

Hi, undera, may I ask a question about reconnection of pylgbst. hub = MoveHub(get_connection_auto(hub_name="LEGO Move Hub")) try: demo = DEMO_CHOICES[options.demo] demo(hub) finally: hub.disconnect()

When the programs exits, the light above the green button remains blue for seconds. If add hub = MoveHub(get_connection_auto(hub_name="LEGO Move Hub")) after finally block, the program points out that processing thread and communication thread have exited, and throws an exception of 'Device not found'. Is there any idea about the reconnection of pylgbst? Looking forward for your reply.

Lamb

undera commented 2 years ago

Blue light can remain on with some BLE libraries, and there's no harm in that AFAIK. You can call switch_off to force hub to power off (https://github.com/undera/pylgbst/blob/master/pylgbst/hub.py#L192).

Regarding reconnecting issue, I advice to switch to Bleak connection type. If the problem persists, post here debug log of that, for better diagnostics.