Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Embossify ReadPageScanActivityReturnParams
Browse files Browse the repository at this point in the history
Use emboss definitions instead of a packed struct for reading a
Read Page Scan Activity command complete event.

Bug: b/42167863
Test: fx test //src/connectivity/bluetooth/core/bt-host
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1107957
GitOrigin-RevId: d8baa58398722fbc116a2176cb166fa00f4f81c0
Change-Id: I7002e140cf522e35753fb4b4edd4967a4b8b695b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232775
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Ben Lawson <[email protected]>
Pigweed-Auto-Submit: Jason Graffius <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
josh-conner authored and CQ Bot Account committed Aug 31, 2024
1 parent 7286a9d commit 4df6f28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
17 changes: 9 additions & 8 deletions pw_bluetooth_sapphire/host/testing/fake_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1831,14 +1831,15 @@ void FakeController::OnWritePageScanActivity(
}

void FakeController::OnReadPageScanActivity() {
hci_spec::ReadPageScanActivityReturnParams params;
params.status = pwemb::StatusCode::SUCCESS;
params.page_scan_interval =
pw::bytes::ConvertOrderTo(cpp20::endian::little, page_scan_interval_);
params.page_scan_window =
pw::bytes::ConvertOrderTo(cpp20::endian::little, page_scan_window_);
RespondWithCommandComplete(hci_spec::kReadPageScanActivity,
BufferView(&params, sizeof(params)));
auto event_packet = hci::EmbossEventPacket::New<
pwemb::ReadPageScanActivityCommandCompleteEventWriter>(
hci_spec::kCommandCompleteEventCode);
auto view = event_packet.view_t();
view.status().Write(pwemb::StatusCode::SUCCESS);
view.page_scan_interval().Write(page_scan_interval_);
view.page_scan_window().Write(page_scan_window_);
RespondWithCommandComplete(pwemb::OpCode::READ_PAGE_SCAN_ACTIVITY,
&event_packet);
}

void FakeController::OnWriteScanEnable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,6 @@ constexpr OpCode kWriteScanEnable = ControllerAndBasebandOpCode(0x001A);
// Read Page Scan Activity Command (v1.1) (BR/EDR)
constexpr OpCode kReadPageScanActivity = ControllerAndBasebandOpCode(0x001B);

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

// Page_Scan_Interval, in time slices (0.625ms)
// Range: kPageScanIntervalMin - kPageScanIntervalMax in hci_constants.h
uint16_t page_scan_interval;

// Page_Scan_Window, in time slices
// Range: kPageScanWindowMin - kPageScanWindowMax in hci_constants.h
uint16_t page_scan_window;
} __attribute__((packed));

// ================================================
// Write Page Scan Activity Command (v1.1) (BR/EDR)
constexpr OpCode kWritePageScanActivity = ControllerAndBasebandOpCode(0x001C);
Expand Down

0 comments on commit 4df6f28

Please sign in to comment.