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/12/21 23:35:51 UTC

[1/4] incubator-mynewt-core git commit: nimble/test: Fix ble_att_svr_test_find_type_value test cases

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop c928be0de -> abfe99483


nimble/test: Fix ble_att_svr_test_find_type_value test cases

Test cases for "Find By Type Value" are incorrect since they are based
on an assumption that attribute group is a sequence of consecutive
attributes with the same type and value.

This fixes the test cases to check for proper grouping as defined by
Bluetooth Specification 4.2, Vol 3, Part G, Section 2.5.3.

Since the actual ATT implementation is based on the same incorrect
assumtpion, the test cases will now fail until ATT is fixed as well.


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/1f2b6bb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1f2b6bb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1f2b6bb2

Branch: refs/heads/develop
Commit: 1f2b6bb2661d95421a00c4c01d75866bde7ba8f1
Parents: c870a0f
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Tue Dec 20 15:24:46 2016 +0100
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Tue Dec 20 15:29:35 2016 +0100

----------------------------------------------------------------------
 net/nimble/host/test/src/ble_att_svr_test.c | 76 ++++++++++++------------
 1 file changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1f2b6bb2/net/nimble/host/test/src/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_att_svr_test.c b/net/nimble/host/test/src/ble_att_svr_test.c
index d794c49..d2fbe63 100644
--- a/net/nimble/host/test/src/ble_att_svr_test.c
+++ b/net/nimble/host/test/src/ble_att_svr_test.c
@@ -1182,15 +1182,16 @@ TEST_CASE(ble_att_svr_test_find_type_value)
     uint16_t handle3;
     uint16_t handle4;
     uint16_t handle5;
+    uint16_t handle_desc;
     uint8_t uuid1[16] = {
         0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
-        0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
-    };
-    uint8_t uuid2[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
-    uint8_t uuid3[16] = {
+        0x00, 0x10, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00
+    }; /* 0x2800 (Primary Service) */
+    uint8_t uuid2[16] = {
         0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
-        0x00, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
-    };
+        0x00, 0x10, 0x00, 0x00, 0x03, 0x28, 0x00, 0x00
+    }; /* 0x2803 (Characteristic) */
+    uint8_t uuid3[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
     int rc;
 
     conn_handle = ble_att_svr_test_misc_init(128);
@@ -1200,7 +1201,7 @@ TEST_CASE(ble_att_svr_test_find_type_value)
 
     /*** Start handle of 0. */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 0, 0, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 0, 0, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc != 0);
     ble_hs_test_util_verify_tx_err_rsp(
@@ -1209,7 +1210,7 @@ TEST_CASE(ble_att_svr_test_find_type_value)
 
     /*** Start handle > end handle. */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 101, 100, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 101, 100, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc != 0);
     ble_hs_test_util_verify_tx_err_rsp(
@@ -1218,7 +1219,7 @@ TEST_CASE(ble_att_svr_test_find_type_value)
 
     /*** No attributes. */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 200, 300, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 200, 300, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc != 0);
     ble_hs_test_util_verify_tx_err_rsp(
@@ -1231,7 +1232,7 @@ TEST_CASE(ble_att_svr_test_find_type_value)
     TEST_ASSERT(rc == 0);
 
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 200, 300, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 200, 300, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc != 0);
     ble_hs_test_util_verify_tx_err_rsp(
@@ -1240,7 +1241,7 @@ TEST_CASE(ble_att_svr_test_find_type_value)
 
     /*** One entry, one attribute. */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, handle1, handle1, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, handle1, handle1, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc == 0);
     ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
@@ -1252,12 +1253,12 @@ TEST_CASE(ble_att_svr_test_find_type_value)
         } }));
 
     /*** One entry, two attributes. */
-    rc = ble_att_svr_register(uuid1, HA_FLAG_PERM_RW, &handle2,
+    rc = ble_att_svr_register(uuid2, HA_FLAG_PERM_RW, &handle2,
                               ble_att_svr_test_misc_attr_fn_r_1, NULL);
     TEST_ASSERT(rc == 0);
 
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, handle1, handle2, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, handle1, handle2, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc == 0);
     ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
