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/01/22 01:21:45 UTC

[3/3] incubator-mynewt-larva git commit: Make GATT services easier to define.

Make GATT services easier to define.

Terminate arrays with 0 rather than named constants.


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

Branch: refs/heads/master
Commit: 88dc6a6a690bc246ef487f444b2c670c7a2ce441
Parents: 9682532
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Jan 21 15:37:13 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Jan 21 16:20:52 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_gatt.h         |  2 +-
 .../host/src/test/ble_gatts_notify_test.c       |  4 +-
 net/nimble/host/src/test/ble_gatts_reg_test.c   | 70 +++++++++-----------
 3 files changed, 33 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/88dc6a6a/net/nimble/host/include/host/ble_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gatt.h b/net/nimble/host/include/host/ble_gatt.h
index 818273e..4ecdb98 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -166,9 +166,9 @@ struct ble_gatt_chr_def {
     ble_gatt_chr_flags flags;
 };
 
+#define BLE_GATT_SVC_TYPE_END       0
 #define BLE_GATT_SVC_TYPE_PRIMARY   1
 #define BLE_GATT_SVC_TYPE_SECONDARY 2
-#define BLE_GATT_SVC_TYPE_END       3
 
 struct ble_gatt_svc_def {
     uint8_t type;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/88dc6a6a/net/nimble/host/src/test/ble_gatts_notify_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatts_notify_test.c b/net/nimble/host/src/test/ble_gatts_notify_test.c
index cdc5a3b..87b7f29 100644
--- a/net/nimble/host/src/test/ble_gatts_notify_test.c
+++ b/net/nimble/host/src/test/ble_gatts_notify_test.c
@@ -53,10 +53,10 @@ static const struct ble_gatt_svc_def ble_gatts_notify_test_svcs[] = { {
         .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY |
                  BLE_GATT_CHR_F_INDICATE,
     }, {
-        .uuid128 = NULL,
+        0
     } },
 }, {
-    .type = BLE_GATT_SVC_TYPE_END,
+    0
 } };
 
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/88dc6a6a/net/nimble/host/src/test/ble_gatts_reg_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatts_reg_test.c b/net/nimble/host/src/test/ble_gatts_reg_test.c
index 32281ab..ebd9fd7 100644
--- a/net/nimble/host/src/test/ble_gatts_reg_test.c
+++ b/net/nimble/host/src/test/ble_gatts_reg_test.c
@@ -105,21 +105,11 @@ TEST_CASE(ble_gatts_reg_test_svc_return)
 
     ble_gatts_reg_test_init();
 
-    /*** Missing type. */
-    struct ble_gatt_svc_def svcs_no_type[] = { {
-        .uuid128 = BLE_UUID16(0x1234),
-    }, {
-        .type = BLE_GATT_SVC_TYPE_END,
-    } };
-
-    rc = ble_gatts_register_svcs(svcs_no_type, NULL, NULL);
-    TEST_ASSERT(rc == BLE_HS_EINVAL);
-
     /*** Missing UUID. */
     struct ble_gatt_svc_def svcs_no_uuid[] = { {
         .type = BLE_GATT_SVC_TYPE_PRIMARY,
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_no_uuid, NULL, NULL);
@@ -135,7 +125,7 @@ TEST_CASE(ble_gatts_reg_test_svc_return)
         .uuid128 = BLE_UUID16(0x1234),
         .includes = (const struct ble_gatt_svc_def*[]) { svcs_circ + 0, NULL },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_circ, NULL, NULL);
@@ -150,7 +140,7 @@ TEST_CASE(ble_gatts_reg_test_svc_return)
         .type = BLE_GATT_SVC_TYPE_SECONDARY,
         .uuid128 = BLE_UUID16(0x1234),
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_good, NULL, NULL);
@@ -171,10 +161,10 @@ TEST_CASE(ble_gatts_reg_test_chr_return)
             .uuid128 = BLE_UUID16(0x1111),
             .flags = BLE_GATT_CHR_F_READ,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_no_chr_cb, NULL, NULL);
