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/08/10 02:11:54 UTC

[1/8] incubator-mynewt-core git commit: BLE Host - Set state before tx HCI enable.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 96b7f79f2 -> 1e9bbc286


BLE Host - Set state before tx HCI enable.

Prior to this change, for advertising, connecting, and scanning, the
host didn't update its GAP state until after all HCI commands were sent
to the controller.  This creates a race condition, because the
controller may act on the enable command before the host GAP state has
been updated.

For example, as soon as the host tells the controlller to
start scanning, the controller may send an advertisement report event.
If the host has not updated its state yet, the advertising report gets
dropped.

Now, the host updates its state before sending the enable command to the
controller.  Unfortunately, this means the host needs to undo the state
update if the enable command fails to be sent.


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

Branch: refs/heads/develop
Commit: defcd4195f1c4e4d80935f371a0677ff66c0a42e
Parents: 96b7f79
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 16:36:02 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 16:36:02 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_gap.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/defcd419/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 49d678e..9717125 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -1733,8 +1733,11 @@ ble_gap_adv_start(uint8_t own_addr_type, uint8_t peer_addr_type,
         }
     }
 
+    ble_gap_slave.op = BLE_GAP_OP_S_ADV;
+
     rc = ble_gap_adv_enable_tx(1);
     if (rc != 0) {
+        ble_gap_slave_reset_state();
         goto done;
     }
 
@@ -1742,7 +1745,6 @@ ble_gap_adv_start(uint8_t own_addr_type, uint8_t peer_addr_type,
         ble_gap_slave_set_timer(duration_ticks);
     }
 
-    ble_gap_slave.op = BLE_GAP_OP_S_ADV;
     rc = 0;
 
 done:
@@ -2094,8 +2096,11 @@ ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
         goto done;
     }
 
+    ble_gap_master.op = BLE_GAP_OP_M_DISC;
+
     rc = ble_gap_disc_enable_tx(1, params.filter_duplicates);
     if (rc != 0) {
+        ble_gap_master_reset_state();
         goto done;
     }
 
@@ -2103,8 +2108,6 @@ ble_gap_disc(uint8_t own_addr_type, int32_t duration_ms,
         ble_gap_master_set_timer(duration_ticks);
     }
 
-    ble_gap_master.op = BLE_GAP_OP_M_DISC;
-
     rc = 0;
 
 done:
