1 /* 2 * Copyright 2017 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 #define LOG_TAG "sco_packet" 18 19 #include "sco_packet.h" 20 21 #include "stack/include/hcidefs.h" 22 23 using std::vector; 24 25 namespace test_vendor_lib { 26 27 ScoPacket::ScoPacket(uint16_t channel, 28 ScoPacket::PacketStatusFlags packet_status) 29 : Packet(DATA_TYPE_SCO, 30 {static_cast<uint8_t>(channel & 0xff), 31 static_cast<uint8_t>(((channel >> 8) & 0x0f) | 32 (packet_status & 0x3 << 4))}) {} 33 34 uint16_t ScoPacket::GetChannel() const { 35 return (GetHeader()[0] | (GetHeader()[1] << 8)) & 0xfff; 36 } 37 38 ScoPacket::PacketStatusFlags ScoPacket::GetPacketStatusFlags() const { 39 return static_cast<ScoPacket::PacketStatusFlags>((GetHeader()[1] >> 4) & 0x3); 40 } 41 42 } // namespace test_vendor_lib 43