Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Migrate UserPasskeyRequestEvent to emboss
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Lulu Wang <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
BenjaminLawson authored and CQ Bot Account committed Aug 23, 2024
1 parent 42d905b commit ad5c105
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 10 additions & 8 deletions pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<hci_spec::UserPasskeyRequestEventParams>();
BrEdrConnectionManager::OnUserPasskeyRequest(
const hci::EmbossEventPacket& event_packet) {
auto params =
event_packet.view<pw::bluetooth::emboss::UserPasskeyRequestEventView>();
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<uint32_t> passkey) {
auto passkey_cb = [self = weak_self_.GetWeakPtr(),
bd_addr](std::optional<uint32_t> passkey) {
if (!self.is_alive()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ad5c105

Please sign in to comment.