Skip to content

Commit

Permalink
drv/bluetooth_btstack: don't advertise after disconnect
Browse files Browse the repository at this point in the history
BTStack has a "feature" where advertising is started automatically [1].

To be consistent with other hubs, we don't want this to happen.

Fixes: pybricks/support#849

[1]: https://github.com/bluekitchen/btstack/blob/ffc05fad031013a636a5d1085532b4ecb83a70a3/src/hci.c#L2789
  • Loading branch information
dlech committed Dec 12, 2022
1 parent 4d07e25 commit af6a4e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

### Fixed
- Fixed SPIKE/MINDSTORMS hubs advertising after disconnect while user program
is still running ([support#849]).

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

## [3.2.0c1] - 2022-12-09

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions lib/pbio/drv/bluetooth/bluetooth_btstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
// HCI_ROLE_MASTER means the connecting device is the peripheral and the hub is the central.
if (hci_subevent_le_connection_complete_get_role(packet) == HCI_ROLE_SLAVE) {
le_con_handle = hci_subevent_le_connection_complete_get_connection_handle(packet);

// don't start advertising again on disconnect
gap_advertisements_enable(false);
} else {
// If we aren't waiting for a handset connection, this must be a different connection.
if (handset.con_state != CON_STATE_WAIT_CONNECT) {
Expand Down

0 comments on commit af6a4e8

Please sign in to comment.