Skip to content

Commit 87db494

Browse files
committed
tutorials/wireless/hub-to-hub: Update for release.
1 parent 3fb7f2e commit 87db494

File tree

6 files changed

+7
-23
lines changed

6 files changed

+7
-23
lines changed
Binary file not shown.
Binary file not shown.

tutorials/wireless/hub-to-hub/broadcast/index.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ video:
1111
youtube: "i--8nBvNn_4"
1212
---
1313

14-
# Experimental features ahead!
15-
16-
Hub to hub communication is still a work in progress. This page explains how
17-
you can install an experimental release on the hub to try it out. This
18-
functionality may change in the future and some things may not work.
19-
20-
Last changed on 2023-05-16. Be sure to use [Pybricks Beta] and the most recent
21-
firmware.
22-
23-
[Pybricks Beta]: https://beta.pybricks.com
24-
2514
# Data broadcasting
2615

2716
When a Bluetooth device is on but not yet connected to anything, it typically
@@ -64,10 +53,11 @@ hub = ThisHub(observe_channels=[1, 2])
6453
You can send data like this:
6554

6655
```python
67-
roll, pitch = sensor.tilt()
56+
# Get a tuple of pitch and roll angles.
57+
data = sensor.tilt()
6858

6959
# Send it out to anyone listening.
70-
hub.ble.broadcast(roll, pitch)
60+
hub.ble.broadcast(data)
7161
```
7262

7363
On another hub, you can receive it as follows:
@@ -86,7 +76,7 @@ if data is not None:
8676
When sending data, your values will be automatically encoded into a format
8777
suitable for broadcasting. You can send integers (`1`, `-5`, ...), floats
8878
(`1.0` `-5.3`, ...), booleans (`True`, `False`), strings (`"example"`), bytes
89-
(`b"\x00\x02"`) and `None`.
79+
(`b"\x00\x02"`) or tuples thereof.
9080

9181

9282
# Running the example programs
@@ -97,7 +87,7 @@ wireless bidirectional communication.
9787
One hub sends tilt sensor data to control a driving vehicle. The vehicle
9888
sends back a distance measurement to show a warning light for nearby obstacles:
9989

100-
**Run this program on the remote**
90+
**Run this program on the sender**
10191

10292
You can use any hub with any type of sensor. For example, you could use the
10393
built-in tilt sensor of the Technic Hub, Prime Hub, Essential Hub, or the
@@ -126,13 +116,7 @@ sensor, you can delete the lines that make use of the Ultrasonic Sensor.
126116

127117
If the hub is still connected to the computer, the bluetooth chip is quite busy
128118
and data broadcasting may be slow. Especially on the Technic Hub and the City
129-
Hub.
119+
Hub. On the Move Hub, it cannot broadcast at all while connected to the PC.
130120

131121
To work around it, just load the program onto the hub and disconnect from your
132122
computer. You can just restart the program with the hub button.
133-
134-
# Known issue: Broadcasting using the City hub does not work
135-
136-
There is a bug in the Bluetooth chip firmware that prevents broadcasting
137-
from working properly on the City hub. It was working in previous experimental
138-
implementations because we were broadcasting data the "wrong" way.
Binary file not shown.

tutorials/wireless/hub-to-hub/broadcast/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
roll = 0
2222

2323
# Send the data!
24-
hub.ble.broadcast(pitch, roll)
24+
hub.ble.broadcast((pitch, roll))
2525

2626
# Check for distance data.
2727
data = hub.ble.observe(2)
Binary file not shown.

0 commit comments

Comments
 (0)