Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Embossify ReadSimplePairingModeReturnParams
Browse files Browse the repository at this point in the history
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 🤖 <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Jason Graffius <[email protected]>
Reviewed-by: Ben Lawson <[email protected]>
  • Loading branch information
josh-conner authored and CQ Bot Account committed Aug 31, 2024
1 parent 2a2c2ad commit 7286a9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 9 additions & 6 deletions pw_bluetooth_sapphire/host/testing/fake_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params, sizeof(params)));
RespondWithCommandComplete(pwemb::OpCode::READ_SIMPLE_PAIRING_MODE,
&event_packet);
}

void FakeController::OnWritePageScanType(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7286a9d

Please sign in to comment.