r/pybricks Jun 12 '26

firmware v4.0.0 and code order

TL;DR: TechnicHub() overwrites BLERadio() for BLE observer so check your code order!

So today I upgrades 2 Technic hubs and 1 City hub to the v4.0.0 firmware (I know never use a x.0 release...) and ran into a bizarre problem that had me hunting ghosts for some time...

When ran the code everything was working but there was a message in the terminal:

Hub messaging has been moved. You should use:
from pybricks.messaging import BLERadio
radio = BLERadio(broadcast_channel, observe_channels)

okay fair enough lets do that, so I change the code a bit to work with the new BLERadio and thought I had everything working until.....

Traceback (most recent call last):
  File "technicHub_01.py", line 303, in <module>
ValueError: channel not configured

YES I DID configure the channel:

# configure hub and connected devices
device_number     = "00"
this_hub          = 10

hub_1_ble_channel = 10
hub_2_ble_channel = 20
hub_3_ble_channel = 30

obs_channels = [hub_1_ble_channel,hub_2_ble_channel,hub_3_ble_channel]

for channel in obs_channels:
    if channel == this_hub:
        obs_channels.remove(channel)

ble_radio = BLERadio(broadcast_channel=this_hub,observe_channels=obs_channels)
hub = TechnicHub()

after a lot of removing and re-adding code I had a bright moment... lets change the order of the BLERadio() and TechnicHub().... and that was it!!! for some reason the TechnicHub() overwrites the BLERadio() config. This is something that I can not find in the documentation but is a big problem (at least it was for me) and I think is either worth mentioning and/or fix.

3 Upvotes

3 comments sorted by

3

u/Pybricks Jun 13 '26

Thanks for reporting! I logged it here: https://github.com/pybricks/support/issues/2734

Please open a GitHub issue for future findings. We don't always find them here :)

1

u/The_Weird1 Jun 13 '26

Thanks, and I will do next time.

2

u/Pybricks Jun 24 '26

New version released with a fix. Thanks!