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/02/06 04:02:22 UTC

incubator-mynewt-larva git commit: Add some configurability to the host.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 4d70cc0c7 -> a1e419d0b


Add some configurability to the host.


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

Branch: refs/heads/master
Commit: a1e419d0b1bc763a3605a8537a9186b9e5918c43
Parents: 4d70cc0
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Feb 5 17:33:51 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Feb 5 19:01:49 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_hs.h         |  13 +
 net/nimble/host/src/ble_att_clt.c             |  96 ++++++++
 net/nimble/host/src/ble_att_priv.h            |   4 +
 net/nimble/host/src/ble_att_svr.c             | 161 +++++++-----
 net/nimble/host/src/ble_gap.c                 |  97 ++++++--
 net/nimble/host/src/ble_gattc.c               | 269 ++++++++++++---------
 net/nimble/host/src/ble_gatts.c               |  45 +++-
 net/nimble/host/src/ble_hs.c                  |   4 +-
 net/nimble/host/src/ble_hs_adv.c              |   8 +
 net/nimble/host/src/ble_hs_cfg.c              |  57 ++++-
 net/nimble/host/src/ble_hs_conn.c             |  48 ++++
 net/nimble/host/src/ble_hs_priv.h             |   1 +
 net/nimble/host/src/test/ble_gatt_read_test.c | 217 -----------------
 net/nimble/include/nimble/nimble_opt.h        | 243 +++++++++++++++++++
 project/bletiny/src/main.c                    |  12 +-
 project/bletiny/src/periph.c                  |  14 +-
 16 files changed, 847 insertions(+), 442 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index eeff7d9..80f947e 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -56,8 +56,21 @@
 #define BLE_HS_L2C_ERR(x)               ((x) ? BLE_HS_ERR_L2C_BASE + (x) : 0)
 
 struct ble_hs_cfg {
+    /** Connection settings. */
     uint16_t max_outstanding_pkts_per_conn;
     uint8_t max_connections;
+    uint8_t max_conn_update_entries;
+
+    /** GATT server settings. */
+    uint16_t max_services;
+    uint16_t max_client_configs;
+
+    /** GATT client settings. */
+    uint8_t max_gattc_procs;
+
+    /** ATT server settings. */
+    uint16_t max_attrs;
+    uint8_t max_prep_entries;
 };
 extern struct ble_hs_cfg ble_hs_cfg;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index 63a440a..f24f4e3 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -229,6 +229,10 @@ int
 ble_att_clt_tx_find_info(struct ble_hs_conn *conn,
                          struct ble_att_find_info_req *req)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_INFO
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -269,6 +273,10 @@ err:
 int
 ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **om)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_INFO
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_find_info_rsp rsp;
     struct ble_att_find_info_idata idata;
     struct os_mbuf *rxom;
