blob: 71b619161df91d776ff751e7248f7cfac996b0b9 [file] [log] [blame]
Myles Watsone4501e52022-09-30 06:20:50 -07001/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cstdlib>
20
21namespace android::hardware::bluetooth::hci {
22
23// HCI UART transport packet types (Volume 4, Part A, 2)
24enum class PacketType : uint8_t {
25 UNKNOWN = 0,
26 COMMAND = 1,
27 ACL_DATA = 2,
28 SCO_DATA = 3,
29 EVENT = 4,
30 ISO_DATA = 5,
31};
32
33// 2 bytes for opcode, 1 byte for parameter length (Volume 4, Part E, 5.4.1)
34static constexpr size_t kCommandHeaderSize = 3;
35static constexpr size_t kCommandLengthOffset = 2;
36
37// 2 bytes for handle, 2 bytes for data length (Volume 4, Part E, 5.4.2)
38static constexpr size_t kAclHeaderSize = 4;
39static constexpr size_t kAclLengthOffset = 2;
40
41// 2 bytes for handle, 1 byte for data length (Volume 4, Part E, 5.4.3)
42static constexpr size_t kScoHeaderSize = 3;
43static constexpr size_t kScoLengthOffset = 2;
44
45// 1 byte for event code, 1 byte for parameter length (Volume 4, Part E, 5.4.4)
46static constexpr size_t kEventHeaderSize = 2;
47static constexpr size_t kEventLengthOffset = 1;
48
49// 2 bytes for handle, 2 bytes for data length (Volume 4, Part E, 5.4.5)
50static constexpr size_t kIsoHeaderSize = 4;
51static constexpr size_t kIsoLengthOffset = 2;
52
53static constexpr size_t kMaxHeaderSize = kAclHeaderSize;
54
55} // namespace android::hardware::bluetooth::hci