Skip to content

Commit 0c7da32

Browse files
committed
drv/bluetooth_stm32_bluenrg: Allow broadcast while connected.
Nothing happens still, but at least you can run your program to test and debug other portions of the code that do not rely on Bluetooth. Also update the matching notes in the BLE module and remove City Hub limitations which have been fixed.
1 parent 533ace0 commit 0c7da32

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
- Added `MoveHub.imu.tilt()` ([support#539]).
99
- Enabled hub init orientation support for Move Hub ([support#539]).
1010

11+
### Changed
12+
- Allow Move Hub to ignore `broadcast` instead of raising an exception while
13+
connected.
14+
1115
### Fixed
1216
- Fixed Move Hub accelerometer not working since v3.3.0b5 ([support#1269]).
1317
- Fixed Bluetooth chip locking up on Technic and City hubs when broadcasting ([support#1095]).

lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,14 @@ static PT_THREAD(broadcast_task(struct pt *pt, pbio_task_t *task)) {
716716

717717
if (status != BLE_STATUS_SUCCESS) {
718718
task->status = ble_error_to_pbio_error(status);
719+
720+
// Broadcasting does not work while connected to the computer. But
721+
// returning an error means that Move Hub programs with
722+
// broadcasting can never run while connected, which makes it very
723+
// impractical to test any program. So mark as success.
724+
if (task->status == PBIO_ERROR_INVALID_OP) {
725+
task->status = PBIO_SUCCESS;
726+
}
719727
PT_EXIT(pt);
720728
}
721729

pybricks/common/pb_type_ble.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,9 @@ STATIC mp_obj_t pb_module_ble_broadcast(size_t n_args, const mp_obj_t *pos_args,
254254
PB_PARSE_ARGS_METHOD(n_args, pos_args, kw_args,
255255
pb_obj_BLE_t, self,
256256
PB_ARG_REQUIRED(data));
257-
// REVISIT: disable this method on move hub and city hub?
258-
// This method will raise an OSError on move hub if it is called while the
257+
// On Move Hub, nothing is broadcast if it is called while the
259258
// move hub is connected to Pybricks Code. Also, broadcasting interferes
260-
// with observing even when not connected to Pybricks Code. On the city
261-
// hub, this method succeeds, but nothing is actually sent over the air.
262-
259+
// with observing even when not connected to Pybricks Code.
263260

264261
// TODO: Stop broadcasting if data is None.
265262

0 commit comments

Comments
 (0)