Skip to content

Commit

Permalink
pw_bluetooth: Add avdtp parser fundation
Browse files Browse the repository at this point in the history
Bug: 381291639
Change-Id: I7d56af5d30fc36c652008944a7f307fdcb8e57c3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/251433
Reviewed-by: Ben Lawson <[email protected]>
Docs-Not-Needed: Ben Lawson <[email protected]>
Commit-Queue: Charlie Boutier <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
SilverBzH authored and CQ Bot Account committed Nov 28, 2024
1 parent e431fab commit 5172ccd
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pw_bluetooth/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ pw_cc_test(
],
)

emboss_cc_library(
name = "_emboss_avdtp",
srcs = ["public/pw_bluetooth/avdtp.emb"],
enable_enum_traits = False,
import_dirs = ["public"],
visibility = ["//visibility:private"],
)

emboss_cc_library(
name = "_emboss_att",
srcs = ["public/pw_bluetooth/att.emb"],
Expand All @@ -187,6 +195,12 @@ emboss_cc_library(
],
)

cc_library(
name = "emboss_avdtp",
includes = ["public"],
deps = [":_emboss_avdtp"],
)

cc_library(
name = "emboss_att",
includes = ["public"],
Expand Down
75 changes: 75 additions & 0 deletions pw_bluetooth/public/pw_bluetooth/avdtp.emb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# This file contains Emboss definitions of the protocol data units (PDUs)
# associated with the Attribute Protocol (ATT) as defined in Vol 3 (Host), Part
# F of the Bluetooth Core Specification. The Emboss compiler is used to generate
# a C++ header from this file.

[$default byte_order: "LittleEndian"]
[(cpp) namespace: "pw::bluetooth::emboss"]
# cf. AVDTP Spec v1.3


enum AvdtpPacketType:
-- cf. 8.4.2 Packet Type
[maximum_bits: 2]
SINGLE_PACKET = 0b00
START_PACKET = 0b01
CONTINUE_PACKET = 0b10
END_PACKET = 0b11


enum AvdtpMessageType:
-- cf. 8.4.3 Message Type
[maximum_bits: 2]
COMMAND = 0b00
GENERAL_REJECT = 0b01
RESPONSE_ACCEPT = 0b10
RESPONSE_REJECT = 0b11


enum AvdtpSignalIdentifierCode:
-- cf. 8.5 Signaling message Identifier
AVDTP_DISCOVER = 0x01
AVDTP_GET_CAPABILITIES = 0x02
AVDT_SET_CONFIGURATION = 0x03
AVDTP_GET_CONFIGURATION = 0x04
AVDTP_RECONFIGURE = 0x05
AVDTP_OPEN = 0x06
AVDTP_START = 0x07
AVDTP_CLOSE = 0x08
AVDTP_SUSPEND = 0x09
AVDTP_ABORT = 0x0A
AVDTP_SECURITY_CONTROL = 0x0B
AVDTP_GET_ALL_CAPABILITIES = 0x0C
AVDTP_DELAYREPORT = 0x0D


struct AvdtpSignalingHeader:
-- cf. 8.4 AVDTP Signaling header
0 [+1] bits:
0 [+2] AvdtpMessageType message_type
$next [+2] AvdtpPacketType packet_type
$next [+4] UInt transaction_label

1 [+1] bits:
0 [+6] AvdtpSignalIdentifierCode signal_identifier
$next [+2] UInt reserved_for_future_addition


struct AvdtpStreamEndPointDiscoveryCommand:
-- cf. 8.6.1 AVDTP_DISCOVER_CMD
[requires: signaling_header.message_type == AvdtpMessageType.COMMAND && signaling_header.signal_identifier == AvdtpSignalIdentifierCode.AVDTP_DISCOVER]
0 [+2] AvdtpSignalingHeader signaling_header

0 comments on commit 5172ccd

Please sign in to comment.