@@ -2292,9 +2295,12 @@ ble_gap_connect(uint8_t own_addr_type,
     ble_gap_master.conn.using_wl = peer_addr_type == BLE_GAP_ADDR_TYPE_WL;
     ble_gap_master.conn.our_addr_type = own_addr_type;
 
+    ble_gap_master.op = BLE_GAP_OP_M_CONN;
+
     rc = ble_gap_conn_create_tx(own_addr_type, peer_addr_type, peer_addr,
                                 conn_params);
     if (rc != 0) {
+        ble_gap_master_reset_state();
         goto done;
     }
 
@@ -2302,8 +2308,6 @@ ble_gap_connect(uint8_t own_addr_type,
         ble_gap_master_set_timer(duration_ticks);
     }
 
-    ble_gap_master.op = BLE_GAP_OP_M_CONN;
-
     rc = 0;
 
 done:


[5/8] incubator-mynewt-core git commit: BLE Host - Add missing break statement.

Posted by cc...@apache.org.
BLE Host - Add missing break statement.

This fixes a minor bug - the sending of notifications / indications
would cause the tx and rx queues to be processed unnecessarily.


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

Branch: refs/heads/develop
Commit: 665d8dc4d07c0aa65e3fdc1eb26a673c001c5930
Parents: d7ce2ac
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:50:21 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 17:50:21 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs.c | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/665d8dc4/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 02db879..231dce3 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -373,6 +373,7 @@ ble_hs_event_handle(void *unused)
         case BLE_HS_EVENT_TX_NOTIFICATIONS:
             BLE_HS_DBG_ASSERT(ev == &ble_hs_event_tx_notifications);
             ble_gatts_tx_notifications();
+            break;
 
         case OS_EVENT_T_MQUEUE_DATA:
             ble_hs_process_tx_data_queue();


[4/8] incubator-mynewt-core git commit: bletiny - Correctly limit var-len adv field sizes.

Posted by cc...@apache.org.
bletiny - Correctly limit var-len adv field sizes.


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

Branch: refs/heads/develop
Commit: d7ce2ac3bafe010b885ef79053e89c2cf500aa65
Parents: e02d7ab
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:03:48 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 17:03:48 2016 -0700

----------------------------------------------------------------------
 apps/bletiny/src/cmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d7ce2ac3/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index e50d6b0..5118aeb 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -1212,11 +1212,11 @@ cmd_sec(int argc, char **argv)
 #define CMD_ADV_DATA_MAX_UUIDS32                8
 #define CMD_ADV_DATA_MAX_UUIDS128               2
 #define CMD_ADV_DATA_MAX_PUBLIC_TGT_ADDRS       8
-#define CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN    32
-#define CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN    32
-#define CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN   32
-#define CMD_ADV_DATA_URI_MAX_LEN                32
-#define CMD_ADV_DATA_MFG_DATA_MAX_LEN           32
+#define CMD_ADV_DATA_SVC_DATA_UUID16_MAX_LEN    BLE_HS_ADV_MAX_FIELD_SZ
+#define CMD_ADV_DATA_SVC_DATA_UUID32_MAX_LEN    BLE_HS_ADV_MAX_FIELD_SZ
+#define CMD_ADV_DATA_SVC_DATA_UUID128_MAX_LEN   BLE_HS_ADV_MAX_FIELD_SZ
+#define CMD_ADV_DATA_URI_MAX_LEN                BLE_HS_ADV_MAX_FIELD_SZ
+#define CMD_ADV_DATA_MFG_DATA_MAX_LEN           BLE_HS_ADV_MAX_FIELD_SZ
 
 static int
 cmd_set_adv_data(void)


[6/8] incubator-mynewt-core git commit: BLE Host - Fix crash when #-evt-bufs > #-os-events

Posted by cc...@apache.org.
BLE Host - Fix crash when #-evt-bufs > #-os-events

When the host could not allocate an OS event for the incoming HCI event,
it tried to free the wrong thing, resulting in a null pointer
dereference.


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

Branch: refs/heads/develop
Commit: 22e7eabb0238e93bab7e0a48dc3ba505150426fa
Parents: 665d8dc
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:51:37 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 17:51:37 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/22e7eabb/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 231dce3..8d4b047 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -406,7 +406,7 @@ ble_hs_enqueue_hci_event(uint8_t *hci_evt)
 
     ev = os_memblock_get(&ble_hs_hci_ev_pool);
     if (ev == NULL) {
-        ble_hci_trans_buf_free(ev->ev_arg);
+        ble_hci_trans_buf_free(hci_evt);
     } else {
         ev->ev_queued = 0;
         ev->ev_type = BLE_HOST_HCI_EVENT_CTLR_EVENT;


[7/8] incubator-mynewt-core git commit: BLE RAM trans: evt buf sz 260-->45; ct 3-->14

Posted by cc...@apache.org.
BLE RAM trans: evt buf sz 260-->45; ct 3-->14

For the combined host-controller (RAM HCI transport), the default HCI
event buffer size was much larger than necessary.  The largest event the
NimBLE controller will send is 45 bytes, but the default buffer size was
260.

This change:

* reduces the default event buffer size from 260 to 45
* increases the default lo-prio event count from 2 to 12
* increases the default hi-prio event count from 1 to 2


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

Branch: refs/heads/develop
Commit: 8b8d887358be1d64e6002fb4efb6b4e0673a1760
Parents: 22e7eab
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:53:46 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 18:00:31 2016 -0700

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_hci.h  |  3 ++
 net/nimble/controller/src/ble_ll_conn_hci.c     | 32 ++++++++++----------
 net/nimble/controller/src/ble_ll_hci.c          |  2 ++
 net/nimble/host/include/host/ble_hs.h           | 18 ++---------
 net/nimble/host/src/ble_hs_cfg.c                |  2 +-
 net/nimble/transport/ram/src/ble_hci_ram.c      |  8 +++--
 6 files changed, 29 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/net/nimble/controller/include/controller/ble_ll_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_hci.h b/net/nimble/controller/include/controller/ble_ll_hci.h
index 47daa76..43b98fc 100644
--- a/net/nimble/controller/include/controller/ble_ll_hci.h
+++ b/net/nimble/controller/include/controller/ble_ll_hci.h
@@ -24,6 +24,9 @@
 #define BLE_LL_SUPP_CMD_LEN (36)
 extern const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN];
 
+/* The largest event the controller will send. */
+#define BLE_LL_MAX_EVT_LEN  (45)
+
 /*
  * This determines the number of outstanding commands allowed from the
  * host to the controller.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index f653ca6..d7001f8 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -203,22 +203,25 @@ ble_ll_conn_comp_event_send(struct ble_ll_conn_sm *connsm, uint8_t status)
     }
 }
 
+
 /**
  * Called to create and send the number of completed packets event to the
  * host.
  *
- * Because of the ridiculous spec, all the connection handles are contiguous and
- * then all the completed packets are contiguous. In order to avoid multiple
- * passes through the connection list or allocating a large stack variable or
- * malloc, I just use the event buffer and place the completed packets after
- * the last possible handle. I then copy the completed packets to make it
- * contiguous with the handles.
- *
- * @param connsm
+ * Because of the ridiculous spec, all the connection handles are contiguous
+ * and then all the completed packets are contiguous. In order to avoid
+ * multiple passes through the connection list or allocating a large stack
+ * variable or malloc, I just use the event buffer and place the completed
+ * packets after the last possible handle. I then copy the completed packets
+ * to make it contiguous with the handles.
  */
 void
 ble_ll_conn_num_comp_pkts_event_send(void)
 {
+    /** The maximum number of handles that will fit in an event buffer. */
+    static const int max_handles =
+        (BLE_LL_MAX_EVT_LEN - BLE_HCI_EVENT_HDR_LEN - 1) / 4;
+
     int event_sent;
     uint8_t *evbuf;
     uint8_t *handle_ptr;
@@ -253,7 +256,7 @@ ble_ll_conn_num_comp_pkts_event_send(void)
                 }
                 handles = 0;
                 handle_ptr = evbuf + 3;
-                comp_pkt_ptr = handle_ptr + (sizeof(uint16_t) * 60);
+                comp_pkt_ptr = handle_ptr + (sizeof(uint16_t) * max_handles);
             }
 
             /* Add handle and complete packets */
