Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ca70a58 authored by Chris Manton's avatar Chris Manton
Browse files

Add stack/include/hcidefs::hci_role helpers and aliases

Bug: 179120287
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I37ec49c8aaac76d49a0f96387129652975a6fa50
parent 43ede325
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -703,6 +703,7 @@ enum : uint8_t {
  HCI_ROLE_UNKNOWN = 0xff,
};
typedef uint8_t hci_role_t;
typedef hci_role_t tHCI_ROLE;
inline std::string RoleText(hci_role_t role) {
  switch (role) {
    case HCI_ROLE_CENTRAL:
@@ -713,6 +714,16 @@ inline std::string RoleText(hci_role_t role) {
      return std::string("unknown");
  }
}
const auto hci_role_text = RoleText;

inline tHCI_ROLE to_hci_role(const uint8_t& role) {
  if (role == 0)
    return HCI_ROLE_CENTRAL;
  else if (role == 1)
    return HCI_ROLE_PERIPHERAL;
  else
    return HCI_ROLE_UNKNOWN;
}

/* HCI mode defenitions */
typedef enum : uint8_t {