OSDN Git Service

Add bta/include/bta_api::preferred_role_text
authorChris Manton <cmanton@google.com>
Fri, 29 Jan 2021 23:58:12 +0000 (15:58 -0800)
committerChris Manton <cmanton@google.com>
Wed, 3 Feb 2021 05:26:20 +0000 (21:26 -0800)
Towards loggable code

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

Change-Id: I105d807a90ede26af7b0ef59a3a0e5b989997799

bta/include/bta_api.h

index 5fadcc3..5b97357 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "bt_target.h"  // Must be first to define build configuration
 
+#include "osi/include/log.h"
 #include "stack/include/bt_types.h"
 #include "stack/include/btm_api_types.h"
 #include "stack/include/btm_ble_api_types.h"
@@ -127,6 +128,17 @@ typedef uint16_t tBTA_DM_CONN;
 
 typedef uint8_t tBTA_PREF_ROLES;
 
+inline std::string preferred_role_text(const tBTA_PREF_ROLES& role) {
+  switch (role) {
+    CASE_RETURN_TEXT(BTA_ANY_ROLE);
+    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_PREF);
+    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_ONLY);
+    CASE_RETURN_TEXT(BTA_PERIPHERAL_ROLE_ONLY);
+    default:
+      return std::string("UNKNOWN:%hhu", role);
+  }
+}
+
 enum {
 
   BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might