From 7286a9d4c200a46bcb04c687afb542cc3afc66cc Mon Sep 17 00:00:00 2001 From: Josh Conner Date: Sat, 31 Aug 2024 05:18:55 +0000 Subject: [PATCH] pw_bluetooth_sapphire: Embossify ReadSimplePairingModeReturnParams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use emboss definitions instead of a packed struct for generating a Read Simple Pairing Mode command complete event. Bug: b/42167863 Test: fx test //src/connectivity/bluetooth/core/bt-host Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1108733 GitOrigin-RevId: 10e3076c077c8fdac42b9327e53b2120d3bcd4ce Change-Id: Idc62cee1385e791748e5082093c9defb25686531 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232755 Lint: Lint 🤖 Commit-Queue: Auto-Submit Pigweed-Auto-Submit: Jason Graffius Reviewed-by: Ben Lawson --- .../host/testing/fake_controller.cc | 15 +++++++++------ .../internal/host/hci-spec/protocol.h | 8 -------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/pw_bluetooth_sapphire/host/testing/fake_controller.cc b/pw_bluetooth_sapphire/host/testing/fake_controller.cc index d2001af50d..2c47f575f2 100644 --- a/pw_bluetooth_sapphire/host/testing/fake_controller.cc +++ b/pw_bluetooth_sapphire/host/testing/fake_controller.cc @@ -1765,17 +1765,20 @@ void FakeController::OnWriteSimplePairingMode( } void FakeController::OnReadSimplePairingMode() { - hci_spec::ReadSimplePairingModeReturnParams params; - params.status = pwemb::StatusCode::SUCCESS; + auto event_packet = hci::EmbossEventPacket::New< + pwemb::ReadSimplePairingModeCommandCompleteEventWriter>( + hci_spec::kCommandCompleteEventCode); + auto view = event_packet.view_t(); + view.status().Write(pwemb::StatusCode::SUCCESS); if (CheckBit(settings_.lmp_features_page1, hci_spec::LMPFeature::kSecureSimplePairingHostSupport)) { - params.simple_pairing_mode = pwemb::GenericEnableParam::ENABLE; + view.simple_pairing_mode().Write(pwemb::GenericEnableParam::ENABLE); } else { - params.simple_pairing_mode = pwemb::GenericEnableParam::DISABLE; + view.simple_pairing_mode().Write(pwemb::GenericEnableParam::DISABLE); } - RespondWithCommandComplete(hci_spec::kReadSimplePairingMode, - BufferView(¶ms, sizeof(params))); + RespondWithCommandComplete(pwemb::OpCode::READ_SIMPLE_PAIRING_MODE, + &event_packet); } void FakeController::OnWritePageScanType( 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 4cf39fa6ae..1500b838a0 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 @@ -402,14 +402,6 @@ constexpr OpCode kWriteExtendedInquiryResponse = // Read Simple Pairing Mode (v2.1 + EDR) (BR/EDR) constexpr OpCode kReadSimplePairingMode = ControllerAndBasebandOpCode(0x0055); -struct ReadSimplePairingModeReturnParams { - // See enum StatusCode in hci_constants.h - StatusCode status; - - // Simple pairing Mode. - GenericEnableParam simple_pairing_mode; -} __attribute__((packed)); - // =============================================== // Write Simple Pairing Mode (v2.1 + EDR) (BR/EDR) constexpr OpCode kWriteSimplePairingMode = ControllerAndBasebandOpCode(0x0056);