From ad5c105616f95619e48461ea87212f89413aec6b Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 23 Aug 2024 17:48:49 +0000 Subject: [PATCH] pw_bluetooth_sapphire: Migrate UserPasskeyRequestEvent to emboss MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: b/42167863 Test: fx test bt-host-gap-tests Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1094306 GitOrigin-RevId: 10964c63e7cc05620b11f5b1b98932adcb9a6d3e Change-Id: I48ecc537c227401c3c82633e6e597d53a6fc7add Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230535 Commit-Queue: Jason Graffius Reviewed-by: Lulu Wang Lint: Lint 🤖 --- .../host/gap/bredr_connection_manager.cc | 18 ++++++++++-------- .../host/gap/bredr_connection_manager.h | 2 +- .../internal/host/hci-spec/protocol.h | 5 ----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc b/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc index 370369b4e7..92b5d584ca 100644 --- a/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc +++ b/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc @@ -1552,23 +1552,25 @@ BrEdrConnectionManager::OnUserConfirmationRequest( } hci::CommandChannel::EventCallbackResult -BrEdrConnectionManager::OnUserPasskeyRequest(const hci::EventPacket& event) { - BT_DEBUG_ASSERT(event.event_code() == hci_spec::kUserPasskeyRequestEventCode); - const auto& params = event.params(); +BrEdrConnectionManager::OnUserPasskeyRequest( + const hci::EmbossEventPacket& event_packet) { + auto params = + event_packet.view(); + DeviceAddressBytes bd_addr = DeviceAddressBytes(params.bd_addr()); - auto conn_pair = FindConnectionByAddress(params.bd_addr); + auto conn_pair = FindConnectionByAddress(bd_addr); if (!conn_pair) { bt_log(WARN, "gap-bredr", "got %s for unconnected addr %s", __func__, - bt_str(params.bd_addr)); - SendUserPasskeyRequestNegativeReply(params.bd_addr); + bt_str(bd_addr)); + SendUserPasskeyRequestNegativeReply(bd_addr); return hci::CommandChannel::EventCallbackResult::kContinue; } - auto passkey_cb = [self = weak_self_.GetWeakPtr(), bd_addr = params.bd_addr]( - std::optional passkey) { + auto passkey_cb = [self = weak_self_.GetWeakPtr(), + bd_addr](std::optional passkey) { if (!self.is_alive()) { return; } diff --git a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/gap/bredr_connection_manager.h b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/gap/bredr_connection_manager.h index 5b45419001..29024d81b0 100644 --- a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/gap/bredr_connection_manager.h +++ b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/gap/bredr_connection_manager.h @@ -286,7 +286,7 @@ class BrEdrConnectionManager final { hci::CommandChannel::EventCallbackResult OnUserConfirmationRequest( const hci::EmbossEventPacket& event_packet); hci::CommandChannel::EventCallbackResult OnUserPasskeyRequest( - const hci::EventPacket& event); + const hci::EmbossEventPacket& event_packet); hci::CommandChannel::EventCallbackResult OnUserPasskeyNotification( const hci::EventPacket& event); hci::CommandChannel::EventCallbackResult OnRoleChange( diff --git a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h index 379f1cb391..56db1d8cbb 100644 --- a/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h +++ b/pw_bluetooth_sapphire/public/pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h @@ -925,11 +925,6 @@ constexpr EventCode kUserConfirmationRequestEventCode = 0x33; // User Passkey Request Event (v2.1 + EDR) (BR/EDR) constexpr EventCode kUserPasskeyRequestEventCode = 0x34; -struct UserPasskeyRequestEventParams { - // Address of the device involved in simple pairing process - DeviceAddressBytes bd_addr; -} __attribute__((packed)); - // =================================================== // Simple Pairing Complete Event (v2.1 + EDR) (BR/EDR) constexpr EventCode kSimplePairingCompleteEventCode = 0x36;