@@ -1268,68 +1269,67 @@ TEST_CASE(ble_att_svr_test_find_type_value)
             .first = 0,
         } }));
 
-    /*** Entry 1: two attributes; entry 2: one attribute. */
+    /*** Entry 1: four attributes; entry 2 (invalid value): one attribute;
+     *   entry 3: one attribute; Check that invalid value is not returned. */
+    ble_att_svr_test_attr_r_2 = (uint8_t[]){0x00, 0x00};
+    ble_att_svr_test_attr_r_2_len = 2;
+
+    rc = ble_att_svr_register(uuid3, HA_FLAG_PERM_RW, &handle_desc,
+                              ble_att_svr_test_misc_attr_fn_r_2, NULL);
+    TEST_ASSERT(rc == 0);
+
     rc = ble_att_svr_register(uuid2, HA_FLAG_PERM_RW, &handle3,
                               ble_att_svr_test_misc_attr_fn_r_2, NULL);
     TEST_ASSERT(rc == 0);
 
     rc = ble_att_svr_register(uuid1, HA_FLAG_PERM_RW, &handle4,
+                              ble_att_svr_test_misc_attr_fn_r_2, NULL);
+    TEST_ASSERT(rc == 0);
+
+    rc = ble_att_svr_register(uuid1, HA_FLAG_PERM_RW, &handle5,
                               ble_att_svr_test_misc_attr_fn_r_1, NULL);
     TEST_ASSERT(rc == 0);
 
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 0x0001, 0xffff, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 0x0001, 0xffff, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc == 0);
     ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
         ((struct ble_att_svr_test_type_value_entry[]) { {
             .first = handle1,
-            .last = handle2,
+            .last = handle3,
         }, {
-            .first = handle4,
-            .last = handle4,
+            .first = handle5,
+            .last = handle5,
         }, {
             .first = 0,
         } }));
 
-    /*** Ensure attribute with wrong value is not included. */
-    ble_att_svr_test_attr_r_2 = (uint8_t[]){0x00, 0x00};
-    ble_att_svr_test_attr_r_2_len = 2;
-
+    /*** As above, check proper range is returned with smaller search range */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 0x0001, 0xffff, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, 0x0001, 0x0001, 0x2800, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc == 0);
     ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
         ((struct ble_att_svr_test_type_value_entry[]) { {
             .first = handle1,
-            .last = handle2,
-        }, {
-            .first = handle4,
-            .last = handle4,
+            .last = handle3,
         }, {
             .first = 0,
         } }));
 
-    /*** Ensure attribute with wrong type is not included. */
-    rc = ble_att_svr_register(uuid3, HA_FLAG_PERM_RW, &handle5,
-                              ble_att_svr_test_misc_attr_fn_r_1, NULL);
-
+    /*** As above, check grouping by Characteristic UUID */
     rc = ble_hs_test_util_rx_att_find_type_value_req(
-        conn_handle, 0x0001, 0xffff, 0x0001, ble_att_svr_test_attr_r_1,
+        conn_handle, handle1, handle3, 0x2803, ble_att_svr_test_attr_r_1,
         ble_att_svr_test_attr_r_1_len);
     TEST_ASSERT(rc == 0);
     ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
         ((struct ble_att_svr_test_type_value_entry[]) { {
-            .first = handle1,
-            .last = handle2,
-        }, {
-            .first = handle4,
-            .last = handle4,
+            .first = handle2,
+            .last = handle_desc,
         }, {
             .first = 0,
         } }));
-
 }
 
 static void


[2/4] incubator-mynewt-core git commit: nimble/att: Rename ble_att_svr_is_valid_group_type

Posted by cc...@apache.org.
nimble/att: Rename ble_att_svr_is_valid_group_type

The ble_att_svr_is_valid_read_group_type() checks if given type is
valid for Read By Group Type Request only, not if it is valid group
type in general. Rename this function so it is more clear what it
does.


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/0b81089f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0b81089f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0b81089f

Branch: refs/heads/develop
Commit: 0b81089fc7554cea59aa503905a193c008de70da
Parents: 1f2b6bb
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Tue Dec 13 16:25:14 2016 +0100
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Tue Dec 20 15:29:43 2016 +0100

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_svr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0b81089f/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 45299de..387745b 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -1713,7 +1713,7 @@ done:
 }
 
 static int
