Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Emboss LEReadSupportedStatesCommandCompleteEvent
Browse files Browse the repository at this point in the history
Migrate LEReadSupportedStatesCommandCompleteEvent to Emboss

Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1109572
GitOrigin-RevId: 9002caff792c1c81051dad950cadc51049d18479
Change-Id: I912395dab8615b15551d6dce5de4fa3f82cc4ac3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232777
Reviewed-by: Ben Lawson <[email protected]>
Lint: Lint 🤖 <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Jason Graffius <[email protected]>
  • Loading branch information
BenjaminLawson authored and CQ Bot Account committed Aug 31, 2024
1 parent 4df6f28 commit 60a6b4d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
11 changes: 6 additions & 5 deletions pw_bluetooth_sapphire/host/gap/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1123,18 +1123,19 @@ void AdapterImpl::InitializeStep2() {
hci::EmbossCommandPacket::New<
pw::bluetooth::emboss::LEReadSupportedStatesCommandView>(
hci_spec::kLEReadSupportedStates),
[this](const hci::EventPacket& cmd_complete) {
[this](const hci::EmbossEventPacket& cmd_complete) {
if (hci_is_error(cmd_complete,
WARN,
"gap",
"LE read local supported states failed")) {
return;
}
auto params =
auto packet =
cmd_complete
.return_params<hci_spec::LEReadSupportedStatesReturnParams>();
state_.low_energy_state.supported_states_ = pw::bytes::ConvertOrderFrom(
cpp20::endian::little, params->le_states);
.view<pw::bluetooth::emboss::
LEReadSupportedStatesCommandCompleteEventView>();
state_.low_energy_state.supported_states_ =
packet.le_states().BackingStorage().ReadLittleEndianUInt<64>();
});

if (state_.SupportedCommands()
Expand Down
14 changes: 8 additions & 6 deletions pw_bluetooth_sapphire/host/testing/fake_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1662,12 +1662,14 @@ void FakeController::OnLEReadBufferSizeV2() {
}

void FakeController::OnLEReadSupportedStates() {
hci_spec::LEReadSupportedStatesReturnParams params;
params.status = pwemb::StatusCode::SUCCESS;
params.le_states = pw::bytes::ConvertOrderTo(cpp20::endian::little,
settings_.le_supported_states);
RespondWithCommandComplete(hci_spec::kLEReadSupportedStates,
BufferView(&params, sizeof(params)));
auto packet = hci::EmbossEventPacket::New<
pwemb::LEReadSupportedStatesCommandCompleteEventWriter>(
hci_spec::kCommandCompleteEventCode);
auto view = packet.view_t();
view.status().Write(pwemb::StatusCode::SUCCESS);
view.le_states().BackingStorage().WriteLittleEndianUInt<64>(
settings_.le_supported_states);
RespondWithCommandComplete(pwemb::OpCode::LE_READ_SUPPORTED_STATES, &packet);
}

void FakeController::OnLEReadLocalSupportedFeatures() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,15 +947,6 @@ constexpr OpCode kLELongTermKeyRequestNegativeReply =
// LE Read Supported States Command (v4.0) (LE)
constexpr OpCode kLEReadSupportedStates = LEControllerCommandOpCode(0x001C);

struct LEReadSupportedStatesReturnParams {
// See enum StatusCode in hci_constants.h.
StatusCode status;

// Bit-mask of supported state or state combinations. See Core Spec v4.2,
// Volume 2, Part E, Section 7.8.27 "LE Read Supported States Command".
uint64_t le_states;
} __attribute__((packed));

// ====================================
// LE Receiver Test Command (v4.0) (LE)
constexpr OpCode kLEReceiverTest = LEControllerCommandOpCode(0x001D);
Expand Down

0 comments on commit 60a6b4d

Please sign in to comment.