@@ -356,6 +364,10 @@ ble_att_clt_tx_find_type_value(struct ble_hs_conn *conn,
                                struct ble_att_find_type_value_req *req,
                                void *attribute_value, int value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -418,6 +430,10 @@ ble_att_clt_parse_find_type_value_hinfo(
 int
 ble_att_clt_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_find_type_value_hinfo hinfo;
     int rc;
 
@@ -457,6 +473,10 @@ ble_att_clt_tx_read_type(struct ble_hs_conn *conn,
                          struct ble_att_read_type_req *req,
                          void *uuid128)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -526,6 +546,10 @@ ble_att_clt_parse_read_type_adata(struct os_mbuf **om, int data_len,
 int
 ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_read_type_adata adata;
     struct ble_att_read_type_rsp rsp;
     int rc;
@@ -570,6 +594,10 @@ done:
 int
 ble_att_clt_tx_read(struct ble_hs_conn *conn, struct ble_att_read_req *req)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -608,6 +636,10 @@ err:
 int
 ble_att_clt_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ
+    return BLE_HS_ENOTSUP;
+#endif
+
     void *value;
     int value_len;
     int rc;
@@ -648,6 +680,10 @@ int
 ble_att_clt_tx_read_blob(struct ble_hs_conn *conn,
                          struct ble_att_read_blob_req *req)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_BLOB
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -686,6 +722,10 @@ err:
 int
 ble_att_clt_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_BLOB
+    return BLE_HS_ENOTSUP;
+#endif
+
     void *value;
     int value_len;
     int rc;
@@ -726,6 +766,10 @@ int
 ble_att_clt_tx_read_mult(struct ble_hs_conn *conn,
                          uint16_t *handles, int num_handles)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_MULT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     void *buf;
@@ -777,6 +821,10 @@ err:
 int
 ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_MULT
+    return BLE_HS_ENOTSUP;
+#endif
+
     void *value;
     int value_len;
     int rc;
@@ -818,6 +866,10 @@ ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
                                struct ble_att_read_group_type_req *req,
                                void *uuid128)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -889,6 +941,10 @@ ble_att_clt_parse_read_group_type_adata(
 int
 ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_read_group_type_adata adata;
     struct ble_att_read_group_type_rsp rsp;
     int rc;
@@ -981,6 +1037,10 @@ ble_att_clt_tx_write_req(struct ble_hs_conn *conn,
                          struct ble_att_write_req *req,
                          void *value, uint16_t value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     rc = ble_att_clt_tx_write_req_or_cmd(conn, req, value, value_len, 1);
@@ -999,6 +1059,10 @@ ble_att_clt_tx_write_cmd(struct ble_hs_conn *conn,
                          struct ble_att_write_req *req,
                          void *value, uint16_t value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_WRITE_NO_RSP
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     rc = ble_att_clt_tx_write_req_or_cmd(conn, req, value, value_len, 0);
@@ -1015,6 +1079,10 @@ ble_att_clt_tx_write_cmd(struct ble_hs_conn *conn,
 int
 ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     /* No payload. */
     ble_gattc_rx_write_rsp(conn_handle);
     return 0;
@@ -1032,6 +1100,10 @@ ble_att_clt_tx_prep_write(struct ble_hs_conn *conn,
                           struct ble_att_prep_write_cmd *req,
                           void *value, uint16_t value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_PREP_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -1088,6 +1160,10 @@ err:
 int
 ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_PREP_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_prep_write_cmd rsp;
     int rc;
 
@@ -1129,6 +1205,10 @@ int
 ble_att_clt_tx_exec_write(struct ble_hs_conn *conn,
                           struct ble_att_exec_write_req *req)
 {
+#if !NIMBLE_OPT_ATT_CLT_EXEC_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -1167,6 +1247,10 @@ err:
 int
 ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_EXEC_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     *rxom = os_mbuf_pullup(*rxom, BLE_ATT_EXEC_WRITE_RSP_SZ);
@@ -1192,6 +1276,10 @@ int
 ble_att_clt_tx_notify(struct ble_hs_conn *conn, struct ble_att_notify_req *req,
                       void *value, uint16_t value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_NOTIFY
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -1241,6 +1329,10 @@ ble_att_clt_tx_indicate(struct ble_hs_conn *conn,
                         struct ble_att_indicate_req *req,
                         void *value, uint16_t value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_INDICATE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct os_mbuf *txom;
     int rc;
@@ -1285,6 +1377,10 @@ err:
 int
 ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_CLT_INDICATE
+    return BLE_HS_ENOTSUP;
+#endif
+
     /* No payload. */
     ble_gattc_rx_indicate_rsp(conn_handle);
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_att_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_priv.h b/net/nimble/host/src/ble_att_priv.h
index b4b1a1b..7197282 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -46,6 +46,10 @@ struct ble_att_prep_entry {
     SLIST_ENTRY(ble_att_prep_entry) bape_next;
     uint16_t bape_handle;
     uint16_t bape_offset;
+
+    /* XXX: This is wasteful; we should use one mbuf chain for the entire
+     * prepared write, and compress the data into as few mbufs as possible.
+     */
     struct os_mbuf *bape_value;
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/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 d71a055..04b46e1 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -31,28 +31,11 @@
 static STAILQ_HEAD(, ble_att_svr_entry) ble_att_svr_list;
 static uint16_t ble_att_svr_id;
 
-#define BLE_ATT_SVR_NUM_ENTRIES          128
-static bssnz_t os_membuf_t
-ble_att_svr_entry_mem[OS_MEMPOOL_SIZE(BLE_ATT_SVR_NUM_ENTRIES,
-                                      sizeof (struct ble_att_svr_entry))];
+static void *ble_att_svr_entry_mem;
 static struct os_mempool ble_att_svr_entry_pool;
 
-#define BLE_ATT_SVR_PREP_MBUF_BUF_SIZE         (128)
-#define BLE_ATT_SVR_PREP_MBUF_MEMBLOCK_SIZE                     \
-    (BLE_ATT_SVR_PREP_MBUF_BUF_SIZE + sizeof(struct os_mbuf) +  \
-     sizeof(struct os_mbuf_pkthdr))
-
-#define BLE_ATT_SVR_NUM_PREP_ENTRIES     8
-#define BLE_ATT_SVR_NUM_PREP_MBUFS       8
-static bssnz_t os_membuf_t
-ble_att_svr_prep_entry_mem[OS_MEMPOOL_SIZE(BLE_ATT_SVR_NUM_PREP_ENTRIES,
-                           sizeof (struct ble_att_prep_entry))];
+static void *ble_att_svr_prep_entry_mem;
 static struct os_mempool ble_att_svr_prep_entry_pool;
-static bssnz_t os_membuf_t
-ble_att_svr_prep_mbuf_mem[OS_MEMPOOL_SIZE(BLE_ATT_SVR_NUM_PREP_MBUFS,
-                          BLE_ATT_SVR_PREP_MBUF_MEMBLOCK_SIZE)];
-static struct os_mempool ble_att_svr_prep_mbuf_mempool;
-static struct os_mbuf_pool ble_att_svr_prep_mbuf_pool;
 
 static bssnz_t uint8_t ble_att_svr_flat_buf[BLE_ATT_ATTR_MAX_LEN];
 
@@ -75,17 +58,6 @@ ble_att_svr_entry_alloc(void)
     return entry;
 }
 
-#if 0
-static void
-ble_att_svr_entry_free(struct ble_att_svr_entry *entry)
-{
-    int rc;
-
-    rc = os_memblock_put(&ble_att_svr_entry_pool, entry);
-    assert(rc == 0);
-}
-#endif
-
 /**
  * Allocate the next handle id and return it.
  *
@@ -835,6 +807,10 @@ done:
 int
 ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_FIND_INFO
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_find_info_req req;
     struct os_mbuf *txom;
     uint16_t err_handle;
@@ -1096,7 +1072,6 @@ ble_att_svr_fill_type_value(uint16_t conn_handle,
     }
 
 done:
-
     any_entries = OS_MBUF_PKTHDR(txom)->omp_len >
                   BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ;
     if (rc == 0 && !any_entries) {
@@ -1164,6 +1139,10 @@ done:
 int
 ble_att_svr_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_FIND_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_find_type_value_req req;
     struct os_mbuf *txom;
     uint16_t err_handle;
@@ -1352,6 +1331,10 @@ done:
 int
 ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_READ_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_read_type_req req;
     struct os_mbuf *txom;
     uint16_t err_handle;
@@ -1485,6 +1468,10 @@ done:
 int
 ble_att_svr_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_READ
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_svr_access_ctxt ctxt;
     struct ble_att_read_req req;
     struct os_mbuf *txom;
@@ -1592,6 +1579,10 @@ done:
 int
 ble_att_svr_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_READ_BLOB
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_svr_access_ctxt ctxt;
     struct ble_att_read_blob_req req;
     struct os_mbuf *txom;
@@ -1749,6 +1740,10 @@ done:
 int
 ble_att_svr_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_READ_MULT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct os_mbuf *txom;
     uint16_t err_handle;
     uint8_t att_err;
@@ -2069,6 +2064,10 @@ done:
 int
 ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_READ_GROUP_TYPE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_read_group_type_req req;
     struct os_mbuf *txom;
     uint8_t uuid128[16];
@@ -2175,6 +2174,10 @@ done:
 int
 ble_att_svr_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_svr_access_ctxt ctxt;
     struct ble_att_write_req req;
     struct os_mbuf *txom;
@@ -2230,6 +2233,10 @@ done:
 int
 ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_WRITE_NO_RSP
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_svr_access_ctxt ctxt;
     struct ble_att_write_req req;
     uint8_t att_err;
@@ -2300,7 +2307,7 @@ ble_att_svr_prep_alloc(void)
     }
 
     memset(entry, 0, sizeof *entry);
-    entry->bape_value = os_mbuf_get_pkthdr(&ble_att_svr_prep_mbuf_pool, 0);
+    entry->bape_value = ble_hs_misc_pkthdr();
     if (entry->bape_value == NULL) {
         ble_att_svr_prep_free(entry);
         return NULL;
@@ -2459,6 +2466,10 @@ ble_att_svr_prep_write(struct ble_hs_conn *conn, uint16_t *err_handle)
 int
 ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_PREP_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_prep_write_cmd req;
     struct ble_att_prep_entry *prep_entry;
     struct ble_att_prep_entry *prep_prev;
@@ -2638,6 +2649,10 @@ done:
 int
 ble_att_svr_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_EXEC_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_exec_write_req req;
     struct ble_hs_conn *conn;
     struct os_mbuf *txom;
@@ -2699,6 +2714,10 @@ done:
 int
 ble_att_svr_rx_notify(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_NOTIFY
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_notify_req req;
     uint16_t attr_len;
     void *attr_data;
@@ -2778,6 +2797,10 @@ done:
 int
 ble_att_svr_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
 {
+#if !NIMBLE_OPT_ATT_SVR_INDICATE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_indicate_req req;
     struct os_mbuf *txom;
     uint16_t attr_len;
@@ -2835,6 +2858,13 @@ done:
     return rc;
 }
 
+static void
+ble_att_svr_free_mem(void)
+{
+    free(ble_att_svr_entry_mem);
+    ble_att_svr_entry_mem = NULL;
+}
+
 /**
  * Lock restrictions: None.
  */
@@ -2843,43 +2873,54 @@ ble_att_svr_init(void)
 {
     int rc;
 
-    STAILQ_INIT(&ble_att_svr_list);
+    ble_att_svr_free_mem();
 
-    rc = os_mempool_init(&ble_att_svr_entry_pool, BLE_ATT_SVR_NUM_ENTRIES,
-                         sizeof (struct ble_att_svr_entry),
-                         ble_att_svr_entry_mem, "ble_att_svr_entry_pool");
-    if (rc != 0) {
-        return BLE_HS_EOS;
-    }
+    if (ble_hs_cfg.max_attrs > 0) {
+        ble_att_svr_entry_mem = malloc(
+            OS_MEMPOOL_BYTES(ble_hs_cfg.max_attrs,
+                             sizeof (struct ble_att_svr_entry)));
+        if (ble_att_svr_entry_mem == NULL) {
+            rc = BLE_HS_ENOMEM;
+            goto err;
+        }
 
-    rc = os_mempool_init(&ble_att_svr_prep_entry_pool,
-                         BLE_ATT_SVR_NUM_PREP_ENTRIES,
-                         sizeof (struct ble_att_prep_entry),
-                         ble_att_svr_prep_entry_mem,
-                         "ble_att_svr_prep_entry_pool");
-    if (rc != 0) {
-        return BLE_HS_EOS;
+        rc = os_mempool_init(&ble_att_svr_entry_pool, ble_hs_cfg.max_attrs,
+                             sizeof (struct ble_att_svr_entry),
+                             ble_att_svr_entry_mem, "ble_att_svr_entry_pool");
+        if (rc != 0) {
+            rc = BLE_HS_EOS;
+            goto err;
+        }
     }
 
-    rc = os_mempool_init(&ble_att_svr_prep_mbuf_mempool,
-                         BLE_ATT_SVR_NUM_PREP_MBUFS,
-                         BLE_ATT_SVR_PREP_MBUF_MEMBLOCK_SIZE,
-                         ble_att_svr_prep_mbuf_mem,
-                         "ble_att_svr_prep_mbuf_pool");
-    if (rc != 0) {
-        return BLE_HS_EOS;
-    }
+    if (ble_hs_cfg.max_prep_entries > 0) {
+        ble_att_svr_prep_entry_mem = malloc(
+            OS_MEMPOOL_BYTES(ble_hs_cfg.max_prep_entries,
+                             sizeof (struct ble_att_prep_entry)));
+        if (ble_att_svr_prep_entry_mem == NULL) {
+            rc = BLE_HS_ENOMEM;
+            goto err;
+        }
 
-    rc = os_mbuf_pool_init(&ble_att_svr_prep_mbuf_pool,
-                           &ble_att_svr_prep_mbuf_mempool,
-                           BLE_ATT_SVR_PREP_MBUF_MEMBLOCK_SIZE,
-                           BLE_ATT_SVR_NUM_PREP_MBUFS);
-    if (rc != 0) {
-        return BLE_HS_EOS;
+        rc = os_mempool_init(&ble_att_svr_prep_entry_pool,
+                             ble_hs_cfg.max_prep_entries,
+                             sizeof (struct ble_att_prep_entry),
+                             ble_att_svr_prep_entry_mem,
+                             "ble_att_svr_prep_entry_pool");
+        if (rc != 0) {
+            rc = BLE_HS_EOS;
+            goto err;
+        }
     }
 
+    STAILQ_INIT(&ble_att_svr_list);
+
     ble_att_svr_id = 0;
     ble_att_svr_notify_cb = NULL;
 
     return 0;
+
+err:
+    ble_att_svr_free_mem();
+    return rc;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index edadbb0..78e4c26 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -21,6 +21,7 @@
 #include "os/os.h"
 #include "ble_hs_priv.h"
 #include "host/host_hci.h"
+#include "ble_hs_priv.h"
 #include "ble_hs_adv_priv.h"
 #include "ble_hci_ack.h"
 #include "ble_hs_conn.h"
@@ -83,8 +84,6 @@
  */
 #define BLE_GAP_ADV_DATA_LIMIT          (BLE_HCI_MAX_ADV_DATA_LEN - 6)
 
-#define BLE_GAP_MAX_UPDATES             4
-
 static const struct ble_gap_crt_params ble_gap_params_dflt = {
     .scan_itvl = 0x0010,
     .scan_window = 0x0010,
@@ -172,9 +171,7 @@ struct ble_gap_update_entry {
 };
 static SLIST_HEAD(, ble_gap_update_entry) ble_gap_update_entries;
 
-static bssnz_t os_membuf_t
-ble_gap_update_mem[OS_MEMPOOL_SIZE(BLE_GAP_MAX_UPDATES,
-                         sizeof (struct ble_gap_update_entry))];
+static void *ble_gap_update_mem;
 static struct os_mempool ble_gap_update_pool;
 
 static int ble_gap_adv_params_tx(void *arg);
@@ -667,6 +664,10 @@ ble_gap_conn_broken(uint16_t conn_handle)
 void
 ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     struct ble_gap_snapshot snap;
     struct ble_hs_conn *conn;
     int rc;
@@ -707,6 +708,10 @@ ble_gap_rx_disconn_complete(struct hci_disconn_complete *evt)
 void
 ble_gap_rx_update_complete(struct hci_le_conn_upd_complete *evt)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     struct ble_gap_update_entry *entry;
     struct ble_gap_snapshot snap;
     struct ble_hs_conn *conn;
@@ -781,6 +786,10 @@ ble_gap_slave_in_progress(void)
 int
 ble_gap_update_in_progress(uint16_t conn_handle)
 {
+#if !NIMBLE_OPT_CONNECT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gap_update_entry *entry;
 
     ble_gap_lock();
@@ -1015,6 +1024,10 @@ ble_gap_accept_slave_conn(uint8_t addr_type, uint8_t *addr)
 void
 ble_gap_rx_adv_report(struct ble_hs_adv *adv)
 {
+#if !NIMBLE_OPT_ROLE_OBSERVER
+    return;
+#endif
+
     struct ble_hs_adv_fields fields;
     int rc;
 
@@ -1049,6 +1062,10 @@ ble_gap_rx_adv_report(struct ble_hs_adv *adv)
 int
 ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
 {
+#if !NIMBLE_OPT_CONNECT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gap_snapshot snap;
     struct ble_hs_conn *conn;
     int status;
@@ -1239,6 +1256,10 @@ ble_gap_slave_timer_exp(void *arg)
 int
 ble_gap_wl_busy(void)
 {
+#if !NIMBLE_OPT_WHITELIST
+    return BLE_HS_ENOTSUP;
+#endif
+
     /* Check if application is currently setting the white list. */
     if (ble_gap_wl.op != BLE_GAP_OP_NULL) {
         return 1;
@@ -1380,8 +1401,12 @@ ble_gap_wl_tx_clear(void *arg)
  */
 int
 ble_gap_wl_set(struct ble_gap_white_entry *white_list,
-                    uint8_t white_list_count, ble_gap_wl_fn *cb, void *cb_arg)
+               uint8_t white_list_count, ble_gap_wl_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_WHITELIST
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
     int i;
 
@@ -1461,6 +1486,10 @@ ble_gap_adv_disable_tx(void *arg)
 int
 ble_gap_adv_stop(void)
 {
+#if !NIMBLE_OPT_ADVERTISE
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     /* Do nothing if advertising is already disabled. */
@@ -1830,6 +1859,10 @@ ble_gap_adv_start(uint8_t discoverable_mode, uint8_t connectable_mode,
                   struct hci_adv_params *adv_params,
                   ble_gap_conn_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_ADVERTISE
+    return BLE_HS_ENOTSUP;
+#endif
+
     uint8_t op;
     int rc;
 
@@ -1894,8 +1927,8 @@ ble_gap_adv_start(uint8_t discoverable_mode, uint8_t connectable_mode,
     }
 
     ble_gap_adv_itvls(discoverable_mode, connectable_mode,
-                           &ble_gap_slave.adv_params.adv_itvl_min,
-                           &ble_gap_slave.adv_params.adv_itvl_max);
+                      &ble_gap_slave.adv_params.adv_itvl_min,
+                      &ble_gap_slave.adv_params.adv_itvl_max);
 
     rc = ble_gap_adv_initiate();
     if (rc != 0) {
@@ -1911,6 +1944,10 @@ ble_gap_adv_start(uint8_t discoverable_mode, uint8_t connectable_mode,
 int
 ble_gap_adv_set_fields(struct ble_hs_adv_fields *adv_fields)
 {
+#if !NIMBLE_OPT_ADVERTISE
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     rc = ble_hs_adv_set_fields(adv_fields, ble_gap_slave.adv_data,
@@ -2063,9 +2100,13 @@ ble_gap_disc_tx_params(void *arg)
  */
 int
 ble_gap_disc(uint32_t duration_ms, uint8_t discovery_mode,
-                  uint8_t scan_type, uint8_t filter_policy,
-                  ble_gap_disc_fn *cb, void *cb_arg)
+             uint8_t scan_type, uint8_t filter_policy,
+             ble_gap_disc_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_ROLE_OBSERVER
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     if (discovery_mode != BLE_GAP_DISC_MODE_LTD &&
@@ -2204,6 +2245,10 @@ ble_gap_conn_initiate(int addr_type, uint8_t *addr,
                       struct ble_gap_crt_params *params,
                       ble_gap_conn_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_ROLE_CENTRAL
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     if (addr_type != BLE_ADDR_TYPE_PUBLIC &&
@@ -2439,6 +2484,10 @@ ble_gap_param_reply_ack(struct ble_hci_ack *ack, void *arg)
 void
 ble_gap_rx_param_req(struct hci_le_conn_param_req *evt)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     struct hci_conn_param_neg_reply neg_reply;
     struct ble_gap_upd_params peer_params;
     struct ble_gap_update_entry *entry;
@@ -2592,6 +2641,10 @@ ble_gap_update_tx(void *arg)
 int
 ble_gap_update_params(uint16_t conn_handle, struct ble_gap_upd_params *params)
 {
+#if !NIMBLE_OPT_CONNECT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gap_update_entry *entry;
     int rc;
 
@@ -2643,19 +2696,33 @@ ble_gap_init(void)
     memset(&ble_gap_slave, 0, sizeof ble_gap_slave);
     memset(&ble_gap_wl, 0, sizeof ble_gap_wl);
 
+    free(ble_gap_update_mem);
+    ble_gap_update_mem = malloc(
+        OS_MEMPOOL_BYTES(ble_hs_cfg.max_conn_update_entries,
+                         sizeof (struct ble_gap_update_entry)));
+
     os_callout_func_init(&ble_gap_master_timer, &ble_hs_evq,
                          ble_gap_master_timer_exp, NULL);
     os_callout_func_init(&ble_gap_slave_timer, &ble_hs_evq,
                          ble_gap_slave_timer_exp, NULL);
 
-    rc = os_mempool_init(&ble_gap_update_pool, BLE_GAP_MAX_UPDATES,
-                         sizeof (struct ble_gap_update_entry),
-                         ble_gap_update_mem, "ble_gap_update_pool");
-    if (rc != 0) {
-        return BLE_HS_EOS;
+    if (ble_hs_cfg.max_conn_update_entries > 0) {
+        rc = os_mempool_init(&ble_gap_update_pool,
+                             ble_hs_cfg.max_conn_update_entries,
+                             sizeof (struct ble_gap_update_entry),
+                             ble_gap_update_mem, "ble_gap_update_pool");
+        if (rc != 0) {
+            rc = BLE_HS_EOS;
+            goto err;
+        }
     }
 
     SLIST_INIT(&ble_gap_update_entries);
 
     return 0;
+
+err:
+    free(ble_gap_update_mem);
+    ble_gap_update_mem = NULL;
+    return rc;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/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 fae7d2b..c68308d 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -33,7 +33,6 @@
  * $definitions / declarations                                               *
  *****************************************************************************/
 
-#define BLE_GATT_NUM_PROCS                      16      /* XXX Configurable. */
 #define BLE_GATT_HEARTBEAT_PERIOD               1000    /* Milliseconds. */
 #define BLE_GATT_UNRESPONSIVE_TIMEOUT           30000   /* Milliseconds. */
 
@@ -505,7 +504,10 @@ ble_gattc_locked_by_cur_task(void)
 static void
 ble_gattc_assert_sanity(void)
 {
-#ifdef BLE_HS_DEBUG
+#if !BLE_HS_DEBUG
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     unsigned mask;
     int num_set;
@@ -523,7 +525,6 @@ ble_gattc_assert_sanity(void)
 
         assert(num_set == 1);
     }
-#endif
 }
 
 /*****************************************************************************
@@ -1354,6 +1355,10 @@ int
 ble_gattc_disc_all_svcs(uint16_t conn_handle, ble_gatt_disc_svc_fn *cb,
                         void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_DISC_ALL_SVCS
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -1539,6 +1544,10 @@ int
 ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, void *service_uuid128,
                            ble_gatt_disc_svc_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_DISC_SVC_UUID
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -1825,6 +1834,10 @@ ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
                         uint16_t end_handle,
                         ble_gatt_disc_svc_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_FIND_INC_SVCS
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2040,6 +2053,10 @@ ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
                         uint16_t end_handle, ble_gatt_chr_fn *cb,
                         void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_DISC_ALL_CHRS
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2262,6 +2279,10 @@ ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
                             uint16_t end_handle, void *uuid128,
                             ble_gatt_chr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_DISC_CHR_UUID
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2451,6 +2472,10 @@ ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t chr_def_handle,
                         uint16_t chr_end_handle,
                         ble_gatt_dsc_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_DISC_ALL_DSCS
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2594,6 +2619,10 @@ int
 ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle,
                ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_READ
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2772,6 +2801,10 @@ ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
                        uint16_t end_handle, void *uuid128,
                        ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_READ_UUID
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -2951,6 +2984,10 @@ int
 ble_gattc_read_long(uint16_t conn_handle, uint16_t handle,
                     ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_READ_LONG
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3093,6 +3130,10 @@ ble_gattc_read_mult(uint16_t conn_handle, uint16_t *handles,
                     uint8_t num_handles, ble_gatt_mult_attr_fn *cb,
                     void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_READ_MULT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3204,6 +3245,10 @@ int
 ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, void *value,
                        uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_WRITE_NO_RSP
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3315,6 +3360,10 @@ int
 ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
                 uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_WRITE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3531,6 +3580,10 @@ int
 ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle, void *value,
                      uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_WRITE_LONG
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3740,6 +3793,10 @@ ble_gattc_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
                          int num_attrs, ble_gatt_reliable_attr_fn *cb,
                          void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_WRITE_RELIABLE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3772,6 +3829,10 @@ ble_gattc_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
 int
 ble_gattc_notify(struct ble_hs_conn *conn, uint16_t chr_val_handle)
 {
+#if !NIMBLE_OPT_GATT_NOTIFY
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_svr_access_ctxt ctxt;
     struct ble_att_notify_req req;
     int rc;
@@ -3801,6 +3862,10 @@ ble_gattc_notify(struct ble_hs_conn *conn, uint16_t chr_val_handle)
 int
 ble_gattc_notify_custom(uint16_t conn_handle, struct ble_gatt_attr *attr)
 {
+#if !NIMBLE_OPT_GATT_NOTIFY
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_att_notify_req req;
     struct ble_hs_conn *conn;
     int rc;
@@ -3956,6 +4021,10 @@ int
 ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle,
                    ble_gatt_attr_fn *cb, void *cb_arg)
 {
+#if !NIMBLE_OPT_GATT_INDICATE
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -3973,110 +4042,6 @@ ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle,
 }
 
 /*****************************************************************************
- * $read descriptor                                                          *
- *****************************************************************************/
-
-/**
- * Initiates GATT procedure: Read Characteristic Descriptors.
- *
- * Lock restrictions:
- *     o Caller unlocks gattc.
- *
- * @param conn_handle           The connection over which to execute the
- *                                  procedure.
- * @param attr_handle           The handle of the descriptor to read.
- * @param cb                    The function to call to report procedure status
- *                                  updates; null for no callback.
- * @param cb_arg                The argument to pass to the callback function.
- */
-int
-ble_gattc_read_dsc(uint16_t conn_handle, uint16_t attr_handle,
-                   ble_gatt_attr_fn *cb, void *cb_arg)
-{
-    return ble_gattc_read(conn_handle, attr_handle, cb, cb_arg);
-}
-
-/*****************************************************************************
- * $read long descriptor                                                     *
- *****************************************************************************/
-
-/**
- * Initiates GATT procedure: Read Long Characteristic Descriptors.
- *
- * Lock restrictions:
- *     o Caller unlocks gattc.
- *
- * @param conn_handle           The connection over which to execute the
- *                                  procedure.
- * @param attr_handle           The handle of the descriptor to read.
- * @param cb                    The function to call to report procedure status
- *                                  updates; null for no callback.
- * @param cb_arg                The argument to pass to the callback function.
- */
-int
-ble_gattc_read_long_dsc(uint16_t conn_handle, uint16_t attr_handle,
-                        ble_gatt_attr_fn *cb, void *cb_arg)
-{
-    return ble_gattc_read_long(conn_handle, attr_handle, cb, cb_arg);
-}
-
-/*****************************************************************************
- * $write descriptor                                                         *
- *****************************************************************************/
-
-/**
- * Initiates GATT procedure: Write Characteristic Descriptors.
- *
- * Lock restrictions:
- *     o Caller unlocks gattc.
- *
- * @param conn_handle           The connection over which to execute the
- *                                  procedure.
- * @param attr_handle           The handle of the descriptor to write.
- * @param value                 The value to write to the descriptor.
- * @param value_len             The number of bytes to write.
- * @param cb                    The function to call to report procedure status
- *                                  updates; null for no callback.
- * @param cb_arg                The argument to pass to the callback function.
- */
-int
-ble_gattc_write_dsc(uint16_t conn_handle, uint16_t attr_handle, void *value,
-                    uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg)
-{
-    return ble_gattc_write(conn_handle, attr_handle, value, value_len,
-                           cb, cb_arg);
-
-}
-
-/*****************************************************************************
- * $write long descriptor                                                    *
- *****************************************************************************/
-
-/**
- * Initiates GATT procedure: Write Long Characteristic Descriptors.
- *
- * Lock restrictions:
- *     o Caller unlocks gattc.
- *
- * @param conn_handle           The connection over which to execute the
- *                                  procedure.
- * @param attr_handle           The handle of the descriptor to write.
- * @param value                 The value to write to the descriptor.
- * @param value_len             The number of bytes to write.
- * @param cb                    The function to call to report procedure status
- *                                  updates; null for no callback.
- * @param cb_arg                The argument to pass to the callback function.
- */
-int
-ble_gattc_write_long_dsc(uint16_t conn_handle, uint16_t attr_handle,
-                         void *value, uint16_t value_len,
-                         ble_gatt_attr_fn *cb, void *cb_arg)
-{
-    return ble_gattc_write_long(conn_handle, attr_handle, value, value_len,
-                                cb, cb_arg);
-}
-
-/*****************************************************************************
  * $rx                                                                       *
  *****************************************************************************/
 
@@ -4161,6 +4126,10 @@ void
 ble_gattc_rx_find_info_idata(uint16_t conn_handle,
                              struct ble_att_find_info_idata *idata)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_INFO
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4183,6 +4152,10 @@ ble_gattc_rx_find_info_idata(uint16_t conn_handle,
 void
 ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_INFO
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4206,6 +4179,10 @@ void
 ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle,
                                    struct ble_att_find_type_value_hinfo *hinfo)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_TYPE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4228,6 +4205,10 @@ ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle,
 void
 ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status)
 {
+#if !NIMBLE_OPT_ATT_CLT_FIND_TYPE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4251,6 +4232,10 @@ void
 ble_gattc_rx_read_type_adata(uint16_t conn_handle,
                              struct ble_att_read_type_adata *adata)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_TYPE
+    return;
+#endif
+
     const struct ble_gattc_rx_adata_entry *rx_entry;
     struct ble_gattc_proc *proc;
     int rc;
@@ -4276,6 +4261,10 @@ ble_gattc_rx_read_type_adata(uint16_t conn_handle,
 void
 ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_TYPE
+    return;
+#endif
+
     const struct ble_gattc_rx_complete_entry *rx_entry;
     struct ble_gattc_proc *proc;
     int rc;
@@ -4302,6 +4291,10 @@ void
 ble_gattc_rx_read_group_type_adata(uint16_t conn_handle,
                                    struct ble_att_read_group_type_adata *adata)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4324,6 +4317,10 @@ ble_gattc_rx_read_group_type_adata(uint16_t conn_handle,
 void
 ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int status)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4347,6 +4344,10 @@ void
 ble_gattc_rx_read_rsp(uint16_t conn_handle, int status, void *value,
                       int value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ
+    return;
+#endif
+
     const struct ble_gattc_rx_attr_entry *rx_entry;
     struct ble_gattc_proc *proc;
     int rc;
@@ -4373,6 +4374,10 @@ void
 ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
                            void *value, int value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_BLOB
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4396,6 +4401,10 @@ void
 ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
                            void *value, int value_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_READ_MULT
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4419,6 +4428,10 @@ ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
 void
 ble_gattc_rx_write_rsp(uint16_t conn_handle)
 {
+#if !NIMBLE_OPT_ATT_CLT_WRITE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4443,6 +4456,10 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
                             struct ble_att_prep_write_cmd *rsp,
                             void *attr_data, uint16_t attr_data_len)
 {
+#if !NIMBLE_OPT_ATT_CLT_PREP_WRITE
+    return;
+#endif
+
     const struct ble_gattc_rx_prep_entry *rx_entry;
     struct ble_gattc_proc *proc;
     int rc;
@@ -4468,6 +4485,10 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
 void
 ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
 {
+#if !NIMBLE_OPT_ATT_CLT_EXEC_WRITE
+    return;
+#endif
+
     const struct ble_gattc_rx_exec_entry *rx_entry;
     struct ble_gattc_proc *proc;
     int rc;
@@ -4493,6 +4514,10 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
 void
 ble_gattc_rx_indicate_rsp(uint16_t conn_handle)
 {
+#if !NIMBLE_OPT_ATT_CLT_INDICATE
+    return;
+#endif
+
     struct ble_gattc_proc *proc;
     int rc;
 
@@ -4720,21 +4745,23 @@ ble_gattc_init(void)
         goto err;
     }
 
-    ble_gattc_proc_mem = malloc(
-        OS_MEMPOOL_BYTES(BLE_GATT_NUM_PROCS,
-                         sizeof (struct ble_gattc_proc)));
-    if (ble_gattc_proc_mem == NULL) {
-        rc = BLE_HS_ENOMEM;
-        goto err;
-    }
+    if (ble_hs_cfg.max_gattc_procs > 0) {
+        ble_gattc_proc_mem = malloc(
+            OS_MEMPOOL_BYTES(ble_hs_cfg.max_gattc_procs,
+                             sizeof (struct ble_gattc_proc)));
+        if (ble_gattc_proc_mem == NULL) {
+            rc = BLE_HS_ENOMEM;
+            goto err;
+        }
 
-    rc = os_mempool_init(&ble_gattc_proc_pool,
-                         BLE_GATT_NUM_PROCS,
-                         sizeof (struct ble_gattc_proc),
-                         ble_gattc_proc_mem,
-                         "ble_gattc_proc_pool");
-    if (rc != 0) {
-        goto err;
+        rc = os_mempool_init(&ble_gattc_proc_pool,
+                             ble_hs_cfg.max_gattc_procs,
+                             sizeof (struct ble_gattc_proc),
+                             ble_gattc_proc_mem,
+                             "ble_gattc_proc_pool");
+        if (rc != 0) {
+            goto err;
+        }
     }
 
     STAILQ_INIT(&ble_gattc_list);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_gatts.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatts.c b/net/nimble/host/src/ble_gatts.c
index c45012e..a92c6e4 100644
--- a/net/nimble/host/src/ble_gatts.c
+++ b/net/nimble/host/src/ble_gatts.c
@@ -28,17 +28,13 @@
 #define BLE_GATTS_INCLUDE_SZ    6
 #define BLE_GATTS_CHR_MAX_SZ    19
 
-#define BLE_GATTS_MAX_SERVICES  16 /* XXX: Make this configurable. */
-#define BLE_GATTS_MAX_CLT_CFGS  32 /* XXX: Make this configurable. */
-
 struct ble_gatts_svc_entry {
     const struct ble_gatt_svc_def *svc;
     uint16_t handle;            /* 0 means unregistered. */
     uint16_t end_group_handle;  /* 0xffff means unset. */
 };
 
-static struct ble_gatts_svc_entry
-    ble_gatts_svc_entries[BLE_GATTS_MAX_SERVICES];
+static struct ble_gatts_svc_entry *ble_gatts_svc_entries;
 static int ble_gatts_num_svc_entries;
 
 static os_membuf_t *ble_gatts_clt_cfg_mem;
@@ -855,6 +851,10 @@ ble_gatts_register_svcs(const struct ble_gatt_svc_def *svcs,
         ble_gatts_svc_entries[i].handle = 0;
         ble_gatts_svc_entries[i].end_group_handle = 0xffff;
     }
+    if (i > ble_hs_cfg.max_services) {
+        return BLE_HS_ENOMEM;
+    }
+
     ble_gatts_num_svc_entries = i;
 
     total_registered = 0;
@@ -924,8 +924,12 @@ ble_gatts_clt_cfg_init(void)
         return 0;
     }
 
+    if (ble_gatts_num_cfgable_chrs > ble_hs_cfg.max_client_configs) {
+        return BLE_HS_ENOMEM;
+    }
+
     /* Initialize client-configuration memory pool. */
-    num_elems = BLE_GATTS_MAX_CLT_CFGS / ble_gatts_num_cfgable_chrs;
+    num_elems = ble_hs_cfg.max_client_configs / ble_gatts_num_cfgable_chrs;
     rc = os_mempool_init(&ble_gatts_clt_cfg_pool, num_elems,
                          ble_gatts_clt_cfg_size(), ble_gatts_clt_cfg_mem,
                          "ble_gatts_clt_cfg_pool");
@@ -977,7 +981,7 @@ ble_gatts_conn_init(struct ble_gatts_conn *gatts_conn)
         ble_gatts_clt_cfg_inited = 1;
     }
 
-    if (ble_gatts_num_cfgable_chrs) {
+    if (ble_gatts_num_cfgable_chrs > 0) {
         ble_gatts_conn_deinit(gatts_conn);
         gatts_conn->clt_cfgs = os_memblock_get(&ble_gatts_clt_cfg_pool);
         if (gatts_conn->clt_cfgs == NULL) {
@@ -1079,6 +1083,10 @@ static void
 ble_gatts_free_mem(void)
 {
     free(ble_gatts_clt_cfg_mem);
+    ble_gatts_clt_cfg_mem = NULL;
+
+    free(ble_gatts_svc_entries);
+    ble_gatts_svc_entries = NULL;
 }
 
 /**
@@ -1094,12 +1102,23 @@ ble_gatts_init(void)
     ble_gatts_clt_cfgs = NULL;
     ble_gatts_clt_cfg_inited = 0;
 
-    ble_gatts_clt_cfg_mem = malloc(
-        OS_MEMPOOL_BYTES(BLE_GATTS_MAX_CLT_CFGS,
-                         sizeof (struct ble_gatts_clt_cfg)));
-    if (ble_gatts_clt_cfg_mem == NULL) {
-        rc = BLE_HS_ENOMEM;
-        goto err;
+    if (ble_hs_cfg.max_client_configs > 0) {
+        ble_gatts_clt_cfg_mem = malloc(
+            OS_MEMPOOL_BYTES(ble_hs_cfg.max_client_configs,
+                             sizeof (struct ble_gatts_clt_cfg)));
+        if (ble_gatts_clt_cfg_mem == NULL) {
+            rc = BLE_HS_ENOMEM;
+            goto err;
+        }
+    }
+
+    if (ble_hs_cfg.max_services > 0) {
+        ble_gatts_svc_entries =
+            malloc(ble_hs_cfg.max_services * sizeof *ble_gatts_svc_entries);
+        if (ble_gatts_svc_entries == NULL) {
+            rc = BLE_HS_ENOMEM;
+            goto err;
+        }
     }
 
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 094e992..03c0abd 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -42,14 +42,14 @@
 static struct os_task ble_hs_task;
 static os_stack_t ble_hs_stack[BLE_HS_STACK_SIZE] bssnz_t;
 
-#define HCI_CMD_BUFS        (8)
+#define HCI_CMD_BUFS        (4)
 #define HCI_CMD_BUF_SIZE    (260)       /* XXX: temporary, Fix later */
 struct os_mempool g_hci_cmd_pool;
 static os_membuf_t g_hci_cmd_buf[OS_MEMPOOL_SIZE(HCI_CMD_BUFS,
                                                  HCI_CMD_BUF_SIZE)] bssnz_t;
 
 /* XXX: this might be transport layer*/
-#define HCI_NUM_OS_EVENTS       (32)
+#define HCI_NUM_OS_EVENTS       (HCI_CMD_BUFS)
 #define HCI_OS_EVENT_BUF_SIZE   (sizeof(struct os_event))
 
 struct os_mempool g_hci_os_event_pool;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_hs_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_adv.c b/net/nimble/host/src/ble_hs_adv.c
index 6ceb017..0270b1e 100644
--- a/net/nimble/host/src/ble_hs_adv.c
+++ b/net/nimble/host/src/ble_hs_adv.c
@@ -41,6 +41,10 @@ int
 ble_hs_adv_set_flat(uint8_t type, int data_len, void *data,
                     uint8_t *dst, uint8_t *dst_len, uint8_t max_len)
 {
+#if !NIMBLE_OPT_ADVERTISE
+    return BLE_HS_ENOTSUP;
+#endif
+
     int rc;
 
     assert(data_len > 0);
@@ -109,6 +113,10 @@ int
 ble_hs_adv_set_fields(struct ble_hs_adv_fields *adv_fields,
                       uint8_t *dst, uint8_t *dst_len, uint8_t max_len)
 {
+#if !NIMBLE_OPT_ADVERTISE
+    return BLE_HS_ENOTSUP;
+#endif
+
     uint8_t type;
     int rc;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_hs_cfg.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_cfg.c b/net/nimble/host/src/ble_hs_cfg.c
index e29b3ef..6040c65 100644
--- a/net/nimble/host/src/ble_hs_cfg.c
+++ b/net/nimble/host/src/ble_hs_cfg.c
@@ -16,9 +16,28 @@
 
 #include "ble_hs_priv.h"
 
-static struct ble_hs_cfg ble_hs_cfg_dflt = {
-    .max_connections = 16,
+static const struct ble_hs_cfg ble_hs_cfg_dflt = {
+    /** Connection settings. */
     .max_outstanding_pkts_per_conn = 5,
+
+#if NIMBLE_OPT_CONNECT
+    .max_connections = 8,
+    .max_conn_update_entries = 4,
+#else
+    .max_connections = 0,
+    .max_conn_update_entries = 0,
+#endif
+
+    /** GATT server settings. */
+    .max_services = 16,
+    .max_client_configs = 32,
+
+    /** GATT client settings. */
+    .max_gattc_procs = 16,
+
+    /** ATT server settings. */
+    .max_attrs = 64,
+    .max_prep_entries = 6,
 };
 
 struct ble_hs_cfg ble_hs_cfg;
@@ -26,5 +45,37 @@ struct ble_hs_cfg ble_hs_cfg;
 void
 ble_hs_cfg_init(void)
 {
-    ble_hs_cfg = ble_hs_cfg_dflt;
+    if (ble_hs_cfg.max_outstanding_pkts_per_conn == 0) {
+        ble_hs_cfg.max_outstanding_pkts_per_conn =
+            ble_hs_cfg_dflt.max_outstanding_pkts_per_conn;
+    }
+
+    if (ble_hs_cfg.max_connections == 0) {
+        ble_hs_cfg.max_connections = ble_hs_cfg_dflt.max_connections;
+    }
+
+    if (ble_hs_cfg.max_conn_update_entries == 0) {
+        ble_hs_cfg.max_conn_update_entries =
+            ble_hs_cfg_dflt.max_conn_update_entries;
+    }
+
+    if (ble_hs_cfg.max_services == 0) {
+        ble_hs_cfg.max_services = ble_hs_cfg_dflt.max_services;
+    }
+
+    if (ble_hs_cfg.max_client_configs == 0) {
+        ble_hs_cfg.max_client_configs = ble_hs_cfg_dflt.max_client_configs;
+    }
+
+    if (ble_hs_cfg.max_gattc_procs == 0) {
+        ble_hs_cfg.max_gattc_procs = ble_hs_cfg_dflt.max_gattc_procs;
+    }
+
+    if (ble_hs_cfg.max_attrs == 0) {
+        ble_hs_cfg.max_attrs = ble_hs_cfg_dflt.max_attrs;
+    }
+
+    if (ble_hs_cfg.max_prep_entries == 0) {
+        ble_hs_cfg.max_prep_entries = ble_hs_cfg_dflt.max_prep_entries;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index cbbfc22..8e3d9a7 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -72,6 +72,10 @@ ble_hs_conn_locked_by_cur_task(void)
 int
 ble_hs_conn_can_alloc(void)
 {
+#if !NIMBLE_OPT_CONNECT
+    return 0;
+#endif
+
     return ble_hs_conn_pool.mp_num_free >= 1;
 }
 
@@ -81,6 +85,10 @@ ble_hs_conn_can_alloc(void)
 struct ble_l2cap_chan *
 ble_hs_conn_chan_find(struct ble_hs_conn *conn, uint16_t cid)
 {
+#if !NIMBLE_OPT_CONNECT
+    return NULL;
+#endif
+
     struct ble_l2cap_chan *chan;
 
     SLIST_FOREACH(chan, &conn->bhc_channels, blc_next) {
@@ -102,6 +110,10 @@ ble_hs_conn_chan_find(struct ble_hs_conn *conn, uint16_t cid)
 int
 ble_hs_conn_chan_insert(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan)
 {
+#if !NIMBLE_OPT_CONNECT
+    return BLE_HS_ENOTSUP;
+#endif
+
     struct ble_l2cap_chan *prev;
     struct ble_l2cap_chan *cur;
 
@@ -132,6 +144,10 @@ ble_hs_conn_chan_insert(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan)
 struct ble_hs_conn *
 ble_hs_conn_alloc(void)
 {
+#if !NIMBLE_OPT_CONNECT
+    return NULL;
+#endif
+
     struct ble_l2cap_chan *chan;
     struct ble_hs_conn *conn;
     int rc;
@@ -196,6 +212,10 @@ ble_hs_conn_delete_chan(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan)
 void
 ble_hs_conn_free(struct ble_hs_conn *conn)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     struct ble_l2cap_chan *chan;
     int rc;
 
@@ -221,6 +241,10 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
 void
 ble_hs_conn_insert(struct ble_hs_conn *conn)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     ble_hs_conn_lock();
 
     assert(ble_hs_conn_find(conn->bhc_handle) == NULL);
@@ -235,6 +259,10 @@ ble_hs_conn_insert(struct ble_hs_conn *conn)
 void
 ble_hs_conn_remove(struct ble_hs_conn *conn)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     SLIST_REMOVE(&ble_hs_conns, conn, ble_hs_conn, bhc_next);
 }
 
@@ -244,6 +272,10 @@ ble_hs_conn_remove(struct ble_hs_conn *conn)
 struct ble_hs_conn *
 ble_hs_conn_find(uint16_t conn_handle)
 {
+#if !NIMBLE_OPT_CONNECT
+    return NULL;
+#endif
+
     struct ble_hs_conn *conn;
 
     SLIST_FOREACH(conn, &ble_hs_conns, bhc_next) {
@@ -261,6 +293,10 @@ ble_hs_conn_find(uint16_t conn_handle)
 int
 ble_hs_conn_exists(uint16_t conn_handle)
 {
+#if !NIMBLE_OPT_CONNECT
+    return 0;
+#endif
+
     struct ble_hs_conn *conn;
 
     ble_hs_conn_lock();
@@ -278,6 +314,10 @@ ble_hs_conn_exists(uint16_t conn_handle)
 struct ble_hs_conn *
 ble_hs_conn_first(void)
 {
+#if !NIMBLE_OPT_CONNECT
+    return NULL;
+#endif
+
     return SLIST_FIRST(&ble_hs_conns);
 }
 
@@ -296,6 +336,10 @@ ble_hs_conn_txable_transition(struct ble_hs_conn *conn)
 void
 ble_hs_conn_rx_num_completed_pkts(uint16_t handle, uint16_t num_pkts)
 {
+#if !NIMBLE_OPT_CONNECT
+    return;
+#endif
+
     struct ble_hs_conn *conn;
     int could_tx;
     int can_tx;
@@ -327,6 +371,10 @@ ble_hs_conn_rx_num_completed_pkts(uint16_t handle, uint16_t num_pkts)
 int
 ble_hs_conn_can_tx(struct ble_hs_conn *conn)
 {
+#if !NIMBLE_OPT_CONNECT
+    return 0;
+#endif
+
     return ble_hs_cfg.max_outstanding_pkts_per_conn == 0 ||
            conn->bhc_outstanding_pkts <
                 ble_hs_cfg.max_outstanding_pkts_per_conn;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/ble_hs_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_priv.h b/net/nimble/host/src/ble_hs_priv.h
index 0aae2c9..4700c8b 100644
--- a/net/nimble/host/src/ble_hs_priv.h
+++ b/net/nimble/host/src/ble_hs_priv.h
@@ -18,6 +18,7 @@
 #define H_BLE_HS_PRIV_
 
 #include <inttypes.h>
+#include "nimble/nimble_opt.h"
 #include "host/ble_hs.h"
 struct os_mbuf;
 struct os_mempool;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/host/src/test/ble_gatt_read_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_read_test.c b/net/nimble/host/src/test/ble_gatt_read_test.c
index ef103cc..7eb2c4c 100644
--- a/net/nimble/host/src/test/ble_gatt_read_test.c
+++ b/net/nimble/host/src/test/ble_gatt_read_test.c
@@ -551,132 +551,6 @@ ble_gatt_read_test_misc_mult_verify_bad(uint8_t att_status,
     TEST_ASSERT(!ble_gattc_any_jobs());
 }
 
-static void
-ble_gatt_read_test_misc_dsc_verify_good(struct ble_gatt_attr *attr)
-{
-    struct ble_hs_conn *conn;
-    int rc;
-
-    ble_gatt_read_test_misc_init();
-    conn = ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
-                                        NULL, NULL);
-
-    rc = ble_gattc_read_dsc(conn->bhc_handle, attr->handle,
-                            ble_gatt_read_test_cb, NULL);
-    TEST_ASSERT_FATAL(rc == 0);
-
-    ble_gatt_read_test_misc_rx_rsp_good(conn, attr);
-
-    TEST_ASSERT(ble_gatt_read_test_num_attrs == 1);
-    TEST_ASSERT(ble_gatt_read_test_attrs[0].conn_handle == conn->bhc_handle);
-    TEST_ASSERT(ble_gatt_read_test_attrs[0].handle == attr->handle);
-    TEST_ASSERT(ble_gatt_read_test_attrs[0].value_len == attr->value_len);
-    TEST_ASSERT(memcmp(ble_gatt_read_test_attrs[0].value, attr->value,
-                       attr->value_len) == 0);
-}
-
-static void
-ble_gatt_read_test_misc_dsc_verify_bad(uint8_t att_status,
-                                       struct ble_gatt_attr *attr)
-{
-    struct ble_hs_conn *conn;
-    int rc;
-
-    ble_gatt_read_test_misc_init();
-    conn = ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
-                                        NULL, NULL);
-
-    rc = ble_gattc_read_dsc(conn->bhc_handle, attr->handle,
-                            ble_gatt_read_test_cb, NULL);
-    TEST_ASSERT_FATAL(rc == 0);
-
-    ble_gatt_read_test_misc_rx_rsp_bad(conn, att_status, attr->handle);
-
-    TEST_ASSERT(ble_gatt_read_test_num_attrs == 0);
-    TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == conn->bhc_handle);
-    TEST_ASSERT(ble_gatt_read_test_bad_status ==
-                BLE_HS_ERR_ATT_BASE + att_status);
-    TEST_ASSERT(!ble_gattc_any_jobs());
-}
-
-static void
-ble_gatt_read_test_misc_dsc_long_verify_good(int max_reads,
-                                         struct ble_gatt_attr *attr)
-{
-    struct ble_hs_conn *conn;
-    int reads_left;
-    int chunk_sz;
-    int rem_len;
-    int att_op;
-    int off;
-    int rc;
-
-    ble_gatt_read_test_misc_init();
-    conn = ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
-                                        NULL, NULL);
-
-    if (max_reads == 0) {
-        max_reads = INT_MAX;
-    }
-    reads_left = max_reads;
-    rc = ble_gattc_read_long_dsc(conn->bhc_handle, attr->handle,
-                                 ble_gatt_read_test_long_cb, &reads_left);
-    TEST_ASSERT_FATAL(rc == 0);
-
-    off = 0;
-    rem_len = attr->value_len;
-    do {
-        if (rem_len > BLE_ATT_MTU_DFLT - 1) {
-            chunk_sz = BLE_ATT_MTU_DFLT - 1;
-        } else {
-            chunk_sz = rem_len;
-        }
-        if (off == 0) {
-            att_op = BLE_ATT_OP_READ_RSP;
-        } else {
-            att_op = BLE_ATT_OP_READ_BLOB_RSP;
-        }
-        ble_gatt_read_test_misc_rx_rsp_good_raw(conn, att_op,
-                                                attr->value + off, chunk_sz);
-        rem_len -= chunk_sz;
-        off += chunk_sz;
-    } while (rem_len > 0 && reads_left > 0);
-
-    TEST_ASSERT(ble_gatt_read_test_complete);
-    TEST_ASSERT(!ble_gattc_any_jobs());
-    TEST_ASSERT(ble_gatt_read_test_attrs[0].conn_handle == conn->bhc_handle);
-    TEST_ASSERT(ble_gatt_read_test_attrs[0].handle == attr->handle);
-    if (reads_left > 0) {
-        TEST_ASSERT(ble_gatt_read_test_attrs[0].value_len == attr->value_len);
-    }
-    TEST_ASSERT(memcmp(ble_gatt_read_test_attrs[0].value, attr->value,
-                       ble_gatt_read_test_attrs[0].value_len) == 0);
-}
-
-static void
-ble_gatt_read_test_misc_dsc_long_verify_bad(uint8_t att_status,
-                                            struct ble_gatt_attr *attr)
-{
-    struct ble_hs_conn *conn;
-    int rc;
-
-    ble_gatt_read_test_misc_init();
-    conn = ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
-                                        NULL, NULL);
-
-    rc = ble_gattc_read_long_dsc(conn->bhc_handle, attr->handle,
-                                 ble_gatt_read_test_long_cb, NULL);
-    TEST_ASSERT_FATAL(rc == 0);
-
-    ble_gatt_read_test_misc_rx_rsp_bad(conn, att_status, attr->handle);
-
-    TEST_ASSERT(ble_gatt_read_test_num_attrs == 0);
-    TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == conn->bhc_handle);
-    TEST_ASSERT(ble_gatt_read_test_bad_status ==
-                BLE_HS_ERR_ATT_BASE + att_status);
-    TEST_ASSERT(!ble_gattc_any_jobs());
-}
-
 TEST_CASE(ble_gatt_read_test_by_handle)
 {
     /* Read a seven-byte attribute. */
@@ -910,103 +784,12 @@ TEST_CASE(ble_gatt_read_test_mult)
         } });
 }
 
-TEST_CASE(ble_gatt_read_test_dsc)
-{
-    /* Read a seven-byte attribute. */
-    ble_gatt_read_test_misc_dsc_verify_good((struct ble_gatt_attr[]) { {
-        .handle = 43,
-        .value = (uint8_t[]){ 1,2,3,4,5,6,7 },
-        .value_len = 7,
-    } });
-
-    /* Read a one-byte attribute. */
-    ble_gatt_read_test_misc_dsc_verify_good((struct ble_gatt_attr[]) { {
-        .handle = 0x5432,
-        .value = (uint8_t[]){ 0xff },
-        .value_len = 1,
-    } });
-
-    /* Read a 200-byte attribute. */
-    ble_gatt_read_test_misc_dsc_verify_good((struct ble_gatt_attr[]) { {
-        .handle = 815,
-        .value = (uint8_t[200]){ 0 },
-        .value_len = 200,
-    } });
-
-    /* Fail due to attribute not found. */
-    ble_gatt_read_test_misc_dsc_verify_bad(BLE_ATT_ERR_ATTR_NOT_FOUND,
-        (struct ble_gatt_attr[]) { {
-            .handle = 719,
-            .value = (uint8_t[]){ 1,2,3,4,5,6,7 },
-            .value_len = 7,
-        } });
-
-    /* Fail due to invalid PDU. */
-    ble_gatt_read_test_misc_dsc_verify_bad(BLE_ATT_ERR_INVALID_PDU,
-        (struct ble_gatt_attr[]) { {
-            .handle = 65,
-            .value = (uint8_t[]){ 0xfa, 0x4c },
-            .value_len = 2,
-        } });
-}
-
-TEST_CASE(ble_gatt_read_test_long_dsc)
-{
-    uint8_t data512[512];
-    int i;
-
-    for (i = 0; i < sizeof data512; i++) {
-        data512[i] = i;
-    }
-
-    /* Read a seven-byte attribute. */
-    ble_gatt_read_test_misc_dsc_long_verify_good(0,
-        (struct ble_gatt_attr[]) { {
-            .handle = 43,
-            .value = data512,
-            .value_len = 7
-        } });
-
-    /* Read a zero-byte attribute. */
-    ble_gatt_read_test_misc_dsc_long_verify_good(0,
-        (struct ble_gatt_attr[]) { {
-            .handle = 43,
-            .value = NULL,
-            .value_len = 0
-        } });
-
-    /* Read a 60-byte attribute; three requests. */
-    ble_gatt_read_test_misc_dsc_long_verify_good(0,
-        (struct ble_gatt_attr[]) { {
-            .handle = 34,
-            .value = data512,
-            .value_len = 60
-        } });
-
-    /* Stop after two reads. */
-    ble_gatt_read_test_misc_dsc_long_verify_good(2,
-        (struct ble_gatt_attr[]) { {
-            .handle = 34,
-            .value = data512,
-            .value_len = 60
-        } });
-
-    /* Fail due to attribute not found. */
-    ble_gatt_read_test_misc_dsc_long_verify_bad(BLE_ATT_ERR_ATTR_NOT_FOUND,
-        (struct ble_gatt_attr[]) { {
-            .handle = 719,
-            .value = (uint8_t[]){ 1,2,3,4,5,6,7 },
-            .value_len = 7
-        } });
-}
 TEST_SUITE(ble_gatt_read_test_suite)
 {
     ble_gatt_read_test_by_handle();
     ble_gatt_read_test_by_uuid();
     ble_gatt_read_test_long();
     ble_gatt_read_test_mult();
-    ble_gatt_read_test_dsc();
-    ble_gatt_read_test_long_dsc();
 }
 
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/net/nimble/include/nimble/nimble_opt.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/nimble_opt.h b/net/nimble/include/nimble/nimble_opt.h
new file mode 100644
index 0000000..6a5425e
--- /dev/null
+++ b/net/nimble/include/nimble/nimble_opt.h
@@ -0,0 +1,243 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_NIMBLE_OPT_
+#define H_NIMBLE_OPT_
+
+
+/** Supported GAP roles.  By default, all four roles are enabled. */
+
+#ifndef NIMBLE_OPT_ROLE_CENTRAL
+#define NIMBLE_OPT_ROLE_CENTRAL                 1
+#endif
+
+#ifndef NIMBLE_OPT_ROLE_PERIPHERAL
+#define NIMBLE_OPT_ROLE_PERIPHERAL              1
+#endif
+
+#ifndef NIMBLE_OPT_ROLE_BROADCASTER
+#define NIMBLE_OPT_ROLE_BROADCASTER             1
+#endif
+
+#ifndef NIMBLE_OPT_ROLE_OBSERVER   
+#define NIMBLE_OPT_ROLE_OBSERVER                1
+#endif
+
+#ifndef NIMBLE_OPT_WHITELIST
+#define NIMBLE_OPT_WHITELIST                    1
+#endif
+
+
+/** Supported GATT procedures.  By default, all are enabled. */
+
+#ifndef NIMBLE_OPT_GATT_DISC_ALL_SVCS
+#define NIMBLE_OPT_GATT_DISC_ALL_SVCS           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_DISC_SVC_UUID
+#define NIMBLE_OPT_GATT_DISC_SVC_UUID           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_FIND_INC_SVCS
+#define NIMBLE_OPT_GATT_FIND_INC_SVCS           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_DISC_ALL_CHRS
+#define NIMBLE_OPT_GATT_DISC_ALL_CHRS           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_DISC_CHR_UUID
+#define NIMBLE_OPT_GATT_DISC_CHR_UUID           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_DISC_ALL_DSCS
+#define NIMBLE_OPT_GATT_DISC_ALL_DSCS           1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_READ         
+#define NIMBLE_OPT_GATT_READ                    1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_READ_UUID    
+#define NIMBLE_OPT_GATT_READ_UUID               1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_READ_LONG    
+#define NIMBLE_OPT_GATT_READ_LONG               1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_READ_MULT    
+#define NIMBLE_OPT_GATT_READ_MULT               1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_WRITE_NO_RSP 
+#define NIMBLE_OPT_GATT_WRITE_NO_RSP            1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_SIGNED_WRITE
+#define NIMBLE_OPT_GATT_SIGNED_WRITE            1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_WRITE              
+#define NIMBLE_OPT_GATT_WRITE                   1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_WRITE_LONG         
+#define NIMBLE_OPT_GATT_WRITE_LONG              1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_WRITE_RELIABLE     
+#define NIMBLE_OPT_GATT_WRITE_RELIABLE          1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_NOTIFY             
+#define NIMBLE_OPT_GATT_NOTIFY                  1
+#endif
+
+#ifndef NIMBLE_OPT_GATT_INDICATE           
+#define NIMBLE_OPT_GATT_INDICATE                1
+#endif
+
+
+/** Supported server ATT commands. */
+
+#ifndef NIMBLE_OPT_ATT_SVR_FIND_INFO
+#define NIMBLE_OPT_ATT_SVR_FIND_INFO            1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_FIND_TYPE
+#define NIMBLE_OPT_ATT_SVR_FIND_TYPE            1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_READ_TYPE
+#define NIMBLE_OPT_ATT_SVR_READ_TYPE            1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_READ
+#define NIMBLE_OPT_ATT_SVR_READ                 1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_READ_BLOB
+#define NIMBLE_OPT_ATT_SVR_READ_BLOB            1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_READ_MULT
+#define NIMBLE_OPT_ATT_SVR_READ_MULT            1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_READ_GROUP_TYPE
+#define NIMBLE_OPT_ATT_SVR_READ_GROUP_TYPE      1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_WRITE
+#define NIMBLE_OPT_ATT_SVR_WRITE                1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_WRITE_NO_RSP
+#define NIMBLE_OPT_ATT_SVR_WRITE_NO_RSP         1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_SIGNED_WRITE
+#define NIMBLE_OPT_ATT_SVR_SIGNED_WRITE         1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_PREP_WRITE
+#define NIMBLE_OPT_ATT_SVR_PREP_WRITE           1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_EXEC_WRITE
+#define NIMBLE_OPT_ATT_SVR_EXEC_WRITE           1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_NOTIFY  
+#define NIMBLE_OPT_ATT_SVR_NOTIFY               1
+#endif
+
+#ifndef NIMBLE_OPT_ATT_SVR_INDICATE
+#define NIMBLE_OPT_ATT_SVR_INDICATE             1
+#endif
+
+/***
+ * Compound options; these are generated automatically from the above
+ * options.
+ */
+
+#undef NIMBLE_OPT_ADVERTISE
+#define NIMBLE_OPT_ADVERTISE                    \
+    (NIMBLE_OPT_ROLE_BROADCASTER || NIMBLE_OPT_ROLE_PERIPHERAL)
+
+#undef NIMBLE_OPT_SCAN
+#define NIMBLE_OPT_SCAN                         \
+    (NIMBLE_OPT_ROLE_CENTRAL || NIMBLE_OPT_ROLE_OBSERVER)
+
+#undef NIMBLE_OPT_CONNECT
+#define NIMBLE_OPT_CONNECT                      \
+    (NIMBLE_OPT_ROLE_CENTRAL || NIMBLE_OPT_ROLE_PERIPHERAL)
+
+
+/** Supported client ATT commands. */
+
+#undef NIMBLE_OPT_ATT_CLT_FIND_INFO
+#define NIMBLE_OPT_ATT_CLT_FIND_INFO            (NIMBLE_OPT_GATT_DISC_ALL_DSCS)
+
+#undef NIMBLE_OPT_ATT_CLT_FIND_TYPE
+#define NIMBLE_OPT_ATT_CLT_FIND_TYPE            (NIMBLE_OPT_GATT_DISC_SVC_UUID)
+
+#undef NIMBLE_OPT_ATT_CLT_READ_TYPE
+#define NIMBLE_OPT_ATT_CLT_READ_TYPE            \
+    (NIMBLE_OPT_GATT_FIND_INC_SVCS ||           \
+     NIMBLE_OPT_GATT_DISC_ALL_CHRS ||           \
+     NIMBLE_OPT_GATT_DISC_CHRS_UUID ||          \
+     NIMBLE_OPT_GATT_READ_UUID)
+    
+#undef NIMBLE_OPT_ATT_CLT_READ
+#define NIMBLE_OPT_ATT_CLT_READ                 \
+    (NIMBLE_OPT_GATT_READ ||                    \
+     NIMBLE_OPT_GATT_READ_LONG ||               \
+     NIMBLE_OPT_GATT_FIND_INC_SVCS)
+
+#undef NIMBLE_OPT_ATT_CLT_READ_BLOB
+#define NIMBLE_OPT_ATT_CLT_READ_BLOB            (NIMBLE_OPT_GATT_READ_LONG)
+
+#undef NIMBLE_OPT_ATT_CLT_READ_MULT
+#define NIMBLE_OPT_ATT_CLT_READ_MULT            (NIMBLE_OPT_GATT_READ_MULT)
+
+#undef NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE
+#define NIMBLE_OPT_ATT_CLT_READ_GROUP_TYPE      \
+    (NIMBLE_OPT_GATT_DISC_ALL_SVCS)
+
+#undef NIMBLE_OPT_ATT_CLT_WRITE
+#define NIMBLE_OPT_ATT_CLT_WRITE                (NIMBLE_OPT_GATT_WRITE)
+
+#undef NIMBLE_OPT_ATT_CLT_WRITE_NO_RSP
+#define NIMBLE_OPT_ATT_CLT_WRITE_NO_RSP         (NIMBLE_OPT_GATT_WRITE_NO_RSP)
+
+#undef NIMBLE_OPT_ATT_CLT_PREP_WRITE
+#define NIMBLE_OPT_ATT_CLT_PREP_WRITE           (NIMBLE_OPT_GATT_WRITE_LONG)
+
+#undef NIMBLE_OPT_ATT_CLT_EXEC_WRITE
+#define NIMBLE_OPT_ATT_CLT_EXEC_WRITE           (NIMBLE_OPT_GATT_WRITE_LONG)
+
+#undef NIMBLE_OPT_ATT_CLT_NOTIFY  
+#define NIMBLE_OPT_ATT_CLT_NOTIFY               (NIMBLE_OPT_GATT_NOTIFY)
+
+#undef NIMBLE_OPT_ATT_CLT_INDICATE
+#define NIMBLE_OPT_ATT_CLT_INDICATE             (NIMBLE_OPT_GATT_INDICATE)
+
+/**
+ * Reset GATT based on connect.
+ */
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/project/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/main.c b/project/bletiny/src/main.c
index 89631b5..29392b7 100755
--- a/project/bletiny/src/main.c
+++ b/project/bletiny/src/main.c
@@ -44,7 +44,7 @@
 #define HOST_TASK_PRIO          (1)
 
 #define SHELL_TASK_PRIO         (3)
-#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(384))
+#define SHELL_TASK_STACK_SIZE   (OS_STACK_ALIGN(128))
 static bssnz_t os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
 static struct os_mutex bletiny_mutex;
@@ -79,9 +79,9 @@ struct os_mempool default_mbuf_mpool;
 #define BLETINY_STACK_SIZE             (128)
 #define BLETINY_TASK_PRIO              (HOST_TASK_PRIO + 1)
 
-#define BLETINY_MAX_SVCS               32
-#define BLETINY_MAX_CHRS               64
-#define BLETINY_MAX_DSCS               64
+#define BLETINY_MAX_SVCS               1
+#define BLETINY_MAX_CHRS               1
+#define BLETINY_MAX_DSCS               1
 
 uint32_t g_next_os_time;
 int g_bletiny_state;
@@ -1306,6 +1306,10 @@ main(void)
 
     /* Initialize the BLE host. */
     ble_hs_cfg.max_connections = 1;
+    ble_hs_cfg.max_services = 4;
+    ble_hs_cfg.max_client_configs = 4;
+    ble_hs_cfg.max_gattc_procs = 2;
+
     rc = ble_hs_init(HOST_TASK_PRIO);
     assert(rc == 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a1e419d0/project/bletiny/src/periph.c
----------------------------------------------------------------------
diff --git a/project/bletiny/src/periph.c b/project/bletiny/src/periph.c
index 5f6b401..d4f4c07 100644
--- a/project/bletiny/src/periph.c
+++ b/project/bletiny/src/periph.c
@@ -316,25 +316,25 @@ periph_register_cb(uint8_t op, union ble_gatt_register_ctxt *ctxt, void *arg)
         uuid16 = ble_uuid_128_to_16(ctxt->svc_reg.svc->uuid128);
         assert(uuid16 != 0);
         bletiny_printf("registered service 0x%04x with handle=%d\n",
-                        uuid16, ctxt->svc_reg.handle);
+                       uuid16, ctxt->svc_reg.handle);
         break;
 
     case BLE_GATT_REGISTER_OP_CHR:
         uuid16 = ble_uuid_128_to_16(ctxt->chr_reg.chr->uuid128);
         assert(uuid16 != 0);
         bletiny_printf("registering characteristic 0x%04x with def_handle=%d "
-                        "val_handle=%d\n",
-                        uuid16, ctxt->chr_reg.def_handle,
-                        ctxt->chr_reg.val_handle);
+                       "val_handle=%d\n",
+                       uuid16, ctxt->chr_reg.def_handle,
+                       ctxt->chr_reg.val_handle);
         break;
 
     case BLE_GATT_REGISTER_OP_DSC:
         uuid16 = ble_uuid_128_to_16(ctxt->dsc_reg.dsc->uuid128);
         assert(uuid16 != 0);
         bletiny_printf("registering descriptor 0x%04x with handle=%d "
-                        "chr_handle=%d\n",
-                        uuid16, ctxt->dsc_reg.dsc_handle,
-                        ctxt->dsc_reg.chr_def_handle);
+                       "chr_handle=%d\n",
+                       uuid16, ctxt->dsc_reg.dsc_handle,
+                       ctxt->dsc_reg.chr_def_handle);
         break;
 
     default: