OSDN Git Service

Add text hci error code logging
authorChris Manton <cmanton@google.com>
Mon, 14 Sep 2020 17:17:32 +0000 (10:17 -0700)
committerChris Manton <cmanton@google.com>
Fri, 18 Sep 2020 17:50:12 +0000 (10:50 -0700)
Towards loggable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Test: act.py -tc BleCocTest

Change-Id: Idc6801ba860a4f96554431c1dbd408a8e651a6e1

stack/include/hci_error_code.h

index e80ac63..0bf5618 100644 (file)
 #define HCI_ERR_LIMIT_REACHED 0x43  // stack/btm/btm_ble_multi_adv.cc
 
 #define HCI_ERR_MAX_ERR 0x43  // TODO remove. randomly used
+
+inline std::string hci_error_code_text(uint16_t error_code) {
+  switch (error_code) {
+    case HCI_ERR_CONNECTION_TOUT:
+      return std::string("Connection Timeout");
+    case HCI_ERR_PEER_USER:
+      return std::string("Remote Terminated Connection");
+    case HCI_ERR_CONN_CAUSE_LOCAL_HOST:
+      return std::string("Local Terminated Connection");
+    default:
+      return std::string("Unknown Error");
+  }
+}