Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master d9aa88d23 -> dc6289454


Make maximum number of connections configurable.


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

Branch: refs/heads/master
Commit: 9ef0a5ecc4a234d72652794deb0461a2691f09f4
Parents: d9aa88d
Author: Christopher Collins <[email protected]>
Authored: Mon Dec 21 14:05:48 2015 -0800
Committer: Christopher Collins <[email protected]>
Committed: Mon Dec 21 14:05:48 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_hs.h |  1 +
 net/nimble/host/src/ble_hs_cfg.c      |  1 +
 net/nimble/host/src/ble_hs_conn.c     | 14 ++++++++------
 net/nimble/host/src/ble_hs_conn.h     |  1 +
 4 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9ef0a5ec/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 839a4d5..5d1a5bf 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -34,6 +34,7 @@
 
 struct ble_hs_cfg {
     uint16_t max_outstanding_pkts_per_conn;
+    uint8_t max_connections;
 };
 extern struct ble_hs_cfg ble_hs_cfg;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9ef0a5ec/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 589e79a..b612b84 100644
--- a/net/nimble/host/src/ble_hs_cfg.c
+++ b/net/nimble/host/src/ble_hs_cfg.c
@@ -1,6 +1,7 @@
 #include "ble_hs_priv.h"
 
 static struct ble_hs_cfg ble_hs_cfg_dflt = {
+    .max_connections = 16,
     .max_outstanding_pkts_per_conn = 5,
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9ef0a5ec/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 b8e6437..68d09f5 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -26,15 +26,17 @@
 #include "ble_gatt_priv.h"
 #include "ble_hs_conn.h"
 
-#define BLE_HS_CONN_MAX         16
-
-#define BLE_HS_CONN_MAX_OUTSTANDING_PKTS    10
-
 static SLIST_HEAD(, ble_hs_conn) ble_hs_conns;
 static struct os_mempool ble_hs_conn_pool;
 
 static os_membuf_t *ble_hs_conn_elem_mem;
 
+int
+ble_hs_conn_can_alloc(void)
+{
+    return ble_hs_conn_pool.mp_num_free >= 1;
+}
+
 struct ble_hs_conn *
 ble_hs_conn_alloc(void)
 {
@@ -195,13 +197,13 @@ ble_hs_conn_init(void)
     ble_hs_conn_free_mem();
 
     ble_hs_conn_elem_mem = malloc(
-        OS_MEMPOOL_BYTES(BLE_HS_CONN_MAX,
+        OS_MEMPOOL_BYTES(ble_hs_cfg.max_connections,
                          sizeof (struct ble_hs_conn)));
     if (ble_hs_conn_elem_mem == NULL) {
         rc = BLE_HS_ENOMEM;
         goto err;
     }
-    rc = os_mempool_init(&ble_hs_conn_pool, BLE_HS_CONN_MAX,
+    rc = os_mempool_init(&ble_hs_conn_pool, ble_hs_cfg.max_connections,
                          sizeof (struct ble_hs_conn),
                          ble_hs_conn_elem_mem, "ble_hs_conn_pool");
     if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9ef0a5ec/net/nimble/host/src/ble_hs_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.h 
b/net/nimble/host/src/ble_hs_conn.h
index 8b623b7..943e77a 100644
--- a/net/nimble/host/src/ble_hs_conn.h
+++ b/net/nimble/host/src/ble_hs_conn.h
@@ -35,6 +35,7 @@ struct ble_hs_conn {
     struct ble_att_svr_conn bhc_att_svr;
 };
 
+int ble_hs_conn_can_alloc(void);
 struct ble_hs_conn *ble_hs_conn_alloc(void);
 void ble_hs_conn_free(struct ble_hs_conn *conn);
 void ble_hs_conn_insert(struct ble_hs_conn *conn);

Reply via email to