Skip to content

Technic Hub freezes when using ble.broadcast() #2206

@akiyuki-k

Description

@akiyuki-k

I really appreciate all the great work on Pybricks.

I'm currently facing an issue where the Technic Hub freezes when calling Bluetooth functions, and I haven't been able to resolve it on my own. I would greatly appreciate any help or guidance.

The program I am using is a simple Bluetooth send-and-receive loop. It includes a receive operation, but in my testing, no messages are ever received (the received message is always empty).

Environment where the issue is reproducible:

• Pybricks v3.6.1 (Pybricks Code v2.6.0)
• One Technic Hub with nothing connected to any ports
• The following program is transferred to the Hub
• After unpairing the Bluetooth connection between the programming PC and the Hub, the program is executed → the Hub freezes
• This occurs consistently: 20 out of 20 attempts result in a freeze
• The time to freeze varies between 1 minute and 150 minutes

When the Hub freezes, the status light remains yellow. Based on this, I suspect the issue is related to the hub.ble.broadcast(senddata) call.

As a reference, when I keep the Bluetooth pairing between the programming PC and the Hub, the same program runs for more than 10 hours without freezing (confirmed twice).

Program:

from pybricks.hubs import TechnicHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch
from umath import pi, sin, cos, radians

hub = TechnicHub(broadcast_channel=1, observe_channels=[2])

# Receive a message every 100ms. Send a message every 1s.
# The indicator switches to red when receiving and yellow when sending.
count = 0
while True:
    hub.light.on(Color.RED)
    data = hub.ble.observe(2)
    if count > 10:
        hub.light.on(Color.YELLOW)
        senddata = ('send', 1)
        hub.ble.broadcast(senddata)
        count = 0
    wait(100)
    count += 1

Please let me know if there's anything else I can try or provide to help diagnose the issue. Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    hub: technichubIssues related to the LEGO Technic hub (Hub No. 2)software: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)topic: bluetoothIssues involving bluetooth

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions