Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Migrate ReadBdAddr event 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/+/1096951
GitOrigin-RevId: 8cf95b00695f6514362fbba57d24edae994a172e
Change-Id: I86757e387a75eea517a1df37439d280f62de2226
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230558
Reviewed-by: Josh Conner <joshconner@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Jason Graffius <jgraff@google.com>
  • Loading branch information
BenjaminLawson authored and CQ Bot Account committed Aug 23, 2024
1 parent 4ca3507 commit 63ff91d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pw_bluetooth_sapphire/host/gap/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -988,13 +988,13 @@ void AdapterImpl::InitializeStep1() {
init_seq_runner_->QueueCommand(
hci::EmbossCommandPacket::New<
pw::bluetooth::emboss::ReadBdAddrCommandView>(hci_spec::kReadBDADDR),
[this](const hci::EventPacket& cmd_complete) {
[this](const hci::EmbossEventPacket& cmd_complete) {
if (hci_is_error(cmd_complete, WARN, "gap", "read BR_ADDR failed")) {
return;
}
auto params =
cmd_complete.return_params<hci_spec::ReadBDADDRReturnParams>();
state_.controller_address = params->bd_addr;
auto packet = cmd_complete.view<
pw::bluetooth::emboss::ReadBdAddrCommandCompleteEventView>();
state_.controller_address = DeviceAddressBytes(packet.bd_addr());
});

if (state().IsControllerFeatureSupported(
Expand Down
12 changes: 7 additions & 5 deletions pw_bluetooth_sapphire/host/testing/fake_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1949,11 +1949,13 @@ void FakeController::OnReadBufferSize() {
}

void FakeController::OnReadBRADDR() {
hci_spec::ReadBDADDRReturnParams params;
params.status = pwemb::StatusCode::SUCCESS;
params.bd_addr = settings_.bd_addr.value();
RespondWithCommandComplete(hci_spec::kReadBDADDR,
BufferView(&params, sizeof(params)));
auto packet =
hci::EmbossEventPacket::New<pwemb::ReadBdAddrCommandCompleteEventWriter>(
hci_spec::kCommandCompleteEventCode);
auto view = packet.view_t();
view.status().Write(pwemb::StatusCode::SUCCESS);
view.bd_addr().CopyFrom(settings_.bd_addr.value().view());
RespondWithCommandComplete(hci_spec::kReadBDADDR, &packet);
}

void FakeController::OnLESetAdvertisingEnable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,6 @@ constexpr OpCode kReadBufferSize = InformationalParamsOpCode(0x0005);
// Read BD_ADDR Command (v1.1) (BR/EDR, LE)
constexpr OpCode kReadBDADDR = InformationalParamsOpCode(0x0009);

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

DeviceAddressBytes bd_addr;
} __attribute__((packed));

// =======================================================
// Read Data Block Size Command (v3.0 + HS) (BR/EDR & AMP)
constexpr OpCode kReadDataBlockSize = InformationalParamsOpCode(0x000A);
Expand Down

0 comments on commit 63ff91d

Please sign in to comment.