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 2015/12/18 19:37:09 UTC
[6/6] incubator-mynewt-larva git commit: Correct some incorrect
default GAP timings.
Correct some incorrect default GAP timings.
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/9930c2be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/9930c2be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/9930c2be
Branch: refs/heads/master
Commit: 9930c2beca00403648f3b9f7df87f3ef98738922
Parents: 7092b08
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Dec 17 17:04:46 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Dec 18 10:36:52 2015 -0800
----------------------------------------------------------------------
net/nimble/host/src/ble_gap_conn.c | 20 ++++++++++++++++----
net/nimble/host/src/ble_hs_conn.c | 24 +++++++++++++++++++++---
2 files changed, 37 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9930c2be/net/nimble/host/src/ble_gap_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_conn.c b/net/nimble/host/src/ble_gap_conn.c
index f7b76ad..0f76fa5 100644
--- a/net/nimble/host/src/ble_gap_conn.c
+++ b/net/nimble/host/src/ble_gap_conn.c
@@ -51,10 +51,22 @@
/** 60 ms. */
#define BLE_GAP_ADV_FAST_INTERVAL1_MAX (60 * 1000 / BLE_HCI_ADV_ITVL)
-/** 1.28 seconds. */
+/** 30 ms; active scanning. */
+#define BLE_GAP_SCAN_FAST_INTERVAL_MIN (30 * 1000 / BLE_HCI_ADV_ITVL)
+
+/** 60 ms; active scanning. */
+#define BLE_GAP_SCAN_FAST_INTERVAL_MAX (60 * 1000 / BLE_HCI_ADV_ITVL)
+
+/** 30 ms; active scanning. */
+#define BLE_GAP_SCAN_FAST_WINDOW (30 * 1000 / BLE_HCI_SCAN_ITVL)
+
+/* 30.72 seconds; active scanning. */
+#define BLE_GAP_SCAN_FAST_PERIOD (30.72 * 1000)
+
+/** 1.28 seconds; background scanning. */
#define BLE_GAP_SCAN_SLOW_INTERVAL1 (1280 * 1000 / BLE_HCI_SCAN_ITVL)
-/** 11.25 ms. */
+/** 11.25 ms; background scanning. */
#define BLE_GAP_SCAN_SLOW_WINDOW1 (11.25 * 1000 / BLE_HCI_SCAN_ITVL)
/** 10.24 seconds. */
@@ -420,8 +432,8 @@ ble_gap_conn_gen_disc_tx_params(void *arg)
ble_hci_ack_set_callback(ble_gap_conn_gen_disc_ack_params, NULL);
rc = host_hci_cmd_le_set_scan_params(BLE_HCI_SCAN_TYPE_ACTIVE,
- BLE_GAP_SCAN_SLOW_INTERVAL1,
- BLE_GAP_SCAN_SLOW_WINDOW1,
+ BLE_GAP_SCAN_FAST_INTERVAL_MIN,
+ BLE_GAP_SCAN_FAST_WINDOW,
BLE_HCI_ADV_OWN_ADDR_PUBLIC,
BLE_HCI_SCAN_FILT_NO_WL);
if (rc != 0) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9930c2be/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 8bb6e12..ef919b7 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -22,11 +22,14 @@
#include "ble_hs_priv.h"
#include "ble_l2cap.h"
#include "ble_l2cap_sig.h"
-#include "ble_hs_conn.h"
#include "ble_att_priv.h"
+#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;
@@ -137,27 +140,42 @@ ble_hs_conn_chan_find(struct ble_hs_conn *conn, uint16_t cid)
return NULL;
}
+static void
+ble_hs_conn_txable_transition(struct ble_hs_conn *conn)
+{
+ ble_gatt_connection_txable(conn->bhc_handle);
+}
+
void
ble_hs_conn_rx_num_completed_pkts(uint16_t handle, uint16_t num_pkts)
{
struct ble_hs_conn *conn;
+ int could_tx;
+ int can_tx;
conn = ble_hs_conn_find(handle);
if (conn == NULL) {
return;
}
+ could_tx = ble_hs_conn_can_tx(conn);
+
if (num_pkts > conn->bhc_outstanding_pkts) {
num_pkts = conn->bhc_outstanding_pkts;
}
conn->bhc_outstanding_pkts -= num_pkts;
+
+ can_tx = ble_hs_conn_can_tx(conn);
+
+ if (!could_tx && can_tx) {
+ ble_hs_conn_txable_transition(conn);
+ }
}
int
ble_hs_conn_can_tx(struct ble_hs_conn *conn)
{
- /* XXX: Ensure number of outstanding packets isn't too great. */
- return 1;
+ return conn->bhc_outstanding_pkts < BLE_HS_CONN_MAX_OUTSTANDING_PKTS;
}
static void