From 5335b95f6876989193ca2431ef9d28d4e39dab69 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 23 Aug 2024 19:44:10 +0000 Subject: [PATCH] pw_bluetooth_sapphire: Migrate LEReadLocalSupportedFeatures 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/+/1096752 GitOrigin-RevId: ecbc2add7ba0e6616a935d6ec27129067932334a Change-Id: I65f73f5ed08052b4bd92c0e884e2cdc3d23ebdb2 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230575 Lint: Lint 🤖 Commit-Queue: Jason Graffius Reviewed-by: Lulu Wang --- pw_bluetooth_sapphire/host/gap/adapter.cc | 10 +++++----- .../host/testing/fake_controller.cc | 13 +++++++------ .../internal/host/hci-spec/protocol.h | 9 --------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/pw_bluetooth_sapphire/host/gap/adapter.cc b/pw_bluetooth_sapphire/host/gap/adapter.cc index e6e574e696..b90053df5d 100644 --- a/pw_bluetooth_sapphire/host/gap/adapter.cc +++ b/pw_bluetooth_sapphire/host/gap/adapter.cc @@ -1098,18 +1098,18 @@ void AdapterImpl::InitializeStep2() { hci::EmbossCommandPacket::New< pw::bluetooth::emboss::LEReadLocalSupportedFeaturesCommandView>( hci_spec::kLEReadLocalSupportedFeatures), - [this](const hci::EventPacket& cmd_complete) { + [this](const hci::EmbossEventPacket& cmd_complete) { if (hci_is_error(cmd_complete, WARN, "gap", "LE read local supported features failed")) { return; } - auto params = cmd_complete.return_params< - hci_spec::LEReadLocalSupportedFeaturesReturnParams>(); + auto packet = cmd_complete.view< + pw::bluetooth::emboss:: + LEReadLocalSupportedFeaturesCommandCompleteEventView>(); state_.low_energy_state.supported_features_ = - pw::bytes::ConvertOrderFrom(cpp20::endian::little, - params->le_features); + packet.le_features().BackingStorage().ReadUInt(); }); // HCI_LE_Read_Supported_States diff --git a/pw_bluetooth_sapphire/host/testing/fake_controller.cc b/pw_bluetooth_sapphire/host/testing/fake_controller.cc index a27b899223..3f3867b258 100644 --- a/pw_bluetooth_sapphire/host/testing/fake_controller.cc +++ b/pw_bluetooth_sapphire/host/testing/fake_controller.cc @@ -1695,12 +1695,13 @@ void FakeController::OnLEReadSupportedStates() { } void FakeController::OnLEReadLocalSupportedFeatures() { - hci_spec::LEReadLocalSupportedFeaturesReturnParams params; - params.status = pwemb::StatusCode::SUCCESS; - params.le_features = - pw::bytes::ConvertOrderTo(cpp20::endian::little, settings_.le_features); - RespondWithCommandComplete(hci_spec::kLEReadLocalSupportedFeatures, - BufferView(¶ms, sizeof(params))); + auto packet = hci::EmbossEventPacket::New< + pwemb::LEReadLocalSupportedFeaturesCommandCompleteEventWriter>( + hci_spec::kCommandCompleteEventCode); + auto view = packet.view_t(); + view.status().Write(pwemb::StatusCode::SUCCESS); + view.le_features().BackingStorage().WriteUInt(settings_.le_features); + RespondWithCommandComplete(hci_spec::kLEReadLocalSupportedFeatures, &packet); } void FakeController::OnLECreateConnectionCancel() { 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 8d8c2975ca..27ab1e4e27 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 @@ -1386,15 +1386,6 @@ struct LEReadBufferSizeV1ReturnParams { constexpr OpCode kLEReadLocalSupportedFeatures = LEControllerCommandOpCode(0x0003); -struct LEReadLocalSupportedFeaturesReturnParams { - // See enum StatusCode in hci_constants.h. - StatusCode status; - - // Bit Mask List of supported LE features. See enum class LESupportedFeature - // in hci_constants.h. - uint64_t le_features; -} __attribute__((packed)); - // ========================================= // LE Set Random Address Command (v4.0) (LE) constexpr OpCode kLESetRandomAddress = LEControllerCommandOpCode(0x0005);