OSDN Git Service

Properly type stack/smp::tSMP_EVT
authorChris Manton <cmanton@google.com>
Tue, 2 Mar 2021 20:32:50 +0000 (12:32 -0800)
committerChris Manton <cmanton@google.com>
Mon, 8 Mar 2021 21:32:03 +0000 (13:32 -0800)
Bug: 163134718
Test: cert
Tag: #refactor

Change-Id: I9a8cc028eaf994b9b8b94d62ddaae05f4cb038e8

stack/include/smp_api_types.h
stack/smp/smp_act.cc
stack/smp/smp_api.cc
stack/smp/smp_int.h

index 2438813..6318129 100644 (file)
@@ -44,6 +44,7 @@ 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 */
index 1e38c13..ccb843e 100644 (file)
@@ -132,6 +132,7 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
         break;
 
       default:
+        LOG_ERROR("Unexpected event:%hhu", p_cb->cb_evt);
         break;
     }
 
@@ -218,6 +219,9 @@ void smp_send_app_cback(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
 
           smp_br_state_machine_event(p_cb, SMP_BR_KEYS_RSP_EVT, NULL);
           break;
+
+        default:
+          LOG_ERROR("Unexpected event: %hhu", p_cb->cb_evt);
       }
     }
   }
@@ -429,7 +433,7 @@ void smp_proc_sec_req(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
 
   SMP_TRACE_DEBUG("%s: auth_req=0x%x", __func__, auth_req);
 
-  p_cb->cb_evt = 0;
+  p_cb->cb_evt = SMP_EVT_NONE;
 
   btm_ble_link_sec_check(p_cb->pairing_bda, auth_req, &sec_req_act);
 
index 28eb539..fd38b80 100644 (file)
@@ -316,7 +316,7 @@ void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res) {
 
     /* clear the SMP_SEC_REQUEST_EVT event after get grant */
     /* avoid generating duplicate pair request */
-    smp_cb.cb_evt = 0;
+    smp_cb.cb_evt = SMP_EVT_NONE;
     tSMP_INT_DATA smp_int_data;
     smp_int_data.status = res;
     smp_br_state_machine_event(&smp_cb, SMP_BR_API_SEC_GRANT_EVT,
@@ -329,7 +329,7 @@ void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res) {
     return;
   /* clear the SMP_SEC_REQUEST_EVT event after get grant */
   /* avoid generate duplicate pair request */
-  smp_cb.cb_evt = 0;
+  smp_cb.cb_evt = SMP_EVT_NONE;
   tSMP_INT_DATA smp_int_data;
   smp_int_data.status = res;
   smp_sm_event(&smp_cb, SMP_API_SEC_GRANT_EVT, &smp_int_data);
index 9e415d4..454cfcb 100644 (file)
@@ -237,7 +237,7 @@ typedef struct {
   uint8_t status;
   uint8_t role;
   uint16_t flags;
-  uint8_t cb_evt;
+  tSMP_EVT cb_evt;
   tSMP_SEC_LEVEL sec_level;
   bool connect_initialized;
   Octet16 confirm;