@@ -189,10 +179,10 @@ TEST_CASE(ble_gatts_reg_test_chr_return)
             .access_cb = ble_gatts_reg_test_misc_dummy_access,
             .flags = BLE_GATT_CHR_F_READ,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_good, NULL, NULL);
@@ -217,13 +207,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_return)
                 .uuid128 = BLE_UUID16(0x8888),
                 .att_flags = 5,
             }, {
-                .uuid128 = NULL,
+                0
             } },
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_no_dsc_cb, NULL, NULL);
@@ -242,13 +232,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_return)
                 .access_cb = ble_gatts_reg_test_misc_dummy_access,
                 .att_flags = 5,
             }, {
-                .uuid128 = NULL,
+                0
             } },
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } };
 
     rc = ble_gatts_register_svcs(svcs_good, NULL, NULL);
@@ -298,7 +288,7 @@ TEST_CASE(ble_gatts_reg_test_svc_cb)
         .type = BLE_GATT_SVC_TYPE_PRIMARY,
         .uuid128 = BLE_UUID16(0x1234),
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 
     /*** 3 primary. */
@@ -312,7 +302,7 @@ TEST_CASE(ble_gatts_reg_test_svc_cb)
         .type = BLE_GATT_SVC_TYPE_PRIMARY,
         .uuid128 = BLE_UUID16(0x3234),
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 
 
@@ -324,7 +314,7 @@ TEST_CASE(ble_gatts_reg_test_svc_cb)
         .type = BLE_GATT_SVC_TYPE_SECONDARY,
         .uuid128 = BLE_UUID16(0x2222),
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 
     /*** 1 primary, 1 secondary, 1 include. */
@@ -338,7 +328,7 @@ TEST_CASE(ble_gatts_reg_test_svc_cb)
             .type = BLE_GATT_SVC_TYPE_SECONDARY,
             .uuid128 = BLE_UUID16(0x2222),
         }, {
-            .type = BLE_GATT_SVC_TYPE_END,
+            0
         }
     };
     ble_gatts_reg_test_misc_svcs(svcs);
@@ -355,10 +345,10 @@ TEST_CASE(ble_gatts_reg_test_chr_cb)
             .access_cb = ble_gatts_reg_test_misc_dummy_access,
             .flags = BLE_GATT_CHR_F_READ,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 
     /*** 3 characteristics. */
@@ -374,7 +364,7 @@ TEST_CASE(ble_gatts_reg_test_chr_cb)
             .access_cb = ble_gatts_reg_test_misc_dummy_access,
             .flags = BLE_GATT_CHR_F_WRITE,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
         .type = BLE_GATT_SVC_TYPE_SECONDARY,
@@ -384,10 +374,10 @@ TEST_CASE(ble_gatts_reg_test_chr_cb)
             .access_cb = ble_gatts_reg_test_misc_dummy_access,
             .flags = BLE_GATT_CHR_F_READ,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 }
 
@@ -406,13 +396,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb)
                 .att_flags = 5,
                 .access_cb = ble_gatts_reg_test_misc_dummy_access,
             }, {
-                .uuid128 = NULL,
+                0
             } },
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 
     /*** 5 descriptors. */
@@ -428,14 +418,14 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb)
                 .att_flags = 5,
                 .access_cb = ble_gatts_reg_test_misc_dummy_access,
             }, {
-                .uuid128 = NULL,
+                0
             } },
         }, {
             .uuid128 = BLE_UUID16(0x2222),
             .access_cb = ble_gatts_reg_test_misc_dummy_access,
             .flags = BLE_GATT_CHR_F_WRITE,
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
         .type = BLE_GATT_SVC_TYPE_SECONDARY,
@@ -461,13 +451,13 @@ TEST_CASE(ble_gatts_reg_test_dsc_cb)
                 .att_flags = 5,
                 .access_cb = ble_gatts_reg_test_misc_dummy_access,
             }, {
-                .uuid128 = NULL,
+                0
             } },
         }, {
-            .uuid128 = NULL,
+            0
         } },
     }, {
-        .type = BLE_GATT_SVC_TYPE_END,
+        0
     } });
 }