@@ -264,11 +267,8 @@ ble_ll_conn_num_comp_pkts_event_send(void)
             comp_pkt_ptr += sizeof(uint16_t);
             ++handles;
 
-            /*
-             * The event buffer should fit at least 255 bytes so this means we
-             * can fit up to 60 handles per event (a little more but who cares).
-             */
-            if (handles == 60) {
+            /* Send now if the buffer is full. */
+            if (handles == max_handles) {
                 evbuf[0] = BLE_HCI_EVCODE_NUM_COMP_PKTS;
                 evbuf[1] = (handles * 2 * sizeof(uint16_t)) + 1;
                 evbuf[2] = handles;
@@ -285,9 +285,9 @@ ble_ll_conn_num_comp_pkts_event_send(void)
         evbuf[0] = BLE_HCI_EVCODE_NUM_COMP_PKTS;
         evbuf[1] = (handles * 2 * sizeof(uint16_t)) + 1;
         evbuf[2] = handles;
-        if (handles < 60) {
+        if (handles < max_handles) {
             /* Make the pkt counts contiguous with handles */
-            memmove(handle_ptr, evbuf + 3 + (60 * 2), handles * 2);
+            memmove(handle_ptr, evbuf + 3 + (max_handles * 2), handles * 2);
         }
         ble_ll_hci_event_send(evbuf);
         event_sent = 1;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index 352dda2..758568b 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -64,6 +64,8 @@ ble_ll_hci_event_send(uint8_t *evbuf)
 {
     int rc;
 
+    assert(BLE_HCI_EVENT_HDR_LEN + evbuf[1] <= BLE_LL_MAX_EVT_LEN);
+
     /* Count number of events sent */
     STATS_INC(ble_ll_stats, hci_events_sent);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/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 954d278..8d85009 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -95,26 +95,12 @@ typedef void ble_hs_sync_fn(void);
 
 struct ble_hs_cfg {
     /**
-     * An HCI buffer is a "flat" 260-byte buffer.  HCI buffers are used by the
-     * controller to send unsolicited events to the host.
-     *
-     * HCI buffers can get tied up when the controller sends lots of
-     * asynchronous / unsolicited events (i.e., non-acks).  When the controller
-     * needs to send one of these events, it allocates an HCI buffer, fills it
-     * with the event payload, and puts it on a host queue.  If the controller
-     * sends a quick burst of these events, the buffer pool may be exhausted,
-     * preventing the host from sending an HCI command to the controller.
-     *
      * Every time the controller sends a non-ack HCI event to the host, it also
      * allocates an OS event (it is unfortunate that these are both called
      * "events").  The OS event is put on the host-parent-task's event queue;
      * it is what wakes up the host-parent-task and indicates that an HCI event
-     * needs to be processsed.  The pool of OS events is allocated with the
-     * same number of elements as the HCI buffer pool.
-     */
-    /* XXX: This should either be renamed to indicate it is only used for OS
-     * events, or it should go away entirely (copy the number from the
-     * transport's config).
+     * needs to be processsed.  This setting should be equal to the total
+     * number of HCI event buffers that the transport is configured to use.
      */
     uint8_t max_hci_bufs;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/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 fb5fb45..eca8407 100644
--- a/net/nimble/host/src/ble_hs_cfg.c
+++ b/net/nimble/host/src/ble_hs_cfg.c
@@ -27,7 +27,7 @@
 
 const struct ble_hs_cfg ble_hs_cfg_dflt = {
     /** HCI settings. */
-    .max_hci_bufs = 3,
+    .max_hci_bufs = 14,
 
     /** Connection settings. */
     .max_connections = BLE_HS_CFG_MAX_CONNECTIONS,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8b8d8873/net/nimble/transport/ram/src/ble_hci_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/src/ble_hci_ram.c b/net/nimble/transport/ram/src/ble_hci_ram.c
index 2ce5fd6..ef46309 100644
--- a/net/nimble/transport/ram/src/ble_hci_ram.c
+++ b/net/nimble/transport/ram/src/ble_hci_ram.c
@@ -9,9 +9,11 @@
 
 /** Default configuration. */
 const struct ble_hci_ram_cfg ble_hci_ram_cfg_dflt = {
-    .num_evt_hi_bufs = 1,
-    .num_evt_lo_bufs = 2,
-    .evt_buf_sz = BLE_HCI_TRANS_CMD_SZ,
+    .num_evt_hi_bufs = 2,
+    .num_evt_lo_bufs = 12,
+
+    /* The largest event the nimble controller will send is 45 bytes. */
+    .evt_buf_sz = 45,
 };
 
 static ble_hci_trans_rx_cmd_fn *ble_hci_ram_rx_cmd_hs_cb;


[8/8] incubator-mynewt-core git commit: BLE apps - Base ble_hs max_hci setting on HCI cfg.

Posted by cc...@apache.org.
BLE apps - Base ble_hs max_hci setting on HCI cfg.

The host should be configured to allocate the same number of OS events
as there are HCI event buffers.  This commit changes the sample apps to
use the RAM transport's configuration to determine how many OS events to
configure the host with.


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

Branch: refs/heads/develop
Commit: 1e9bbc2860e38c88d63a1504b6724f175ddd6def
Parents: 8b8d887
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:56:52 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 18:00:31 2016 -0700

----------------------------------------------------------------------
 apps/blecent/src/main.c | 6 ++++--
 apps/bleprph/src/main.c | 5 ++++-
 apps/bletiny/src/main.c | 1 +
 apps/bleuart/src/main.c | 6 ++++--
 4 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1e9bbc28/apps/blecent/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index 66a4e3f..2b89a11 100755
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -508,6 +508,7 @@ blecent_task_handler(void *unused)
 int
 main(void)
 {
+    struct ble_hci_ram_cfg hci_cfg;
     struct ble_hs_cfg cfg;
     uint32_t seed;
     int rc;
@@ -567,12 +568,13 @@ main(void)
     assert(rc == 0);
 
     /* Initialize the RAM HCI transport. */
-    rc = ble_hci_ram_init(&ble_hci_ram_cfg_dflt);
+    hci_cfg = ble_hci_ram_cfg_dflt;
+    rc = ble_hci_ram_init(&hci_cfg);
     assert(rc == 0);
 
     /* Configure the host. */
     cfg = ble_hs_cfg_dflt;
-    cfg.max_hci_bufs = 3;
+    cfg.max_hci_bufs = hci_cfg.num_evt_hi_bufs + hci_cfg.num_evt_lo_bufs;
     cfg.max_gattc_procs = 5;
     cfg.sm_bonding = 1;
     cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1e9bbc28/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 9d75a66..961ed4b 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -332,6 +332,7 @@ bleprph_task_handler(void *unused)
 int
 main(void)
 {
+    struct ble_hci_ram_cfg hci_cfg;
     struct ble_hs_cfg cfg;
     uint32_t seed;
     int rc;
@@ -391,11 +392,13 @@ main(void)
     assert(rc == 0);
 
     /* Initialize the RAM HCI transport. */
-    rc = ble_hci_ram_init(&ble_hci_ram_cfg_dflt);
+    hci_cfg = ble_hci_ram_cfg_dflt;
+    rc = ble_hci_ram_init(&hci_cfg);
     assert(rc == 0);
 
     /* Initialize the NimBLE host configuration. */
     cfg = ble_hs_cfg_dflt;
+    cfg.max_hci_bufs = hci_cfg.num_evt_hi_bufs + hci_cfg.num_evt_lo_bufs;
     cfg.max_gattc_procs = 2;
     cfg.sm_bonding = 1;
     cfg.sm_our_key_dist = BLE_SM_PAIR_KEY_DIST_ENC;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1e9bbc28/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index dbb340b..f2941e7 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1704,6 +1704,7 @@ main(void)
 
     /* Initialize the NimBLE host configuration. */
     cfg = ble_hs_cfg_dflt;
+    cfg.max_hci_bufs = hci_cfg.num_evt_hi_bufs + hci_cfg.num_evt_lo_bufs;
     cfg.max_gattc_procs = 2;
     cfg.reset_cb = bletiny_on_reset;
     cfg.store_read_cb = ble_store_ram_read;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1e9bbc28/apps/bleuart/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleuart/src/main.c b/apps/bleuart/src/main.c
index a530195..061ab3b 100755
--- a/apps/bleuart/src/main.c
+++ b/apps/bleuart/src/main.c
@@ -253,6 +253,7 @@ bleuart_task_handler(void *unused)
 int
 main(void)
 {
+    struct ble_hci_ram_cfg hci_cfg;
     struct ble_hs_cfg cfg;
     uint32_t seed;
     int rc;
@@ -297,11 +298,13 @@ main(void)
     assert(rc == 0);
 
     /* Initialize the RAM HCI transport. */
-    rc = ble_hci_ram_init(&ble_hci_ram_cfg_dflt);
+    hci_cfg = ble_hci_ram_cfg_dflt;
+    rc = ble_hci_ram_init(&hci_cfg);
     assert(rc == 0);
 
     /* Initialize the BLE host. */
     cfg = ble_hs_cfg_dflt;
+    cfg.max_hci_bufs = hci_cfg.num_evt_hi_bufs + hci_cfg.num_evt_lo_bufs;
     cfg.max_connections = 1;
     cfg.max_gattc_procs = 2;
     cfg.max_l2cap_chans = 3;
@@ -334,7 +337,6 @@ main(void)
     rc = nmgr_ble_gatt_svr_init(&bleuart_evq, &cfg);
     assert(rc == 0);
 
-
     rc = ble_hs_init(&bleuart_evq, &cfg);
     assert(rc == 0);
 


[3/8] incubator-mynewt-core git commit: fixup adv

Posted by cc...@apache.org.
fixup adv


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

Branch: refs/heads/develop
Commit: e02d7abab902a1ad509bef3b45a225df2e45e026
Parents: 0d279b6
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 17:01:02 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 17:01:02 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_hs_adv.h | 3 +++
 net/nimble/host/src/ble_hs_adv.c          | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e02d7aba/net/nimble/host/include/host/ble_hs_adv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_adv.h b/net/nimble/host/include/host/ble_hs_adv.h
index cbbb468..8ae2b00 100644
--- a/net/nimble/host/include/host/ble_hs_adv.h
+++ b/net/nimble/host/include/host/ble_hs_adv.h
@@ -22,6 +22,9 @@
 
 #include <inttypes.h>
 
+/** Max field payload size (account for 2-byte header). */
+#define BLE_HS_ADV_MAX_FIELD_SZ     (BLE_HCI_MAX_ADV_DATA_LEN - 2)
+
 struct ble_hs_adv_fields {
     /*** 0x01 - Flags. */
     uint8_t flags;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e02d7aba/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 305c672..fd7bfaf 100644
--- a/net/nimble/host/src/ble_hs_adv.c
+++ b/net/nimble/host/src/ble_hs_adv.c
@@ -23,9 +23,6 @@
 #include "host/ble_hs_adv.h"
 #include "ble_hs_priv.h"
 
-/** Max field paylaod size (account for 2-byte header). */
-#define BLE_HS_ADV_MAX_FIELD_SZ     (BLE_HCI_MAX_ADV_DATA_LEN - 2)
-
 static uint16_t ble_hs_adv_uuids16[BLE_HS_ADV_MAX_FIELD_SZ / 2];
 static uint32_t ble_hs_adv_uuids32[BLE_HS_ADV_MAX_FIELD_SZ / 4];
 


[2/8] incubator-mynewt-core git commit: BLE Host - Don't reject max-size adv field.

Posted by cc...@apache.org.
BLE Host - Don't reject max-size adv field.

The host would reject an advertising report if it contains a 31-byte
field (maximum size allowed).  It was incorrectly limiting fields to 30
bytes.


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

Branch: refs/heads/develop
Commit: 0d279b6933a15c5c76264a1f4325810470dd0fdb
Parents: defcd41
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 16:57:35 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Aug 9 16:57:35 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs_adv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d279b69/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 da0d5c1..305c672 100644
--- a/net/nimble/host/src/ble_hs_adv.c
+++ b/net/nimble/host/src/ble_hs_adv.c
@@ -23,7 +23,8 @@
 #include "host/ble_hs_adv.h"
 #include "ble_hs_priv.h"
 
-#define BLE_HS_ADV_MAX_FIELD_SZ     (BLE_HCI_MAX_ADV_DATA_LEN - 3)
+/** Max field paylaod size (account for 2-byte header). */
+#define BLE_HS_ADV_MAX_FIELD_SZ     (BLE_HCI_MAX_ADV_DATA_LEN - 2)
 
 static uint16_t ble_hs_adv_uuids16[BLE_HS_ADV_MAX_FIELD_SZ / 2];
 static uint32_t ble_hs_adv_uuids32[BLE_HS_ADV_MAX_FIELD_SZ / 4];