• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 <string>
20 
21 /* HCI role definitions */
22 typedef enum : uint8_t {
23   HCI_ROLE_CENTRAL = 0x00,
24   HCI_ROLE_PERIPHERAL = 0x01,
25   HCI_ROLE_UNKNOWN = 0xff,
26 } tHCI_ROLE;
27 
hci_role_text(const tHCI_ROLE & role)28 inline std::string hci_role_text(const tHCI_ROLE& role) {
29   switch (role) {
30     case HCI_ROLE_CENTRAL:
31       return std::string("central");
32     case HCI_ROLE_PERIPHERAL:
33       return std::string("peripheral");
34     default:
35       return std::string("unknown");
36   }
37 }
38 
to_hci_role(const uint8_t & role)39 inline tHCI_ROLE to_hci_role(const uint8_t& role) {
40   if (role == 0)
41     return HCI_ROLE_CENTRAL;
42   else if (role == 1)
43     return HCI_ROLE_PERIPHERAL;
44   else
45     return HCI_ROLE_UNKNOWN;
46 }
47 
48 typedef tHCI_ROLE hci_role_t;         // LEGACY
49 const auto RoleText = hci_role_text;  // LEGACY
50