OSDN Git Service

Add stack/include/bt_types::DeviceTypeText
authorChris Manton <cmanton@google.com>
Thu, 17 Sep 2020 23:20:40 +0000 (16:20 -0700)
committerChris Manton <cmanton@google.com>
Sat, 19 Sep 2020 19:44:34 +0000 (12:44 -0700)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I360800a8bc66902cefe926ca23d4158e43f726c5

stack/include/bt_types.h

index afc6f6e..27b8082 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#ifdef __cplusplus
+#include <string>
+#endif  // __cplusplus
 
 #ifndef FALSE
 #define FALSE false
@@ -802,6 +805,21 @@ struct tBLE_BD_ADDR {
 #define BT_DEVICE_TYPE_BLE 0x02
 #define BT_DEVICE_TYPE_DUMO 0x03
 typedef uint8_t tBT_DEVICE_TYPE;
+#ifdef __cplusplus
+inline std::string DeviceTypeText(tBT_DEVICE_TYPE type) {
+  switch (type) {
+    case BT_DEVICE_TYPE_BREDR:
+      return std::string("BR_EDR");
+    case BT_DEVICE_TYPE_BLE:
+      return std::string("BLE");
+    case BT_DEVICE_TYPE_DUMO:
+      return std::string("BR_EDR and BLE");
+    default:
+      return std::string("Unknown");
+  }
+}
+#endif  // __cplusplus
+
 /*****************************************************************************/
 
 /* Define trace levels */