-ble_att_svr_is_valid_group_type(uint8_t *uuid128)
+ble_att_svr_is_valid_read_group_type(uint8_t *uuid128)
 {
     uint16_t uuid16;
 
@@ -1848,7 +1848,7 @@ ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle,
 
         if (start_group_handle != 0) {
             /* We have already found the start of a group. */
-            if (!ble_att_svr_is_valid_group_type(entry->ha_uuid)) {
+            if (!ble_att_svr_is_valid_read_group_type(entry->ha_uuid)) {
                 /* This attribute is part of the current group. */
                 end_group_handle = entry->ha_handle_id;
             } else {
@@ -2019,7 +2019,7 @@ ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
         goto done;
     }
 
-    if (!ble_att_svr_is_valid_group_type(uuid128)) {
+    if (!ble_att_svr_is_valid_read_group_type(uuid128)) {
         att_err = BLE_ATT_ERR_UNSUPPORTED_GROUP;
         err_handle = req.bagq_start_handle;
         rc = BLE_HS_ENOTSUP;


[3/4] incubator-mynewt-core git commit: nimble/att: Refactor Find By Type Value handling

Posted by cc...@apache.org.
nimble/att: Refactor Find By Type Value handling

Current implementation of "Find By Type Value" handler is broken as it
assumes that group is a sequence of consecutive attributes with the
same type and value. This is incorrect and it breaks "Discover Primary
Services By Service UUID" GATT procedure effectively making impossible
to search for service by UUID on local GATT server.

This fixes the problem by refactoring ble_att_svr_fill_type_value() to
use proper grouping as defined by Bluetooth Specification, Vol 3, Part
G, Section 2.5.3.


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/483eb817
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/483eb817
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/483eb817

Branch: refs/heads/develop
Commit: 483eb817675666542ed02aec172815b88e291990
Parents: 0b81089
Author: Andrzej Kaczmarek <an...@codecoup.pl>
Authored: Tue Dec 20 13:21:09 2016 +0100
Committer: Andrzej Kaczmarek <an...@codecoup.pl>
Committed: Tue Dec 20 23:12:24 2016 +0100

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_svr.c | 178 ++++++++++++++-------------------
 1 file changed, 76 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/483eb817/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 387745b..656d432 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -975,16 +975,11 @@ done:
 }
 
 /**
- * Processes a single non-matching attribute entry while filling a
- * Find-By-Type-Value-Response.
+ * Fills a Find-By-Type-Value-Response with single entry.
  *
  * @param om                    The response mbuf.
- * @param first                 Pointer to the first matching handle ID in the
- *                                  current group of IDs.  0 if there is not a
- *                                  current group.
- * @param prev                  Pointer to the most recent matching handle ID
- *                                  in the current group of IDs.  0 if there is
- *                                  not a current group.
+ * @param first                 First handle ID in the current group of IDs.
+ * @param last                  Last handle ID in the current group of ID.
  * @param mtu                   The ATT L2CAP channel MTU.
  *
  * @return                      0 if the response should be sent;
@@ -994,97 +989,60 @@ done:
  *                              Other nonzero on error.
  */
 static int
-ble_att_svr_fill_type_value_no_match(struct os_mbuf *om, uint16_t *first,
-                                     uint16_t *prev, int mtu,
+ble_att_svr_fill_type_value_entry(struct os_mbuf *om, uint16_t first,
+                                     uint16_t last, int mtu,
                                      uint8_t *out_att_err)
 {
     uint16_t u16;
     int rsp_sz;
     int rc;
 
-    /* If there is no current group, then there is nothing to do. */
-    if (*first == 0) {
-        return BLE_HS_EAGAIN;
-    }
-
     rsp_sz = OS_MBUF_PKTHDR(om)->omp_len + 4;
     if (rsp_sz > mtu) {
         return 0;
     }
 
-    u16 = *first;
-    htole16(&u16, u16);
+    htole16(&u16, first);
     rc = os_mbuf_append(om, &u16, 2);
     if (rc != 0) {
         *out_att_err = BLE_ATT_ERR_INSUFFICIENT_RES;
         return BLE_HS_ENOMEM;
     }
 
-    u16 = *prev;
-    htole16(&u16, u16);
+    htole16(&u16, last);
     rc = os_mbuf_append(om, &u16, 2);
     if (rc != 0) {
         *out_att_err = BLE_ATT_ERR_INSUFFICIENT_RES;
         return BLE_HS_ENOMEM;
     }
 
-    *first = 0;
-    *prev = 0;
-
     return BLE_HS_EAGAIN;
 }
 
-/**
- * Processes a single matching attribute entry while filling a
- * Find-By-Type-Value-Response.
- *
- * @param om                    The response mbuf.
- * @param first                 Pointer to the first matching handle ID in the
- *                                  current group of IDs.  0 if there is not a
- *                                  current group.
- * @param prev                  Pointer to the most recent matching handle ID
- *                                  in the current group of IDs.  0 if there is
- *                                  not a current group.
- * @param handle_id             The matching handle ID to process.
- * @param mtu                   The ATT L2CAP channel MTU.
- *
- * @return                      0 if the response should be sent;
- *                              BLE_HS_EAGAIN if the entry was successfully
- *                                  processed and subsequent entries can be
- *                                  inspected.
- *                              Other nonzero on error.
- */
 static int
-ble_att_svr_fill_type_value_match(struct os_mbuf *om, uint16_t *first,
-                                  uint16_t *prev, uint16_t handle_id,
-                                  int mtu, uint8_t *out_att_err)
+ble_att_svr_is_valid_find_group_type(uint16_t uuid16)
 {
-    int rc;
-
-    /* If this is the start of a group, record it as the first ID and keep
-     * searching.
-     */
-    if (*first == 0) {
-        *first = handle_id;
-        *prev = handle_id;
-        return BLE_HS_EAGAIN;
-    }
+    return uuid16 == BLE_ATT_UUID_PRIMARY_SERVICE ||
+           uuid16 == BLE_ATT_UUID_SECONDARY_SERVICE ||
+           uuid16 == BLE_ATT_UUID_CHARACTERISTIC;
+}
 
-    /* If this is the continuation of a group, keep searching. */
-    if (handle_id == *prev + 1) {
-        *prev = handle_id;
-        return BLE_HS_EAGAIN;
+static int
+ble_att_svr_is_valid_group_end(uint16_t uuid16_group, uint16_t uuid16)
+{
+    switch (uuid16_group) {
+    case BLE_ATT_UUID_PRIMARY_SERVICE:
+    case BLE_ATT_UUID_SECONDARY_SERVICE:
+        /* Only Primary or Secondary Service types end service group. */
+        return uuid16 == BLE_ATT_UUID_PRIMARY_SERVICE ||
+               uuid16 == BLE_ATT_UUID_SECONDARY_SERVICE;
+    case BLE_ATT_UUID_CHARACTERISTIC:
+        /* Any valid grouping type ends characteristic group */
+        return ble_att_svr_is_valid_find_group_type(uuid16);
+    default:
+        /* Any attribute type ends group of non-grouping type */
+        return 1;
     }
-
-    /* Otherwise, this handle is not a part of the previous group.  Write the
-     * previous group to the response, and remember this ID as the start of the
-     * next group.
-     */
-    rc = ble_att_svr_fill_type_value_no_match(om, first, prev, mtu,
-                                              out_att_err);
-    *first = handle_id;
-    *prev = handle_id;
-    return rc;
 }
 
 /**
@@ -1116,7 +1074,6 @@ ble_att_svr_fill_type_value(uint16_t conn_handle,
     uint16_t first;
     uint16_t prev;
     int any_entries;
-    int match;
     int rc;
 
     first = 0;
@@ -1128,51 +1085,68 @@ ble_att_svr_fill_type_value(uint16_t conn_handle,
      * written to the response.
      */
     STAILQ_FOREACH(ha, &ble_att_svr_list, ha_next) {
-        match = 0;
+        if (ha->ha_handle_id < req->bavq_start_handle) {
+            continue;
+        }
 
-        if (ha->ha_handle_id > req->bavq_end_handle) {
+        /* Continue to look for end of group in case group is in progress. */
+        if (!first && ha->ha_handle_id > req->bavq_end_handle) {
             break;
         }
 
-        if (ha->ha_handle_id >= req->bavq_start_handle) {
-            /* Compare the attribute type and value to the request fields to
-             * determine if this attribute matches.
-             */
-            uuid16 = ble_uuid_128_to_16(ha->ha_uuid);
-            if (uuid16 == req->bavq_attr_type) {
-                rc = ble_att_svr_read_flat(conn_handle, ha, 0, sizeof buf, buf,
-                                           &attr_len, out_att_err);
-                if (rc != 0) {
-                    goto done;
-                }
-                rc = os_mbuf_cmpf(rxom, BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ,
-                                  buf, attr_len);
-                if (rc == 0) {
-                    match = 1;
-                }
+        uuid16 = ble_uuid_128_to_16(ha->ha_uuid);
+
+        /* With group in progress, check if current attribute ends it. */
+        if (first) {
+            if (!ble_att_svr_is_valid_group_end(req->bavq_attr_type, uuid16)) {
+                prev = ha->ha_handle_id;
+                continue;
             }
-        }
 
-        if (match) {
-            rc = ble_att_svr_fill_type_value_match(txom, &first, &prev,
-                                                   ha->ha_handle_id, mtu,
+            rc = ble_att_svr_fill_type_value_entry(txom, first, prev, mtu,
                                                    out_att_err);
-        } else {
-            rc = ble_att_svr_fill_type_value_no_match(txom, &first, &prev,
-                                                      mtu, out_att_err);
+            if (rc != BLE_HS_EAGAIN) {
+                goto done;
+            }
+
+            first = 0;
+            prev = 0;
+
+            /* Break in case we were just looking for end of group past the end
+             * handle ID. */
+            if (ha->ha_handle_id > req->bavq_end_handle) {
+                break;
+            }
         }
 
-        if (rc != BLE_HS_EAGAIN) {
-            goto done;
+        /* Compare the attribute type and value to the request fields to
+         * determine if this attribute matches.
+         */
+        if (uuid16 == req->bavq_attr_type) {
+            rc = ble_att_svr_read_flat(conn_handle, ha, 0, sizeof buf, buf,
+                                       &attr_len, out_att_err);
+            if (rc != 0) {
+                goto done;
+            }
+            rc = os_mbuf_cmpf(rxom, BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ,
+                              buf, attr_len);
+            if (rc == 0) {
+                first = ha->ha_handle_id;
+                prev = ha->ha_handle_id;
+            }
         }
     }
 
-    /* Process one last non-matching ID in case a group was in progress when
-     * the end of the attribute list was reached.
+    /* Process last group in case a group was in progress when the end of the
+     * attribute list was reached.
      */
-    rc = ble_att_svr_fill_type_value_no_match(txom, &first, &prev, mtu,
-                                              out_att_err);
-    if (rc == BLE_HS_EAGAIN) {
+    if (first) {
+        rc = ble_att_svr_fill_type_value_entry(txom, first, prev, mtu,
+                                               out_att_err);
+        if (rc == BLE_HS_EAGAIN) {
+            rc = 0;
+        }
+    } else {
         rc = 0;
     }
 


[4/4] incubator-mynewt-core git commit: This closes #143.

Posted by cc...@apache.org.
This closes #143.

Merge remote-tracking branch 'andrzej-kaczmarek/nimble/find_by_type_fix' into develop

* andrzej-kaczmarek/nimble/find_by_type_fix:
  nimble/att: Refactor Find By Type Value handling
  nimble/att: Rename ble_att_svr_is_valid_group_type
  nimble/test: Fix ble_att_svr_test_find_type_value test cases


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/abfe9948
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/abfe9948
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/abfe9948

Branch: refs/heads/develop
Commit: abfe994832bc07fa205694f9a2301bc527070986
Parents: c928be0 483eb81
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Dec 21 15:30:39 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Dec 21 15:30:39 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_svr.c           | 184 ++++++++++-------------
 net/nimble/host/test/src/ble_att_svr_test.c |  76 +++++-----
 2 files changed, 117 insertions(+), 143 deletions(-)
----------------------------------------------------------------------