xref: /aosp_15_r20/external/pigweed/pw_bluetooth/public/pw_bluetooth/avdtp.emb (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15# This file contains Emboss definitions of the protocol data units (PDUs)
16# associated with the Attribute Protocol (ATT) as defined in Vol 3 (Host), Part
17# F of the Bluetooth Core Specification. The Emboss compiler is used to generate
18# a C++ header from this file.
19
20[$default byte_order: "LittleEndian"]
21[(cpp) namespace: "pw::bluetooth::emboss::avdtp"]
22# cf. AVDTP Spec v1.3
23
24# Glossary
25# ACP: Acceptor
26# INT: Initiatior
27# RFA: Reserved for Future Addition
28# SEID: Stream End-point Identifier
29# SEP: Stream End Point
30# TSEP: Stream End Point Type
31
32enum PacketType:
33  -- cf. 8.4.2 Packet Type
34  [maximum_bits: 2]
35  SINGLE_PACKET   = 0b00
36  START_PACKET    = 0b01
37  CONTINUE_PACKET = 0b10
38  END_PACKET      = 0b11
39
40
41enum MessageType:
42  -- cf. 8.4.3 Message Type
43  [maximum_bits: 2]
44  COMMAND         = 0b00
45  GENERAL_REJECT  = 0b01
46  RESPONSE_ACCEPT = 0b10
47  RESPONSE_REJECT = 0b11
48
49
50enum SignalIdentifierCode:
51  -- cf. 8.5 Signaling message Identifier
52  AVDTP_DISCOVER             = 0x01
53  AVDTP_GET_CAPABILITIES     = 0x02
54  AVDT_SET_CONFIGURATION     = 0x03
55  AVDTP_GET_CONFIGURATION    = 0x04
56  AVDTP_RECONFIGURE          = 0x05
57  AVDTP_OPEN                 = 0x06
58  AVDTP_START                = 0x07
59  AVDTP_CLOSE                = 0x08
60  AVDTP_SUSPEND              = 0x09
61  AVDTP_ABORT                = 0x0A
62  AVDTP_SECURITY_CONTROL     = 0x0B
63  AVDTP_GET_ALL_CAPABILITIES = 0x0C
64  AVDTP_DELAYREPORT          = 0x0D
65
66
67enum Seid:
68  -- cf. 8.20.1 Stream End-point IDentifier(SEID, INT SEID, ACP SEID)
69  FORBIDDEN = 0x00
70  RFD       = 0x3F
71
72
73enum Tsep:
74  -- cf. 8.20.3 Stream End-point Type, Source or Sink
75  [maximum_bits: 1]
76  SRC = 0b0
77  SNK = 0b1
78
79
80enum InUse:
81  -- cf. 8.20.5 Stream End Point in Use
82  [maximum_bits: 1]
83  NOT_IN_USE = 0b0
84  IN_USE     = 0b1
85
86
87enum ErrorCode:
88  -- Cf. 8.20.6 Signaling Errors
89  -- Cf. 8.20.6.2 ERROR Code Tables
90  BAD_HEADER_FORMAT          = 0x01
91  BAD_LENGTH                 = 0x11
92  BAD_ACP_SEID               = 0x12
93  SEP_IN_USE                 = 0x13
94  SEP_NOT_IN_USE             = 0x14
95  BAD_SERV_CATEGORY          = 0x17
96  BAD_PAYLOAD_FORMAT         = 0x18
97  NOT_SUPPORTED_COMMAND      = 0x19
98  INVALID_CAPABILITIES       = 0x1A
99  BAD_RECOVERY_TYPE          = 0x22
100  BAD_MEDIA_TRANSPORT_FORMAT = 0x23
101  BAD_RECOVERY_FORMAT        = 0x25
102  BAD_ROHC_FORMAT            = 0x26
103  BAD_CP_FORMAT              = 0x27
104  BAD_MULTIPLEXING_FORMAT    = 0x28
105  UNSUPPORTED_CONFIGURATION  = 0x29
106  BAD_STATE                  = 0x31
107
108
109enum MediaType:
110  -- cf. Bluetooth SIG assigned numbers
111  AUDIO      = 0x00
112  VIDEO      = 0x01
113  MULTIMEDIA = 0x02
114
115
116struct Sep:
117  -- cf. 8.6.2 Stream End Point Discovery Response
118  0     [+1]  bits:
119    0     [+1]       UInt       reserved_for_future_addition
120    $next [+1]       InUse      in_use
121    $next [+6]       UInt       acp_seid
122
123  $next [+1]  bits:
124    0     [+3]       UInt       rfa
125    $next [+1]       Tsep       tsep
126    $next [+4]       MediaType  media_type
127
128# Cf 8. Signaling Messages
129
130
131struct SignalingHeader:
132  -- cf. 8.4 AVDTP Signaling header
133  0     [+1]  bits:
134    0     [+2]       MessageType           message_type
135    $next [+2]       PacketType            packet_type
136    $next [+4]       UInt                  transaction_label
137
138  1     [+1]  bits:
139    0     [+6]       SignalIdentifierCode  signal_identifier
140    $next [+2]       UInt                  rfa
141
142
143struct StreamEndPointDiscoveryCommand:
144  -- cf. 8.6.1  Stream End Point Discovery Command
145  -- AVDTP_DISCOVER_CMD
146  [requires: signaling_header.message_type == MessageType.COMMAND && signaling_header.signal_identifier == SignalIdentifierCode.AVDTP_DISCOVER]
147  0 [+2]  SignalingHeader  signaling_header
148
149
150struct StreamEndPointDiscoveryResponse:
151  -- cf. 8.6.2 Stream End Point Discovery Response
152  -- AVDTP_DISCOVER_RSP
153  [requires: signaling_header.message_type == MessageType.RESPONSE_ACCEPT && signaling_header.signal_identifier == SignalIdentifierCode.AVDTP_DISCOVER]
154  0 [+2]  SignalingHeader  signaling_header
155  1 [+2]  Sep              acp_sep
156
157
158struct StreamEndPointDiscoveryReject:
159  -- cf. 8.6.3 Stream End Point Discovery Reject
160  -- AVDTP_DISCOVER_REJ
161  [requires: signaling_header.message_type == MessageType.RESPONSE_REJECT && signaling_header.signal_identifier == SignalIdentifierCode.AVDTP_DISCOVER]
162  0     [+2]  SignalingHeader  signaling_header
163  $next [+1]  ErrorCode        error_code
164