OSDN Git Service

Enum-ify tSMP_EVT
authorChris Manton <cmanton@google.com>
Tue, 2 Mar 2021 20:32:59 +0000 (12:32 -0800)
committerChris Manton <cmanton@google.com>
Wed, 14 Apr 2021 15:32:14 +0000 (08:32 -0700)
Toward readable code

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

Change-Id: I12e2d8d7d1f8ddb05a6b9b673c74013fda5a0d22

stack/include/smp_api_types.h

index 6318129..955402b 100644 (file)
@@ -44,24 +44,27 @@ typedef enum : uint8_t {
 } tSMP_OPCODE;
 
 /* SMP event type */
-#define SMP_EVT_NONE 0           /* Default no event */
-#define SMP_IO_CAP_REQ_EVT 1     /* IO capability request event */
-#define SMP_SEC_REQUEST_EVT 2    /* SMP pairing request */
-#define SMP_PASSKEY_NOTIF_EVT 3  /* passkey notification event */
-#define SMP_PASSKEY_REQ_EVT 4    /* passkey request event */
-#define SMP_OOB_REQ_EVT 5        /* OOB request event */
-#define SMP_NC_REQ_EVT 6         /* Numeric Comparison request event */
-#define SMP_COMPLT_EVT 7         /* SMP complete event */
-#define SMP_PEER_KEYPR_NOT_EVT 8 /* Peer keypress notification */
-
-/* SC OOB request event (both local and peer OOB data can be expected in
- * response) */
-#define SMP_SC_OOB_REQ_EVT 9
-/* SC OOB local data set is created (as result of SMP_CrLocScOobData(...)) */
-#define SMP_SC_LOC_OOB_DATA_UP_EVT 10
-#define SMP_BR_KEYS_REQ_EVT 12 /* SMP over BR keys request event */
-#define SMP_CONSENT_REQ_EVT 14 /* Consent request event */
-typedef uint8_t tSMP_EVT;
+typedef enum : uint8_t {
+  SMP_EVT_NONE = 0,           /* Default no event */
+  SMP_IO_CAP_REQ_EVT = 1,     /* IO capability request event */
+  SMP_SEC_REQUEST_EVT = 2,    /* SMP pairing request */
+  SMP_PASSKEY_NOTIF_EVT = 3,  /* passkey notification event */
+  SMP_PASSKEY_REQ_EVT = 4,    /* passkey request event */
+  SMP_OOB_REQ_EVT = 5,        /* OOB request event */
+  SMP_NC_REQ_EVT = 6,         /* Numeric Comparison request event */
+  SMP_COMPLT_EVT = 7,         /* SMP complete event */
+  SMP_PEER_KEYPR_NOT_EVT = 8, /* Peer keypress notification */
+
+  /* SC OOB request event (both local and peer OOB data can be expected in
+   * response) */
+  SMP_SC_OOB_REQ_EVT = 9,
+  /* SC OOB local data set is created (as result of SMP_CrLocScOobData(...)) */
+  SMP_SC_LOC_OOB_DATA_UP_EVT = 10,
+  SMP_UNUSED11 = 11,
+  SMP_BR_KEYS_REQ_EVT = 12, /* SMP over BR keys request event */
+  SMP_UNUSED13 = 13,
+  SMP_CONSENT_REQ_EVT = 14, /* Consent request event */
+} tSMP_EVT;
 
 /* pairing failure reason code */
 #define SMP_PASSKEY_ENTRY_FAIL 0x01