1 /****************************************************************************** 2 * 3 * Copyright (C) 2022 Google, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 namespace bluetooth { 20 namespace hal { 21 22 constexpr uint32_t kBytesToTest = 0x12345678; 23 constexpr uint8_t kFirstByte = (const uint8_t&)kBytesToTest; 24 constexpr bool isLittleEndian = kFirstByte == 0x78; 25 constexpr bool isBigEndian = kFirstByte == 0x12; 26 static_assert((isLittleEndian || isBigEndian) && (isLittleEndian != isBigEndian)); 27 28 constexpr uint32_t BTSNOOP_VERSION_NUMBER = isLittleEndian ? 0x01000000 : 1; 29 constexpr uint32_t BTSNOOP_DATALINK_TYPE = 30 isLittleEndian ? 0xea030000 : 0x03ea; // Datalink Type code for HCI UART (H4) is 1002 31 32 class SnoopLoggerCommon { 33 public: 34 struct FileHeaderType { 35 uint8_t identification_pattern[8]; 36 uint32_t version_number; 37 uint32_t datalink_type; 38 } __attribute__((__packed__)); 39 40 static constexpr FileHeaderType kBtSnoopFileHeader = { 41 .identification_pattern = {'b', 't', 's', 'n', 'o', 'o', 'p', 0x00}, 42 .version_number = BTSNOOP_VERSION_NUMBER, 43 .datalink_type = BTSNOOP_DATALINK_TYPE}; 44 }; 45 46 } // namespace hal 47 } // namespace bluetooth 48