-
-
Notifications
You must be signed in to change notification settings - Fork 7
Description
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 += 1Please let me know if there's anything else I can try or provide to help diagnose the issue. Thank you in advance!