1 /* 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 21 namespace android::hardware::bluetooth::hci { 22 23 // HCI UART transport packet types (Volume 4, Part A, 2) 24 enum 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) 34 static constexpr size_t kCommandHeaderSize = 3; 35 static constexpr size_t kCommandLengthOffset = 2; 36 37 // 2 bytes for handle, 2 bytes for data length (Volume 4, Part E, 5.4.2) 38 static constexpr size_t kAclHeaderSize = 4; 39 static constexpr size_t kAclLengthOffset = 2; 40 41 // 2 bytes for handle, 1 byte for data length (Volume 4, Part E, 5.4.3) 42 static constexpr size_t kScoHeaderSize = 3; 43 static constexpr size_t kScoLengthOffset = 2; 44 45 // 1 byte for event code, 1 byte for parameter length (Volume 4, Part E, 5.4.4) 46 static constexpr size_t kEventHeaderSize = 2; 47 static constexpr size_t kEventLengthOffset = 1; 48 49 // 2 bytes for handle, 2 bytes for data length (Volume 4, Part E, 5.4.5) 50 static constexpr size_t kIsoHeaderSize = 4; 51 static constexpr size_t kIsoLengthOffset = 2; 52 53 static constexpr size_t kMaxHeaderSize = kAclHeaderSize; 54 55 } // namespace android::hardware::bluetooth::hci 56