Skip to content

Commit

Permalink
pw_bluetooth: Add frame_type and poll_final definitions for rfcomm
Browse files Browse the repository at this point in the history
Add ability to extract the different portions of control.

Change-Id: Ie42ee8bfc14cbd0ad745965f391e1c9f3bcde176
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/254473
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Austin Foxley <afoxley@google.com>
Reviewed-by: Ben Lawson <benlawson@google.com>
Docs-Not-Needed: Austin Foxley <afoxley@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
  • Loading branch information
afoxley authored and CQ Bot Account committed Dec 13, 2024
1 parent 0944913 commit 0ea7157
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pw_bluetooth/public/pw_bluetooth/rfcomm_frames.emb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ struct RfcommFrame:
let uih = control == RfcommFrameType.UNNUMBERED_INFORMATION_WITH_HEADER_CHECK || control == RfcommFrameType.UNNUMBERED_INFORMATION_WITH_HEADER_CHECK_AND_POLL_FINAL
-- Helper flag to check whether frame is UIH type, regardless of whether credits are in use.

let flow_control = control == RfcommFrameType.UNNUMBERED_INFORMATION_WITH_HEADER_CHECK_AND_POLL_FINAL
-- Helper to check whether RFCOMM credits are allowed in this frame.

# Overlapping with control to split up frame_type and poll_final

1 [+1] bits:

0 [+4] UInt frame_type_1

4 [+1] UInt poll_final

5 [+3] UInt frame_type_2
-- ETSI TS 07.10 section 5.2.1.3

let frame_type = frame_type_1+frame_type_2*32
-- Helper to extract frame type value without poll_final bit

2 [+1] bits:

0 [+1] RfcommLengthExtended length_extended_flag
Expand All @@ -110,7 +127,7 @@ struct RfcommFrame:

let credits_offset = $present(length_extended) ? 4 : 3

if control == RfcommFrameType.UNNUMBERED_INFORMATION_WITH_HEADER_CHECK_AND_POLL_FINAL && channel != 0:
if flow_control && channel != 0:
credits_offset [+1] UInt credits
-- Credits field can appears as first byte of information when Poll/Final
-- bit is set on UIH frames and channel is not control (0).
Expand Down

0 comments on commit 0ea7157

Please sign in to comment.