You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/01/21 20:33:08 UTC
[2/3] incubator-mynewt-larva git commit: Fix GATT MTU exchange
procedure.
Fix GATT MTU exchange procedure.
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/0cba4211
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/0cba4211
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/0cba4211
Branch: refs/heads/master
Commit: 0cba42117963d5f8d5197ca8e54a0610f7e3849c
Parents: 9b395ce
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Jan 21 11:31:46 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Jan 21 11:31:46 2016 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_att.h | 2 ++
net/nimble/host/src/ble_att.c | 24 +++++++++++++++++++++++-
net/nimble/host/src/ble_att_clt.c | 2 ++
net/nimble/host/src/ble_gattc.c | 5 +++++
net/nimble/host/src/ble_hs.c | 4 +++-
5 files changed, 35 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0cba4211/net/nimble/host/include/host/ble_att.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_att.h b/net/nimble/host/include/host/ble_att.h
index 6d7300c..1ddab57 100644
--- a/net/nimble/host/include/host/ble_att.h
+++ b/net/nimble/host/include/host/ble_att.h
@@ -115,6 +115,8 @@ typedef int ble_att_svr_notify_fn(uint16_t conn_handle, uint16_t attr_handle,
int ble_att_svr_write_local(uint16_t attr_handle, void *data,
uint16_t data_len);
+int ble_att_set_preferred_mtu(uint16_t mtu);
+
void ble_att_set_notify_cb(ble_att_svr_notify_fn *cb, void *cb_arg);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0cba4211/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index b167687..d7b79f8 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -21,6 +21,8 @@
#include "ble_att_cmd.h"
#include "ble_att_priv.h"
+static uint16_t ble_att_preferred_mtu;
+
/** Dispatch table for incoming ATT requests. Sorted by op code. */
typedef int ble_att_rx_fn(struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan,
@@ -125,6 +127,20 @@ ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu)
chan->blc_peer_mtu = peer_mtu;
}
+int
+ble_att_set_preferred_mtu(uint16_t mtu)
+{
+ if (mtu < BLE_ATT_MTU_DFLT) {
+ return BLE_HS_EINVAL;
+ }
+
+ ble_att_preferred_mtu = mtu;
+
+ /* XXX: Set my_mtu for established connections that haven't exchanged. */
+
+ return 0;
+}
+
struct ble_l2cap_chan *
ble_att_create_chan(void)
{
@@ -136,7 +152,7 @@ ble_att_create_chan(void)
}
chan->blc_cid = BLE_L2CAP_CID_ATT;
- chan->blc_my_mtu = BLE_ATT_MTU_DFLT;
+ chan->blc_my_mtu = ble_att_preferred_mtu;
chan->blc_default_mtu = BLE_ATT_MTU_DFLT;
chan->blc_rx_fn = ble_att_rx;
@@ -161,3 +177,9 @@ ble_att_get_pkthdr(void)
return om;
}
+
+void
+ble_att_init(void)
+{
+ ble_att_preferred_mtu = BLE_ATT_MTU_DFLT;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0cba4211/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 41c19ec..d977e51 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -156,6 +156,8 @@ ble_att_clt_tx_mtu(struct ble_hs_conn *conn, struct ble_att_mtu_cmd *req)
goto err;
}
+ chan->blc_flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
+
return 0;
err:
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0cba4211/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 0311ec4..e98feda 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -863,6 +863,11 @@ ble_gattc_mtu_kick(struct ble_gattc_proc *proc)
chan = ble_hs_conn_chan_find(conn, BLE_L2CAP_CID_ATT);
assert(chan != NULL);
+ if (chan->blc_flags & BLE_L2CAP_CHAN_F_TXED_MTU) {
+ rc = BLE_HS_EALREADY;
+ goto err;
+ }
+
req.bamc_mtu = chan->blc_my_mtu;
rc = ble_att_clt_tx_mtu(conn, &req);
if (rc != 0) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/0cba4211/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 4a89200..72d390a 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -51,7 +51,7 @@ static os_membuf_t g_hci_cmd_buf[OS_MEMPOOL_SIZE(HCI_CMD_BUFS,
#define HCI_NUM_OS_EVENTS (32)
#define HCI_OS_EVENT_BUF_SIZE (sizeof(struct os_event))
-#define BLE_HS_NUM_MBUFS (8)
+#define BLE_HS_NUM_MBUFS (4)
#define BLE_HS_MBUF_BUF_SIZE (256)
#define BLE_HS_MBUF_MEMBLOCK_SIZE \
(BLE_HS_MBUF_BUF_SIZE + sizeof(struct os_mbuf) + \
@@ -251,6 +251,8 @@ ble_hs_init(uint8_t prio)
return rc;
}
+ ble_att_init();
+
rc = ble_att_svr_init();
if (rc != 0) {
return rc;