Skip to content

Commit

Permalink
pw_bluetooth_proxy: Add missing fields to l2cap coc move
Browse files Browse the repository at this point in the history
Also group mutex protected fields together to make it easier to compare
for future move changes.

Change-Id: If90bdf274de6a17fe1168540036422f59babdf92
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/256094
Docs-Not-Needed: Ben Lawson <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Lint: Lint 🤖 <[email protected]>
Docs-Not-Needed: David Rees <[email protected]>
Reviewed-by: Ben Lawson <[email protected]>
Pigweed-Auto-Submit: David Rees <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Commit-Queue: David Rees <[email protected]>
  • Loading branch information
studgeek authored and CQ Bot Account committed Dec 23, 2024
1 parent 06df658 commit 4bbfa84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions pw_bluetooth_proxy/l2cap_coc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ L2capCoc::L2capCoc(L2capCoc&& other)
std::lock_guard other_lock(other.mutex_);
tx_credits_ = other.tx_credits_;
remaining_sdu_bytes_to_ignore_ = other.remaining_sdu_bytes_to_ignore_;
rx_sdu_ = std::move(other.rx_sdu_);
rx_sdu_offset_ = other.rx_sdu_offset_;
rx_sdu_bytes_remaining_ = other.rx_sdu_bytes_remaining_;
}

pw::Status L2capCoc::Write(pw::span<const uint8_t> payload) {
Expand Down Expand Up @@ -374,10 +377,9 @@ L2capCoc::L2capCoc(
rx_mps_(rx_config.mps),
tx_mtu_(tx_config.mtu),
tx_mps_(tx_config.mps),
tx_credits_(tx_config.credits),
remaining_sdu_bytes_to_ignore_(0),
payload_from_controller_fn_(std::move(payload_from_controller_fn)),
receive_fn_multibuf_(std::move(receive_fn_multibuf)) {}
receive_fn_multibuf_(std::move(receive_fn_multibuf)),
tx_credits_(tx_config.credits) {}

std::optional<H4PacketWithH4> L2capCoc::DequeuePacket() {
if (state() != State::kRunning) {
Expand Down
8 changes: 4 additions & 4 deletions pw_bluetooth_proxy/public/pw_bluetooth_proxy/l2cap_coc.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ class L2capCoc : public L2capChannel {

multibuf::MultiBufAllocator& rx_multibuf_allocator_;
L2capSignalingChannel* signaling_channel_;
sync::Mutex mutex_;
uint16_t rx_mtu_;
uint16_t rx_mps_;
uint16_t tx_mtu_;
uint16_t tx_mps_;
uint16_t tx_credits_ PW_GUARDED_BY(mutex_);
uint16_t remaining_sdu_bytes_to_ignore_ PW_GUARDED_BY(mutex_);
Function<void(pw::span<uint8_t> payload)> payload_from_controller_fn_;

Function<void(multibuf::MultiBuf&& payload)> receive_fn_multibuf_;

sync::Mutex mutex_;
uint16_t tx_credits_ PW_GUARDED_BY(mutex_);
uint16_t remaining_sdu_bytes_to_ignore_ PW_GUARDED_BY(mutex_) = 0;
std::optional<multibuf::MultiBuf> rx_sdu_ PW_GUARDED_BY(mutex_);
uint16_t rx_sdu_offset_ PW_GUARDED_BY(mutex_) = 0;
uint16_t rx_sdu_bytes_remaining_ PW_GUARDED_BY(mutex_) = 0;
Expand Down

0 comments on commit 4bbfa84

Please sign in to comment.