You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/07/13 18:07:50 UTC

[4/4] incubator-mynewt-core git commit: BLE Host - gattc: dsc refers to chr val handle.

BLE Host - gattc: dsc refers to chr val handle.

Prior to this change, the corresponding characteristic's definition
handle was required to initiate descriptor discovery.  Now it is the
characteristic's *value* handle.

Rationale: an app likely doesn't care at all about characteristic
definition handles; it is the value handles that are interesting.  The
app should not need to calculate the definition handle from the value
handle just to discover descriptors.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c7c7c9c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c7c7c9c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c7c7c9c1

Branch: refs/heads/ble_hs_api
Commit: c7c7c9c18febecf9a36231c9e4dc416a40f684d3
Parents: e588bbb
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jul 13 10:47:15 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jul 13 10:47:15 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_gattc.c                 | 16 ++---
 net/nimble/host/src/test/ble_gatt_conn_test.c   |  4 +-
 net/nimble/host/src/test/ble_gatt_disc_d_test.c | 72 ++++++++++----------
 3 files changed, 46 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7c7c9c1/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index 825365b..6a5e8ec 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -138,7 +138,7 @@ struct ble_gattc_proc {
         } disc_chr_uuid;
 
         struct {
-            uint16_t chr_def_handle;
+            uint16_t chr_val_handle;
             uint16_t prev_handle;
             uint16_t end_handle;
             ble_gatt_dsc_fn *cb;
@@ -447,8 +447,8 @@ static void
 ble_gattc_log_disc_all_dscs(struct ble_gattc_proc *proc)
 {
     ble_gattc_log_proc_init("discover all descriptors; ");
-    BLE_HS_LOG(INFO, "chr_def_handle=%d end_handle=%d\n",
-               proc->disc_all_dscs.chr_def_handle,
+    BLE_HS_LOG(INFO, "chr_val_handle=%d end_handle=%d\n",
+               proc->disc_all_dscs.chr_val_handle,
                proc->disc_all_dscs.end_handle);
 }
 
@@ -2255,7 +2255,7 @@ ble_gattc_disc_all_dscs_cb(struct ble_gattc_proc *proc, int status,
     } else {
         rc = proc->disc_all_dscs.cb(proc->conn_handle,
                                     ble_gattc_error(status, att_handle),
-                                    proc->disc_all_dscs.chr_def_handle,
+                                    proc->disc_all_dscs.chr_val_handle,
                                     dsc, proc->disc_all_dscs.cb_arg);
     }
 
@@ -2376,7 +2376,7 @@ ble_gattc_disc_all_dscs_rx_complete(struct ble_gattc_proc *proc, int status)
  *
  * @param conn_handle           The connection over which to execute the
  *                                  procedure.
- * @param chr_def_handle        The handle of the characteristic definition
+ * @param chr_val_handle        The handle of the characteristic value
  *                                  attribute.
  * @param chr_end_handle        The last handle in the characteristic
  *                                  definition.
@@ -2388,7 +2388,7 @@ ble_gattc_disc_all_dscs_rx_complete(struct ble_gattc_proc *proc, int status)
  * @return                      0 on success; nonzero on failure.
  */
 int
-ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_def_handle,
+ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_val_handle,
                         uint16_t chr_end_handle,
                         ble_gatt_dsc_fn *cb, void *cb_arg)
 {
@@ -2409,8 +2409,8 @@ ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_def_handle,
 
     proc->op = BLE_GATT_OP_DISC_ALL_DSCS;
     proc->conn_handle = conn_handle;
-    proc->disc_all_dscs.chr_def_handle = chr_def_handle;
-    proc->disc_all_dscs.prev_handle = chr_def_handle + 1;
+    proc->disc_all_dscs.chr_val_handle = chr_val_handle;
+    proc->disc_all_dscs.prev_handle = chr_val_handle;
     proc->disc_all_dscs.end_handle = chr_end_handle;
     proc->disc_all_dscs.cb = cb;
     proc->disc_all_dscs.cb_arg = cb_arg;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7c7c9c1/net/nimble/host/src/test/ble_gatt_conn_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_conn_test.c b/net/nimble/host/src/test/ble_gatt_conn_test.c
index 2617dfc..9441e20 100644
--- a/net/nimble/host/src/test/ble_gatt_conn_test.c
+++ b/net/nimble/host/src/test/ble_gatt_conn_test.c
@@ -428,12 +428,12 @@ TEST_CASE(ble_gatt_conn_test_disconnect)
 
     /* Connection 2. */
     disc_all_dscs_arg.exp_conn_handle = 2;
-    rc = ble_gattc_disc_all_dscs(2, 1, 0xffff,
+    rc = ble_gattc_disc_all_dscs(2, 3, 0xffff,
                                  ble_gatt_conn_test_disc_all_dscs_cb,
                                  &disc_all_dscs_arg);
 
     disc_chr_uuid_arg.exp_conn_handle = 2;
-    rc = ble_gattc_disc_chrs_by_uuid(2, 1, 0xffff, BLE_UUID16(0x2222),
+    rc = ble_gattc_disc_chrs_by_uuid(2, 2, 0xffff, BLE_UUID16(0x2222),
                                      ble_gatt_conn_test_disc_chr_uuid_cb,
                                      &disc_chr_uuid_arg);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7c7c9c1/net/nimble/host/src/test/ble_gatt_disc_d_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_disc_d_test.c b/net/nimble/host/src/test/ble_gatt_disc_d_test.c
index 26e49be..048ecb7 100644
--- a/net/nimble/host/src/test/ble_gatt_disc_d_test.c
+++ b/net/nimble/host/src/test/ble_gatt_disc_d_test.c
@@ -28,7 +28,7 @@
 #include "ble_hs_test_util.h"
 
 struct ble_gatt_disc_d_test_dsc {
-    uint16_t chr_def_handle; /* 0 if last entry. */
+    uint16_t chr_val_handle; /* 0 if last entry. */
     uint16_t dsc_handle;
     uint8_t dsc_uuid128[16];
 };
@@ -74,7 +74,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(
 
     off = BLE_ATT_FIND_INFO_RSP_BASE_SZ;
     for (i = 0; ; i++) {
-        if (dscs[i].chr_def_handle == 0) {
+        if (dscs[i].chr_val_handle == 0) {
             /* No more descriptors. */
             break;
         }
@@ -113,7 +113,7 @@ ble_gatt_disc_d_test_misc_rx_rsp(uint16_t conn_handle,
     int idx;
 
     idx = 0;
-    while (dscs[idx].chr_def_handle != 0) {
+    while (dscs[idx].chr_val_handle != 0) {
         count = ble_gatt_disc_d_test_misc_rx_rsp_once(conn_handle, dscs + idx);
         if (count == 0) {
             break;
@@ -140,9 +140,9 @@ ble_gatt_disc_d_test_misc_verify_dscs(struct ble_gatt_disc_d_test_dsc *dscs,
         stop_after = INT_MAX;
     }
 
-    for (i = 0; i < stop_after && dscs[i].chr_def_handle != 0; i++) {
-        TEST_ASSERT(dscs[i].chr_def_handle ==
-                    ble_gatt_disc_d_test_dscs[i].chr_def_handle);
+    for (i = 0; i < stop_after && dscs[i].chr_val_handle != 0; i++) {
+        TEST_ASSERT(dscs[i].chr_val_handle ==
+                    ble_gatt_disc_d_test_dscs[i].chr_val_handle);
         TEST_ASSERT(dscs[i].dsc_handle ==
                     ble_gatt_disc_d_test_dscs[i].dsc_handle);
         TEST_ASSERT(memcmp(dscs[i].dsc_uuid128,
@@ -157,7 +157,7 @@ ble_gatt_disc_d_test_misc_verify_dscs(struct ble_gatt_disc_d_test_dsc *dscs,
 static int
 ble_gatt_disc_d_test_misc_cb(uint16_t conn_handle,
                              const struct ble_gatt_error *error,
-                             uint16_t chr_def_handle,
+                             uint16_t chr_val_handle,
                              const struct ble_gatt_dsc *dsc,
                              void *arg)
 {
@@ -175,7 +175,7 @@ ble_gatt_disc_d_test_misc_cb(uint16_t conn_handle,
                           BLE_GATT_DISC_D_TEST_MAX_DSCS);
 
         dst = ble_gatt_disc_d_test_dscs + ble_gatt_disc_d_test_num_dscs++;
-        dst->chr_def_handle = chr_def_handle;
+        dst->chr_val_handle = chr_val_handle;
         dst->dsc_handle = dsc->handle;
         memcpy(dst->dsc_uuid128, dsc->uuid128, 16);
         break;
@@ -201,7 +201,7 @@ ble_gatt_disc_d_test_misc_cb(uint16_t conn_handle,
 }
 
 static void
-ble_gatt_disc_d_test_misc_all(uint16_t chr_def_handle, uint16_t end_handle,
+ble_gatt_disc_d_test_misc_all(uint16_t chr_val_handle, uint16_t end_handle,
                               int stop_after,
                               struct ble_gatt_disc_d_test_dsc *dscs)
 {
@@ -214,7 +214,7 @@ ble_gatt_disc_d_test_misc_all(uint16_t chr_def_handle, uint16_t end_handle,
                                  NULL, NULL);
 
     num_left = stop_after;
-    rc = ble_gattc_disc_all_dscs(2, chr_def_handle, end_handle,
+    rc = ble_gattc_disc_all_dscs(2, chr_val_handle, end_handle,
                                  ble_gatt_disc_d_test_misc_cb, &num_left);
     TEST_ASSERT(rc == 0);
 
@@ -225,9 +225,9 @@ ble_gatt_disc_d_test_misc_all(uint16_t chr_def_handle, uint16_t end_handle,
 TEST_CASE(ble_gatt_disc_d_test_1)
 {
     /*** One 16-bit descriptor. */
-    ble_gatt_disc_d_test_misc_all(4, 10, 0,
+    ble_gatt_disc_d_test_misc_all(5, 10, 0,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 4,
+            .chr_val_handle = 5,
             .dsc_handle = 6,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1234),
         }, {
@@ -236,13 +236,13 @@ TEST_CASE(ble_gatt_disc_d_test_1)
     );
 
     /*** Two 16-bit descriptors. */
-    ble_gatt_disc_d_test_misc_all(49, 100, 0,
+    ble_gatt_disc_d_test_misc_all(50, 100, 0,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 51,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1111),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 52,
             .dsc_uuid128 = BLE_UUID16_ARR(0x2222),
         }, {
@@ -251,25 +251,25 @@ TEST_CASE(ble_gatt_disc_d_test_1)
     );
 
     /*** Five 16-bit descriptors. */
-    ble_gatt_disc_d_test_misc_all(49, 100, 0,
+    ble_gatt_disc_d_test_misc_all(50, 100, 0,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 51,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1111),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 52,
             .dsc_uuid128 = BLE_UUID16_ARR(0x2222),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 53,
             .dsc_uuid128 = BLE_UUID16_ARR(0x3333),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 54,
             .dsc_uuid128 = BLE_UUID16_ARR(0x4444),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 55,
             .dsc_uuid128 = BLE_UUID16_ARR(0x5555),
         }, {
@@ -278,25 +278,25 @@ TEST_CASE(ble_gatt_disc_d_test_1)
     );
 
     /*** Interleaved 16-bit and 128-bit descriptors. */
-    ble_gatt_disc_d_test_misc_all(49, 100, 0,
+    ble_gatt_disc_d_test_misc_all(50, 100, 0,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 51,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1111),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 52,
             .dsc_uuid128 = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 },
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 53,
             .dsc_uuid128 = BLE_UUID16_ARR(0x3333),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 54,
             .dsc_uuid128 = { 1,0,4,0,6,9,17,7,8,43,7,4,12,43,19,35 },
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 55,
             .dsc_uuid128 = BLE_UUID16_ARR(0x5555),
         }, {
@@ -305,13 +305,13 @@ TEST_CASE(ble_gatt_disc_d_test_1)
     );
 
     /*** Ends with final handle ID. */
-    ble_gatt_disc_d_test_misc_all(49, 52, 0,
+    ble_gatt_disc_d_test_misc_all(50, 52, 0,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 51,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1111),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 52,
             .dsc_uuid128 = BLE_UUID16_ARR(0x2222),
         }, {
@@ -320,25 +320,25 @@ TEST_CASE(ble_gatt_disc_d_test_1)
     );
 
     /*** Stop after two descriptors. */
-    ble_gatt_disc_d_test_misc_all(49, 100, 2,
+    ble_gatt_disc_d_test_misc_all(50, 100, 2,
         ((struct ble_gatt_disc_d_test_dsc[]) { {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 51,
             .dsc_uuid128 = BLE_UUID16_ARR(0x1111),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 52,
             .dsc_uuid128 = BLE_UUID16_ARR(0x2222),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 53,
             .dsc_uuid128 = BLE_UUID16_ARR(0x3333),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 54,
             .dsc_uuid128 = BLE_UUID16_ARR(0x4444),
         }, {
-            .chr_def_handle = 49,
+            .chr_val_handle = 50,
             .dsc_handle = 55,
             .dsc_uuid128 = BLE_UUID16_ARR(0x5555),
         }, {