OSDN Git Service

Add stack/l2cap/l2c_int::link_state_text
authorChris Manton <cmanton@google.com>
Fri, 20 Nov 2020 20:31:46 +0000 (12:31 -0800)
committerChris Manton <cmanton@google.com>
Tue, 24 Nov 2020 06:19:54 +0000 (22:19 -0800)
Toward loggable code

Bug: 163134718
Tag: #refactor
Test: CtsVerifier

Change-Id: If32f14beece68e85f7cbf345a3f694c1f2553bdb

stack/l2cap/l2c_int.h

index 0f8d39f..c107d8e 100644 (file)
@@ -25,6 +25,7 @@
 #define L2C_INT_H
 
 #include <stdbool.h>
+#include <string>
 
 #include "bt_common.h"
 #include "btm_api.h"
@@ -89,6 +90,25 @@ typedef enum {
   LST_DISCONNECTING
 } tL2C_LINK_STATE;
 
+inline std::string link_state_text(const tL2C_LINK_STATE& state) {
+  switch (state) {
+    case LST_DISCONNECTED:
+      return std::string("LST_DISCONNECTED");
+    case LST_CONNECT_HOLDING:
+      return std::string("LST_CONNECT_HOLDING");
+    case LST_CONNECTING_WAIT_SWITCH:
+      return std::string("LST_CONNECTING_WAIT_SWITCH");
+    case LST_CONNECTING:
+      return std::string("LST_CONNECTING");
+    case LST_CONNECTED:
+      return std::string("LST_CONNECTED");
+    case LST_DISCONNECTING:
+      return std::string("LST_DISCONNECTING");
+    default:
+      return std::string("UNKNOWN");
+  }
+}
+
 /* Define input events to the L2CAP link and channel state machines. The names
  * of the events may seem a bit strange, but they are taken from
  * the Bluetooth specification.