Skip to content

Commit

Permalink
drv/bluetooth_stm32_cc2640: fix technic hub broadcast
Browse files Browse the repository at this point in the history
Broadcasting was not working on Technic hub when it was not connected
to another device (e.g. computer or remote control). This adds a check
for connected state and applies the same hack of using ADV_IND like
City hub if needed.

Fixes: pybricks/support#1086
  • Loading branch information
dlech committed Jun 1, 2023
1 parent d80df1a commit 416a29e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
### Fixed
- Fixed BLE broadcast not working on City hub.
- Fixed crash on BTStack hubs when program stopped during call to `ble.broadcast()`.
- Fixed BLE broadcast not working on Technic hub when not connected ([support#1086]).

[support#402]: https://github.com/pybricks/support/issues/402
[support#1086]: https://github.com/pybricks/support/issues/402

## [3.3.0b5] - 2023-05-16

Expand Down
5 changes: 4 additions & 1 deletion lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,10 @@ static PT_THREAD(broadcast_task(struct pt *pt, pbio_task_t *task)) {
// send something over the air.
ADV_IND,
#else
ADV_NONCONN_IND,
// Technic hub will send non-connectable advertisements only if
// it is connected to something else, otherwise we need the same
// hack as the City hub.
(conn_handle == NO_CONNECTION && remote_handle == NO_CONNECTION) ? ADV_IND : ADV_NONCONN_IND,
#endif
GAP_INITIATOR_ADDR_TYPE_PRIVATE_NON_RESOLVE, NULL,
GAP_CHANNEL_MAP_ALL, GAP_FILTER_POLICY_SCAN_ANY_CONNECT_ANY);
Expand Down

0 comments on commit 416a29e

Please sign in to comment.