OSDN Git Service

Add main/shim/helpers::ToHciRole
authorChris Manton <cmanton@google.com>
Thu, 31 Dec 2020 00:19:12 +0000 (16:19 -0800)
committerChris Manton <cmanton@google.com>
Wed, 20 Jan 2021 16:05:28 +0000 (08:05 -0800)
Towards shimmable code

Bug: 176960731
Tag: #refactor
Test: gd/cert/run

Change-Id: I576be1908b70116b9aeeaa56c0e1601480ccbcb2

main/shim/helpers.h

index cb8c62c..beaa39f 100644 (file)
@@ -128,6 +128,17 @@ inline uint8_t ToLegacyRole(hci::Role role) {
   return static_cast<uint8_t>(role);
 }
 
+inline hci::Role ToHciRole(hci_role_t role) {
+  switch (role) {
+    case HCI_ROLE_CENTRAL:
+      return hci::Role::CENTRAL;
+    case HCI_ROLE_PERIPHERAL:
+      return hci::Role::PERIPHERAL;
+    default:
+      ASSERT_LOG(false, "Unable to determine legacy role:%u", role);
+  }
+}
+
 inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) {
   switch (reason) {
     case hci::ErrorCode::SUCCESS: