1 /*
2  * Copyright 2024 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 <cstdint>
20 #include <vector>
21 
22 #include "discovery/device/data_parser.h"
23 #include "hci/uuid.h"
24 
25 namespace bluetooth {
26 namespace discovery {
27 namespace device {
28 
29 struct service_uuid16_t {
30   uint16_t uuid;
31   std::vector<uint8_t> data;
32 };
33 
34 struct service_uuid32_t {
35   uint32_t uuid;
36   std::vector<uint8_t> data;
37 };
38 
39 class EirData : public DataParser {
40  public:
41   EirData(const std::vector<uint8_t>& data);
42 
43   bool GetCompleteNames(std::vector<std::array<uint8_t, 240>>&) const;
44   bool GetShortenedNames(std::vector<std::array<uint8_t, 240>>&) const;
45 
46   bool GetUuids16(std::vector<uint16_t>&) const;
47   bool GetUuidsIncomplete16(std::vector<uint16_t>&) const;
48   bool GetUuids32(std::vector<uint32_t>&) const;
49   bool GetUuidsIncomplete32(std::vector<uint32_t>&) const;
50   bool GetUuids128(std::vector<hci::Uuid>&) const;
51   bool GetUuidsIncomplete128(std::vector<hci::Uuid>&) const;
52 
53   bool GetDeviceId(std::vector<std::vector<uint8_t>>&) const;
54 
55   bool GetManufacturerSpecificData(std::vector<std::vector<uint8_t>>&) const;
56 
57   bool GetSecurityManagerOobFlags(std::vector<std::vector<uint8_t>>&) const;
58   bool GetServiceUuuids16(std::vector<service_uuid16_t>&) const;
59   bool GetServiceUuuids32(std::vector<service_uuid32_t>&) const;
60   bool GetTxPowerLevel(std::vector<int8_t>&) const;
61 };
62 
63 }  // namespace device
64 }  // namespace discovery
65 }  // namespace bluetooth
66