OSDN Git Service

enum-ify stack/include/bt_types::BT_PSM_
authorChris Manton <cmanton@google.com>
Fri, 13 Nov 2020 23:55:42 +0000 (15:55 -0800)
committerChris Manton <cmanton@google.com>
Tue, 17 Nov 2020 22:12:18 +0000 (22:12 +0000)
Toward readable code

Bug: 163134718
Tag: #refactor
Test: CtsVerifier

Change-Id: Icf24f483a807c28763bf677f5d01b13cc3c9c553

stack/include/bt_types.h

index e11a7a6..126fd55 100644 (file)
@@ -234,21 +234,31 @@ typedef struct {
 
 #define BT_HDR_SIZE (sizeof(BT_HDR))
 
-#define BT_PSM_SDP 0x0001
-#define BT_PSM_RFCOMM 0x0003
-#define BT_PSM_TCS 0x0005
-#define BT_PSM_CTP 0x0007
-#define BT_PSM_BNEP 0x000F
-#define BT_PSM_HIDC 0x0011
-#define BT_PSM_HIDI 0x0013
-#define BT_PSM_UPNP 0x0015
-#define BT_PSM_AVCTP 0x0017
-#define BT_PSM_AVDTP 0x0019
-#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */
-#define BT_PSM_UDI_CP \
-  0x001D /* Unrestricted Digital Information Profile C-Plane  */
-#define BT_PSM_ATT 0x001F /* Attribute Protocol  */
-#define BT_PSM_EATT 0x0027
+enum : uint16_t {
+  BT_PSM_SDP = 0x0001,
+  BT_PSM_RFCOMM = 0x0003,
+  BT_PSM_TCS = 0x0005,
+  TCS_PSM_INTERCOM = 5,
+  BT_PSM_CTP = 0x0007,
+  TCS_PSM_CORDLESS = 7,
+  BT_PSM_BNEP = 0x000F,
+  BT_PSM_HIDC = 0x0011,
+  HID_PSM_CONTROL = 0x0011,
+  BT_PSM_HIDI = 0x0013,
+  HID_PSM_INTERRUPT = 0x0013,
+  BT_PSM_UPNP = 0x0015,
+  BT_PSM_AVCTP = 0x0017,
+  BT_PSM_AVDTP = 0x0019,
+  BT_PSM_AVCTP_13 = 0x001B, /* Advanced Control - Browsing */
+  BT_PSM_UDI_CP =
+      0x001D,          /* Unrestricted Digital Information Profile C-Plane  */
+  BT_PSM_ATT = 0x001F, /* Attribute Protocol  */
+  BT_PSM_EATT = 0x0027,
+  /* We will not allocate a PSM in the reserved range to 3rd party apps
+   */
+  BRCM_RESERVED_PSM_START = 0x5AE1,
+  BRCM_RESERVED_PSM_END = 0x5AFF,
+};
 
 /* These macros extract the HCI opcodes from a buffer
  */
@@ -671,11 +681,6 @@ typedef struct {
 #define BT_EIR_SERVICE_DATA_128BITS_UUID_TYPE 0x21
 #define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF
 
-/* We will not allocate a PSM in the reserved range to 3rd party apps
- */
-#define BRCM_RESERVED_PSM_START 0x5AE1
-#define BRCM_RESERVED_PSM_END 0x5AFF
-
 /* Device Types
  */
 enum : uint8_t {
@@ -746,11 +751,4 @@ inline std::string DeviceTypeText(tBT_DEVICE_TYPE type) {
 #define TRACE_TYPE_EVENT 0x00000003
 #define TRACE_TYPE_DEBUG 0x00000004
 
-#define TCS_PSM_INTERCOM 5
-#define TCS_PSM_CORDLESS 7
-#define BT_PSM_BNEP 0x000F
-/* Define PSMs HID uses */
-#define HID_PSM_CONTROL 0x0011
-#define HID_PSM_INTERRUPT 0x0013
-
 #endif