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/08 03:56:39 UTC
[1/3] incubator-mynewt-larva git commit: Fix up some missing tx calls
in unit tests.
Repository: incubator-mynewt-larva
Updated Branches:
refs/heads/master d5ba6afe5 -> 7587a3735
Fix up some missing tx calls in unit tests.
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/c5cb14a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/c5cb14a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/c5cb14a9
Branch: refs/heads/master
Commit: c5cb14a9e716292f3cfb05fedd1e70a0772f3c5f
Parents: d5ba6af
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Jan 7 17:59:01 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Jan 7 17:59:01 2016 -0800
----------------------------------------------------------------------
net/nimble/host/src/test/ble_att_clt_test.c | 4 ++--
net/nimble/host/src/test/ble_att_svr_test.c | 22 ++++++++++----------
net/nimble/host/src/test/ble_gatt_conn_test.c | 11 ++++------
net/nimble/host/src/test/ble_gatt_disc_c_test.c | 5 ++---
net/nimble/host/src/test/ble_gatt_disc_s_test.c | 8 +++----
net/nimble/host/src/test/ble_gatt_find_s_test.c | 6 ++----
net/nimble/host/src/test/ble_gatt_read_test.c | 4 ++--
net/nimble/host/src/test/ble_gatt_write_test.c | 6 ++----
.../host/src/test/ble_gatts_notify_test.c | 6 ++----
9 files changed, 31 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_att_clt_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_clt_test.c b/net/nimble/host/src/test/ble_att_clt_test.c
index 8501020..3e820a1 100644
--- a/net/nimble/host/src/test/ble_att_clt_test.c
+++ b/net/nimble/host/src/test/ble_att_clt_test.c
@@ -193,7 +193,7 @@ ble_att_clt_test_case_tx_write_req_or_cmd(int is_req)
req.bawq_handle = 0x1234;
ble_att_clt_test_tx_write_req_or_cmd(conn, &req, value5, sizeof value5,
is_req);
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
ble_att_clt_test_misc_verify_tx_write(0x1234, value5, sizeof value5,
is_req);
@@ -201,7 +201,7 @@ ble_att_clt_test_case_tx_write_req_or_cmd(int is_req)
req.bawq_handle = 0xab83;
ble_att_clt_test_tx_write_req_or_cmd(conn, &req, value300, sizeof value300,
is_req);
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
ble_att_clt_test_misc_verify_tx_write(0xab83, value300,
BLE_ATT_MTU_DFLT - 3, is_req);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_att_svr_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_att_svr_test.c b/net/nimble/host/src/test/ble_att_svr_test.c
index 253622a..6043b47 100644
--- a/net/nimble/host/src/test/ble_att_svr_test.c
+++ b/net/nimble/host/src/test/ble_att_svr_test.c
@@ -283,7 +283,7 @@ ble_att_svr_test_misc_verify_tx_err_rsp(struct ble_l2cap_chan *chan,
uint8_t buf[BLE_ATT_ERROR_RSP_SZ];
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, sizeof buf, buf);
TEST_ASSERT(rc == 0);
@@ -307,7 +307,7 @@ ble_att_svr_test_misc_verify_tx_read_rsp(struct ble_l2cap_chan *chan,
int rc;
int i;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, 1, &u8);
TEST_ASSERT(rc == 0);
@@ -332,7 +332,7 @@ ble_att_svr_test_misc_verify_tx_write_rsp(struct ble_l2cap_chan *chan)
uint8_t u8;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, 1, &u8);
TEST_ASSERT(rc == 0);
@@ -350,7 +350,7 @@ ble_att_svr_test_misc_verify_tx_mtu_rsp(struct ble_l2cap_chan *chan)
uint8_t buf[BLE_ATT_MTU_CMD_SZ];
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, sizeof buf, buf);
TEST_ASSERT(rc == 0);
@@ -385,7 +385,7 @@ ble_att_svr_test_misc_verify_tx_find_info_rsp(
int off;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
off = 0;
@@ -447,7 +447,7 @@ ble_att_svr_test_misc_verify_tx_find_type_value_rsp(
int off;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
off = 0;
@@ -499,7 +499,7 @@ ble_att_svr_test_misc_verify_tx_read_group_type_rsp(
int off;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
om = os_mbuf_pullup(ble_hs_test_util_prev_tx,
BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
@@ -568,7 +568,7 @@ ble_att_svr_test_misc_verify_tx_read_type_rsp(
int off;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
om = os_mbuf_pullup(ble_hs_test_util_prev_tx,
BLE_ATT_READ_TYPE_RSP_BASE_SZ);
@@ -608,7 +608,7 @@ ble_att_svr_test_misc_verify_tx_prep_write_rsp(struct ble_l2cap_chan *chan,
uint8_t buf[1024];
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0,
OS_MBUF_PKTLEN(ble_hs_test_util_prev_tx), buf);
@@ -632,7 +632,7 @@ ble_att_svr_test_misc_verify_tx_exec_write_rsp(struct ble_l2cap_chan *chan)
struct os_mbuf *om;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
om = os_mbuf_pullup(ble_hs_test_util_prev_tx, BLE_ATT_EXEC_WRITE_RSP_SZ);
TEST_ASSERT_FATAL(om != NULL);
@@ -807,7 +807,7 @@ ble_att_svr_test_misc_verify_tx_indicate_rsp(struct ble_l2cap_chan *chan)
struct os_mbuf *om;
int rc;
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
om = os_mbuf_pullup(ble_hs_test_util_prev_tx, BLE_ATT_INDICATE_RSP_SZ);
TEST_ASSERT_FATAL(om != NULL);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatt_conn_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_conn_test.c b/net/nimble/host/src/test/ble_gatt_conn_test.c
index b4929a6..950260e 100644
--- a/net/nimble/host/src/test/ble_gatt_conn_test.c
+++ b/net/nimble/host/src/test/ble_gatt_conn_test.c
@@ -146,7 +146,7 @@ TEST_CASE(ble_gatt_conn_test_disconnect)
TEST_ASSERT_FATAL(rc == 0);
/* Start the procedures. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
/* Break the connections; verify callbacks got called. */
ble_gattc_connection_broken(BLE_GATT_BREAK_TEST_DISC_SERVICE_HANDLE);
@@ -181,15 +181,13 @@ TEST_CASE(ble_gatt_conn_test_congestion)
rc = ble_gattc_write(1, 0x1234, ble_gatt_conn_test_write_value,
sizeof ble_gatt_conn_test_write_value, NULL, NULL);
TEST_ASSERT_FATAL(rc == 0);
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
/* Ensure only one packet got sent. */
TEST_ASSERT(conn->bhc_outstanding_pkts == 1);
/* Additional wakeups should not trigger the second send. */
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
TEST_ASSERT(conn->bhc_outstanding_pkts == 1);
/* Receive a num-packets-completed event. */
@@ -202,8 +200,7 @@ TEST_CASE(ble_gatt_conn_test_congestion)
TEST_ASSERT(conn->bhc_outstanding_pkts == 0);
/* Now the second write should get sent. */
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
TEST_ASSERT(conn->bhc_outstanding_pkts == 1);
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatt_disc_c_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_disc_c_test.c b/net/nimble/host/src/test/ble_gatt_disc_c_test.c
index dd7b139..395b0c2 100644
--- a/net/nimble/host/src/test/ble_gatt_disc_c_test.c
+++ b/net/nimble/host/src/test/ble_gatt_disc_c_test.c
@@ -63,8 +63,7 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(
int i;
/* Send the pending ATT Read By Type Request. */
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
if (chars[0].uuid16 != 0) {
rsp.batp_length = BLE_ATT_READ_TYPE_ADATA_BASE_SZ +
@@ -135,7 +134,7 @@ ble_gatt_disc_c_test_misc_rx_rsp(struct ble_hs_conn *conn,
if (chars[idx - 1].decl_handle != end_handle) {
/* Send the pending ATT Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
ble_hs_test_util_rx_att_err_rsp(conn, BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
chars[idx - 1].decl_handle);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatt_disc_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_disc_s_test.c b/net/nimble/host/src/test/ble_gatt_disc_s_test.c
index 1cb73b2..e3e6c36 100644
--- a/net/nimble/host/src/test/ble_gatt_disc_s_test.c
+++ b/net/nimble/host/src/test/ble_gatt_disc_s_test.c
@@ -68,7 +68,7 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(
int i;
/* Send the pending ATT Read By Group Type Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
rsp.bagp_length = ble_gatt_disc_s_test_misc_svc_length(services);
rc = ble_att_read_group_type_rsp_write(
@@ -128,7 +128,7 @@ ble_gatt_disc_s_test_misc_rx_all_rsp(
if (services[idx - 1].end_handle != 0xffff) {
/* Send the pending ATT Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
ble_hs_test_util_rx_att_err_rsp(conn, BLE_ATT_OP_READ_GROUP_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
services[idx - 1].start_handle);
@@ -146,7 +146,7 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
int i;
/* Send the pending ATT Find By Type Value Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
buf[0] = BLE_ATT_OP_FIND_TYPE_VALUE_RSP;
off = BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ;
@@ -188,7 +188,7 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp(
if (services[idx - 1].end_handle != 0xffff) {
/* Send the pending ATT Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
ble_hs_test_util_rx_att_err_rsp(conn, BLE_ATT_OP_FIND_TYPE_VALUE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
services[idx - 1].start_handle);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatt_find_s_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_find_s_test.c b/net/nimble/host/src/test/ble_gatt_find_s_test.c
index 63bb150..147ce3c 100644
--- a/net/nimble/host/src/test/ble_gatt_find_s_test.c
+++ b/net/nimble/host/src/test/ble_gatt_find_s_test.c
@@ -153,8 +153,7 @@ ble_gatt_find_s_test_misc_verify_tx_read_type(uint16_t start_handle,
uint16_t uuid16;
int rc;
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
TEST_ASSERT_FATAL(ble_hs_test_util_prev_tx != NULL);
@@ -179,8 +178,7 @@ ble_gatt_find_s_test_misc_verify_tx_read(uint16_t handle)
struct os_mbuf *om;
int rc;
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
TEST_ASSERT_FATAL(ble_hs_test_util_prev_tx != NULL);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/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 f2686a5..9ad5cac 100644
--- a/net/nimble/host/src/test/ble_gatt_read_test.c
+++ b/net/nimble/host/src/test/ble_gatt_read_test.c
@@ -60,7 +60,7 @@ ble_gatt_read_test_misc_rx_rsp_good(struct ble_hs_conn *conn,
TEST_ASSERT_FATAL(attr->value_len <= sizeof buf);
/* Send the pending ATT Read Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
buf[0] = BLE_ATT_OP_READ_RSP;
memcpy(buf + 1, attr->value, attr->value_len);
@@ -79,7 +79,7 @@ ble_gatt_read_test_misc_rx_rsp_bad(struct ble_hs_conn *conn,
uint8_t att_error)
{
/* Send the pending ATT Read Request. */
- ble_gattc_wakeup();
+ ble_hs_test_util_tx_all();
ble_hs_test_util_rx_att_err_rsp(conn, BLE_ATT_OP_READ_REQ, att_error,
attr->handle);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatt_write_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatt_write_test.c b/net/nimble/host/src/test/ble_gatt_write_test.c
index 17d4132..9ce137d 100644
--- a/net/nimble/host/src/test/ble_gatt_write_test.c
+++ b/net/nimble/host/src/test/ble_gatt_write_test.c
@@ -83,8 +83,7 @@ TEST_CASE(ble_gatt_write_test_no_rsp)
TEST_ASSERT(rc == 0);
/* Send the pending ATT Write Command. */
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
/* No response expected; verify callback got called. */
TEST_ASSERT(ble_gatt_write_test_cb_called);
@@ -105,8 +104,7 @@ TEST_CASE(ble_gatt_write_test_rsp)
TEST_ASSERT(rc == 0);
/* Send the pending ATT Write Command. */
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
/* Response not received yet; verify callback not called. */
TEST_ASSERT(!ble_gatt_write_test_cb_called);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/c5cb14a9/net/nimble/host/src/test/ble_gatts_notify_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_gatts_notify_test.c b/net/nimble/host/src/test/ble_gatts_notify_test.c
index 700fcbc..6efe467 100644
--- a/net/nimble/host/src/test/ble_gatts_notify_test.c
+++ b/net/nimble/host/src/test/ble_gatts_notify_test.c
@@ -184,8 +184,7 @@ ble_gatts_notify_test_misc_verify_tx_n(struct ble_l2cap_chan *chan,
int rc;
int i;
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
req_len = OS_MBUF_PKTLEN(ble_hs_test_util_prev_tx);
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, req_len, buf);
@@ -209,8 +208,7 @@ ble_gatts_notify_test_misc_verify_tx_i(struct ble_l2cap_chan *chan,
int rc;
int i;
- ble_gattc_wakeup();
- ble_hs_process_tx_data_queue();
+ ble_hs_test_util_tx_all();
req_len = OS_MBUF_PKTLEN(ble_hs_test_util_prev_tx);
rc = os_mbuf_copydata(ble_hs_test_util_prev_tx, 0, req_len, buf);
[2/3] incubator-mynewt-larva git commit: Reorganize a bunch of ATT
code.
Posted by cc...@apache.org.
Reorganize a bunch of ATT code.
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/d05dcac3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/d05dcac3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/d05dcac3
Branch: refs/heads/master
Commit: d05dcac3ecc7b09f8793dd6390861ae350f46507
Parents: c5cb14a
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Jan 7 18:23:27 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Jan 7 18:56:04 2016 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gatt.h | 1 -
net/nimble/host/src/ble_att_clt.c | 337 +++++++++++++++------------
net/nimble/host/src/ble_att_priv.h | 41 +++-
net/nimble/host/src/ble_gatt_priv.h | 18 +-
net/nimble/host/src/ble_gattc.c | 41 ++--
5 files changed, 251 insertions(+), 187 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d05dcac3/net/nimble/host/include/host/ble_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gatt.h b/net/nimble/host/include/host/ble_gatt.h
index 1cc4085..dd8088f 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -21,7 +21,6 @@
#include "host/ble_att.h"
struct ble_hs_conn;
struct ble_att_error_rsp;
-struct ble_att_clt_adata;
/*** @client. */
struct ble_gatt_service {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d05dcac3/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 5951fd6..aa7aa7d 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -67,6 +67,37 @@ err:
return rc;
}
+static int
+ble_att_clt_append_blob(struct ble_l2cap_chan *chan, struct os_mbuf *txom,
+ void *blob, int blob_len)
+{
+ uint16_t mtu;
+ int extra_len;
+ int cmd_len;
+ int rc;
+
+ mtu = ble_l2cap_chan_mtu(chan);
+ cmd_len = OS_MBUF_PKTLEN(txom) + blob_len;
+ extra_len = cmd_len - mtu;
+ if (extra_len > 0) {
+ blob_len -= extra_len;
+ }
+ if (blob_len <= 0) {
+ return BLE_HS_EMSGSIZE;
+ }
+
+ rc = os_mbuf_append(txom, blob, blob_len);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+ * $error response *
+ *****************************************************************************/
+
int
ble_att_clt_rx_error(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf **om)
@@ -89,6 +120,10 @@ ble_att_clt_rx_error(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
return 0;
}
+/*****************************************************************************
+ * $mtu exchange *
+ *****************************************************************************/
+
int
ble_att_clt_tx_mtu(struct ble_hs_conn *conn, struct ble_att_mtu_cmd *req)
{
@@ -146,6 +181,10 @@ ble_att_clt_rx_mtu(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
return 0;
}
+/*****************************************************************************
+ * $find information *
+ *****************************************************************************/
+
int
ble_att_clt_tx_find_info(struct ble_hs_conn *conn,
struct ble_att_find_info_req *req)
@@ -189,11 +228,9 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf **om)
{
struct ble_att_find_info_rsp rsp;
+ struct ble_att_find_info_idata idata;
struct os_mbuf *rxom;
- uint16_t handle_id;
uint16_t uuid16;
- uint8_t uuid128[16];
- int off;
int rc;
*om = os_mbuf_pullup(*om, BLE_ATT_FIND_INFO_RSP_BASE_SZ);
@@ -206,29 +243,30 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
rc = ble_att_find_info_rsp_parse(rxom->om_data, rxom->om_len, &rsp);
assert(rc == 0);
+ os_mbuf_adj(rxom, BLE_ATT_FIND_INFO_RSP_BASE_SZ);
- handle_id = 0;
- off = BLE_ATT_FIND_INFO_RSP_BASE_SZ;
- while (off < OS_MBUF_PKTLEN(rxom)) {
- rc = os_mbuf_copydata(rxom, off, 2, &handle_id);
- if (rc != 0) {
+ idata.attr_handle = 0;
+ while (OS_MBUF_PKTLEN(rxom) > 0) {
+ rxom = os_mbuf_pullup(rxom, 2);
+ if (rxom == NULL) {
rc = BLE_HS_EBADDATA;
goto done;
}
- off += 2;
- handle_id = le16toh(&handle_id);
+
+ idata.attr_handle = le16toh(rxom->om_data);
+ os_mbuf_adj(rxom, 2);
switch (rsp.bafp_format) {
case BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT:
- rc = os_mbuf_copydata(rxom, off, 2, &uuid16);
- if (rc != 0) {
+ rxom = os_mbuf_pullup(rxom, 2);
+ if (rxom == NULL) {
rc = BLE_HS_EBADDATA;
goto done;
}
- off += 2;
- uuid16 = le16toh(&uuid16);
+ uuid16 = le16toh(rxom->om_data);
+ os_mbuf_adj(rxom, 2);
- rc = ble_uuid_16_to_128(uuid16, uuid128);
+ rc = ble_uuid_16_to_128(uuid16, idata.uuid128);
if (rc != 0) {
rc = BLE_HS_EBADDATA;
goto done;
@@ -236,12 +274,12 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
break;
case BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT:
- rc = os_mbuf_copydata(rxom, off, 16, &uuid128);
+ rc = os_mbuf_copydata(rxom, 0, 16, idata.uuid128);
if (rc != 0) {
rc = BLE_HS_EBADDATA;
goto done;
}
- off += 16;
+ os_mbuf_adj(rxom, 16);
break;
default:
@@ -249,16 +287,119 @@ ble_att_clt_rx_find_info(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
goto done;
}
- ble_gattc_rx_find_info_entry(conn, 0, handle_id, uuid128);
+ ble_gattc_rx_find_info_entry(conn, &idata);
}
rc = 0;
done:
+ *om = rxom;
+
ble_gattc_rx_find_info_complete(conn, rc);
return rc;
}
+/*****************************************************************************
+ * $find by type value *
+ *****************************************************************************/
+
+int
+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)
+{
+ struct ble_l2cap_chan *chan;
+ struct os_mbuf *txom;
+ int rc;
+
+ txom = NULL;
+
+ if (req->bavq_start_handle == 0 ||
+ req->bavq_start_handle > req->bavq_end_handle) {
+
+ rc = BLE_HS_EINVAL;
+ goto err;
+ }
+
+ rc = ble_att_clt_prep_req(conn, &chan, &txom,
+ BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ);
+ if (rc != 0) {
+ goto err;
+ }
+
+ rc = ble_att_find_type_value_req_write(txom->om_data, txom->om_len, req);
+ assert(rc == 0);
+
+ rc = os_mbuf_append(txom, attribute_value, value_len);
+ if (rc != 0) {
+ rc = BLE_HS_EMSGSIZE;
+ goto err;
+ }
+
+ rc = ble_l2cap_tx(conn, chan, txom);
+ txom = NULL;
+ if (rc != 0) {
+ goto err;
+ }
+
+ return 0;
+
+err:
+ os_mbuf_free_chain(txom);
+ return rc;
+}
+
+static int
+ble_att_clt_parse_find_type_value_hinfo(
+ struct os_mbuf **om, struct ble_att_find_type_value_hinfo *hinfo)
+{
+ *om = os_mbuf_pullup(*om, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
+ if (*om == NULL) {
+ return BLE_HS_ENOMEM;
+ }
+
+ hinfo->attr_handle = le16toh((*om)->om_data + 0);
+ hinfo->group_end_handle = le16toh((*om)->om_data + 2);
+
+ return 0;
+}
+
+int
+ble_att_clt_rx_find_type_value(struct ble_hs_conn *conn,
+ struct ble_l2cap_chan *chan,
+ struct os_mbuf **rxom)
+{
+ struct ble_att_find_type_value_hinfo hinfo;
+ int rc;
+
+ /* Reponse consists of a one-byte opcode (already verified) and a variable
+ * length Handles Information List field. Strip the opcode from the
+ * response.
+ */
+ os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ);
+
+ /* Parse the Handles Information List field, passing each entry to GATT. */
+ rc = 0;
+ while (OS_MBUF_PKTLEN(*rxom) > 0) {
+ rc = ble_att_clt_parse_find_type_value_hinfo(rxom, &hinfo);
+ if (rc != 0) {
+ break;
+ }
+
+ ble_gattc_rx_find_type_value_hinfo(conn, &hinfo);
+ os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
+ }
+
+ /* Notify GATT client that the full response has been parsed. */
+ ble_gattc_rx_find_type_value_complete(conn, rc);
+
+ return 0;
+}
+
+/*****************************************************************************
+ * $read by type *
+ *****************************************************************************/
+
int
ble_att_clt_tx_read_type(struct ble_hs_conn *conn,
struct ble_att_read_type_req *req,
@@ -305,8 +446,8 @@ err:
}
static int
-ble_att_clt_parse_type_attribute_data(struct os_mbuf **om, int data_len,
- struct ble_att_clt_adata *adata)
+ble_att_clt_parse_read_type_adata(struct os_mbuf **om, int data_len,
+ struct ble_att_read_type_adata *adata)
{
if (data_len <= BLE_ATT_READ_TYPE_ADATA_BASE_SZ) {
return BLE_HS_EMSGSIZE;
@@ -318,7 +459,6 @@ ble_att_clt_parse_type_attribute_data(struct os_mbuf **om, int data_len,
}
adata->att_handle = le16toh((*om)->om_data + 0);
- adata->end_group_handle = 0;
adata->value_len = data_len - BLE_ATT_READ_TYPE_ADATA_BASE_SZ;
adata->value = (*om)->om_data + BLE_ATT_READ_TYPE_ADATA_BASE_SZ;
@@ -329,8 +469,8 @@ int
ble_att_clt_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf **rxom)
{
+ struct ble_att_read_type_adata adata;
struct ble_att_read_type_rsp rsp;
- struct ble_att_clt_adata adata;
int rc;
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_TYPE_RSP_BASE_SZ);
@@ -347,7 +487,7 @@ ble_att_clt_rx_read_type(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
/* Parse the Attribute Data List field, passing each entry to the GATT. */
while (OS_MBUF_PKTLEN(*rxom) > 0) {
- rc = ble_att_clt_parse_type_attribute_data(rxom, rsp.batp_length,
+ rc = ble_att_clt_parse_read_type_adata(rxom, rsp.batp_length,
&adata);
if (rc != 0) {
goto done;
@@ -365,6 +505,10 @@ done:
}
+/*****************************************************************************
+ * $read *
+ *****************************************************************************/
+
int
ble_att_clt_tx_read(struct ble_hs_conn *conn, struct ble_att_read_req *req)
{
@@ -433,6 +577,10 @@ done:
return rc;
}
+/*****************************************************************************
+ * $read by group type *
+ *****************************************************************************/
+
int
ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
struct ble_att_read_group_type_req *req,
@@ -479,8 +627,9 @@ err:
}
static int
-ble_att_clt_parse_group_attribute_data(struct os_mbuf **om, int data_len,
- struct ble_att_clt_adata *adata)
+ble_att_clt_parse_read_group_type_adata(
+ struct os_mbuf **om, int data_len,
+ struct ble_att_read_group_type_adata *adata)
{
if (data_len < BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ + 1) {
return BLE_HS_EMSGSIZE;
@@ -505,7 +654,7 @@ ble_att_clt_rx_read_group_type(struct ble_hs_conn *conn,
struct os_mbuf **rxom)
{
struct ble_att_read_group_type_rsp rsp;
- struct ble_att_clt_adata adata;
+ struct ble_att_read_group_type_adata adata;
int rc;
*rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
@@ -523,13 +672,13 @@ ble_att_clt_rx_read_group_type(struct ble_hs_conn *conn,
/* Parse the Attribute Data List field, passing each entry to GATT. */
while (OS_MBUF_PKTLEN(*rxom) > 0) {
- rc = ble_att_clt_parse_group_attribute_data(rxom, rsp.bagp_length,
+ rc = ble_att_clt_parse_read_group_type_adata(rxom, rsp.bagp_length,
&adata);
if (rc != 0) {
goto done;
}
- ble_gattc_rx_read_group_type_adata(conn, &adata);
+ ble_gattc_rx_read_group_type_entry(conn, &adata);
os_mbuf_adj(*rxom, rsp.bagp_length);
}
@@ -540,127 +689,9 @@ done:
return 0;
}
-int
-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)
-{
- struct ble_l2cap_chan *chan;
- struct os_mbuf *txom;
- int rc;
-
- txom = NULL;
-
- if (req->bavq_start_handle == 0 ||
- req->bavq_start_handle > req->bavq_end_handle) {
-
- rc = BLE_HS_EINVAL;
- goto err;
- }
-
- rc = ble_att_clt_prep_req(conn, &chan, &txom,
- BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ);
- if (rc != 0) {
- goto err;
- }
-
- rc = ble_att_find_type_value_req_write(txom->om_data, txom->om_len, req);
- assert(rc == 0);
-
- rc = os_mbuf_append(txom, attribute_value, value_len);
- if (rc != 0) {
- rc = BLE_HS_EMSGSIZE;
- goto err;
- }
-
- rc = ble_l2cap_tx(conn, chan, txom);
- txom = NULL;
- if (rc != 0) {
- goto err;
- }
-
- return 0;
-
-err:
- os_mbuf_free_chain(txom);
- return rc;
-}
-
-static int
-ble_att_clt_parse_handles_info(struct os_mbuf **om,
- struct ble_att_clt_adata *adata)
-{
- *om = os_mbuf_pullup(*om, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
- if (*om == NULL) {
- return BLE_HS_ENOMEM;
- }
-
- adata->att_handle = le16toh((*om)->om_data + 0);
- adata->end_group_handle = le16toh((*om)->om_data + 2);
- adata->value_len = 0;
- adata->value = NULL;
-
- return 0;
-}
-
-int
-ble_att_clt_rx_find_type_value(struct ble_hs_conn *conn,
- struct ble_l2cap_chan *chan,
- struct os_mbuf **rxom)
-{
- struct ble_att_clt_adata adata;
- int rc;
-
- /* Reponse consists of a one-byte opcode (already verified) and a variable
- * length Handles Information List field. Strip the opcode from the
- * response.
- */
- os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ);
-
- /* Parse the Handles Information List field, passing each entry to GATT. */
- rc = 0;
- while (OS_MBUF_PKTLEN(*rxom) > 0) {
- rc = ble_att_clt_parse_handles_info(rxom, &adata);
- if (rc != 0) {
- break;
- }
-
- ble_gattc_rx_find_type_value_hinfo(conn, &adata);
- os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
- }
-
- /* Notify GATT client that the full response has been parsed. */
- ble_gattc_rx_find_type_value_complete(conn, rc);
-
- return 0;
-}
-
-static int
-ble_att_clt_append_blob(struct ble_l2cap_chan *chan, struct os_mbuf *txom,
- void *blob, int blob_len)
-{
- uint16_t mtu;
- int extra_len;
- int cmd_len;
- int rc;
-
- mtu = ble_l2cap_chan_mtu(chan);
- cmd_len = OS_MBUF_PKTLEN(txom) + blob_len;
- extra_len = cmd_len - mtu;
- if (extra_len > 0) {
- blob_len -= extra_len;
- }
- if (blob_len <= 0) {
- return BLE_HS_EMSGSIZE;
- }
-
- rc = os_mbuf_append(txom, blob, blob_len);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
-}
+/*****************************************************************************
+ * $write *
+ *****************************************************************************/
static int
ble_att_clt_tx_write_req_or_cmd(struct ble_hs_conn *conn,
@@ -745,6 +776,10 @@ ble_att_clt_rx_write(struct ble_hs_conn *conn,
return 0;
}
+/*****************************************************************************
+ * $handle value notification *
+ *****************************************************************************/
+
int
ble_att_clt_tx_notify(struct ble_hs_conn *conn, struct ble_att_notify_req *req,
void *value, uint16_t value_len)
@@ -786,6 +821,10 @@ err:
return rc;
}
+/*****************************************************************************
+ * $handle value indication *
+ *****************************************************************************/
+
int
ble_att_clt_tx_indicate(struct ble_hs_conn *conn,
struct ble_att_indicate_req *req,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d05dcac3/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 3b8d2ff..f921288 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -80,21 +80,17 @@ typedef int (*ble_att_svr_walk_func_t)(struct ble_att_svr_entry *entry,
#define HA_OPCODE_COMMAND_FLAG (1 << 6)
#define HA_OPCODE_AUTH_SIG_FLAG (1 << 7)
-struct ble_att_clt_adata {
- uint16_t att_handle;
- uint16_t end_group_handle;
- int value_len;
- uint8_t *value;
-};
-
SLIST_HEAD(ble_att_clt_entry_list, ble_att_clt_entry);
/*** @gen */
+
struct ble_l2cap_chan *ble_att_create_chan(void);
void ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu);
struct os_mbuf *ble_att_get_pkthdr(void);
+
/*** @svr */
+
extern ble_att_svr_notify_fn *ble_att_svr_notify_cb;
extern void *ble_att_svr_notify_cb_arg;
@@ -136,7 +132,36 @@ int ble_att_svr_read_handle(struct ble_hs_conn *conn, uint16_t attr_handle,
uint8_t *out_att_err);
int ble_att_svr_init(void);
-/*** @clt */
+
+/*** $clt */
+
+/** An information-data entry in a find information response. */
+struct ble_att_find_info_idata {
+ uint16_t attr_handle;
+ uint8_t uuid128[16];
+};
+
+/** A handles-information entry in a find by type value response. */
+struct ble_att_find_type_value_hinfo {
+ uint16_t attr_handle;
+ uint16_t group_end_handle;
+};
+
+/** An attribute-data entry in a read by type response. */
+struct ble_att_read_type_adata {
+ uint16_t att_handle;
+ int value_len;
+ uint8_t *value;
+};
+
+/** An attribute-data entry in a read by group type response. */
+struct ble_att_read_group_type_adata {
+ uint16_t att_handle;
+ uint16_t end_group_handle;
+ int value_len;
+ uint8_t *value;
+};
+
int ble_att_clt_rx_error(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf **rxom);
int ble_att_clt_tx_mtu(struct ble_hs_conn *conn,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d05dcac3/net/nimble/host/src/ble_gatt_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatt_priv.h b/net/nimble/host/src/ble_gatt_priv.h
index 5b6e344..521ab2d 100644
--- a/net/nimble/host/src/ble_gatt_priv.h
+++ b/net/nimble/host/src/ble_gatt_priv.h
@@ -18,6 +18,10 @@
#define H_BLE_GATT_PRIV_
#include "host/ble_gatt.h"
+struct ble_att_read_type_adata;
+struct ble_att_find_type_value_hinfo;
+struct ble_att_find_info_idata;
+struct ble_att_read_group_type_adata;
#define BLE_GATT_CHR_DECL_SZ_16 5
#define BLE_GATT_CHR_DECL_SZ_128 19
@@ -45,20 +49,20 @@ void ble_gattc_rx_err(uint16_t conn_handle, struct ble_att_error_rsp *rsp);
void ble_gattc_wakeup(void);
void ble_gattc_rx_mtu(struct ble_hs_conn *conn, uint16_t chan_mtu);
void ble_gattc_rx_read_type_adata(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
-void ble_gattc_rx_read_type_complete(struct ble_hs_conn *conn, int rc);
+ struct ble_att_read_type_adata *adata);
+void ble_gattc_rx_read_type_complete(struct ble_hs_conn *conn, int status);
void ble_gattc_rx_read_rsp(struct ble_hs_conn *conn, int status, void *value,
int value_len);
-void ble_gattc_rx_read_group_type_adata(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+void ble_gattc_rx_read_group_type_entry(struct ble_hs_conn *conn,
+ struct ble_att_read_group_type_adata *agdata);
void ble_gattc_rx_read_group_type_complete(struct ble_hs_conn *conn, int rc);
void ble_gattc_rx_find_type_value_hinfo(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+ struct ble_att_find_type_value_hinfo *hinfo);
void ble_gattc_rx_find_type_value_complete(struct ble_hs_conn *conn, int rc);
void ble_gattc_rx_write_rsp(struct ble_hs_conn *conn);
void ble_gattc_rx_indicate_rsp(struct ble_hs_conn *conn);
-void ble_gattc_rx_find_info_entry(struct ble_hs_conn *conn, int status,
- uint16_t handle, uint8_t *uuid128);
+void ble_gattc_rx_find_info_entry(struct ble_hs_conn *conn,
+ struct ble_att_find_info_idata *idata);
void ble_gattc_rx_find_info_complete(struct ble_hs_conn *conn, int status);
void ble_gattc_connection_txable(uint16_t conn_handle);
void ble_gattc_connection_broken(uint16_t conn_handle);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/d05dcac3/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 77e9284..f808d5b 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -163,19 +163,19 @@ static void ble_gattc_err_indicate(struct ble_gattc_entry *entry, int status);
static int ble_gattc_find_inc_svcs_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+ struct ble_att_read_type_adata *adata);
static int ble_gattc_find_inc_svcs_rx_complete(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
int status);
static int ble_gattc_disc_all_chrs_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+ struct ble_att_read_type_adata *adata);
static int ble_gattc_disc_all_chrs_rx_complete(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
int status);
static int ble_gattc_disc_chr_uuid_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+ struct ble_att_read_type_adata *adata);
static int ble_gattc_disc_chr_uuid_rx_complete(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
int status);
@@ -242,7 +242,7 @@ static const struct ble_gattc_dispatch_entry
typedef int ble_gattc_rx_adata_fn(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata);
+ struct ble_att_read_type_adata *adata);
struct ble_gattc_rx_adata_entry {
uint8_t op;
ble_gattc_rx_adata_fn *cb;
@@ -678,8 +678,8 @@ ble_gattc_err_disc_all_svcs(struct ble_gattc_entry *entry, int status)
}
void
-ble_gattc_rx_read_group_type_adata(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ble_gattc_rx_read_group_type_entry(struct ble_hs_conn *conn,
+ struct ble_att_read_group_type_adata *adata)
{
struct ble_gatt_service service;
struct ble_gattc_entry *entry;
@@ -836,7 +836,7 @@ ble_gattc_err_disc_svc_uuid(struct ble_gattc_entry *entry, int status)
void
ble_gattc_rx_find_type_value_hinfo(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ struct ble_att_find_type_value_hinfo *hinfo)
{
struct ble_gatt_service service;
struct ble_gattc_entry *entry;
@@ -850,10 +850,10 @@ ble_gattc_rx_find_type_value_hinfo(struct ble_hs_conn *conn,
return;
}
- entry->disc_svc_uuid.prev_handle = adata->end_group_handle;
+ entry->disc_svc_uuid.prev_handle = hinfo->group_end_handle;
- service.start_handle = adata->att_handle;
- service.end_handle = adata->end_group_handle;
+ service.start_handle = hinfo->attr_handle;
+ service.end_handle = hinfo->group_end_handle;
memcpy(service.uuid128, entry->disc_svc_uuid.service_uuid, 16);
rc = ble_gattc_disc_svc_uuid_cb(entry, 0, &service);
@@ -1025,7 +1025,7 @@ done:
static int
ble_gattc_find_inc_svcs_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ struct ble_att_read_type_adata *adata)
{
struct ble_gatt_service service;
uint16_t uuid16;
@@ -1173,7 +1173,7 @@ ble_gattc_err_disc_all_chrs(struct ble_gattc_entry *entry, int status)
static int
ble_gattc_disc_all_chrs_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ struct ble_att_read_type_adata *adata)
{
struct ble_gatt_chr chr;
uint16_t uuid16;
@@ -1324,7 +1324,7 @@ ble_gattc_err_disc_chr_uuid(struct ble_gattc_entry *entry, int status)
static int
ble_gattc_disc_chr_uuid_rx_adata(struct ble_gattc_entry *entry,
struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ struct ble_att_read_type_adata *adata)
{
struct ble_gatt_chr chr;
uint16_t uuid16;
@@ -1474,8 +1474,8 @@ ble_gattc_err_disc_all_dscs(struct ble_gattc_entry *entry, int status)
}
void
-ble_gattc_rx_find_info_entry(struct ble_hs_conn *conn, int status,
- uint16_t handle, uint8_t *uuid128)
+ble_gattc_rx_find_info_entry(struct ble_hs_conn *conn,
+ struct ble_att_find_info_idata *idata)
{
struct ble_gattc_entry *entry;
struct ble_gattc_entry *prev;
@@ -1488,15 +1488,12 @@ ble_gattc_rx_find_info_entry(struct ble_hs_conn *conn, int status,
return;
}
- rc = ble_gattc_disc_all_dscs_cb(entry, status, handle, uuid128);
+ rc = ble_gattc_disc_all_dscs_cb(entry, 0, idata->attr_handle,
+ idata->uuid128);
if (rc != 0) {
ble_gattc_entry_remove_free(entry, prev);
- } else if (status != 0) {
- /* Error. */
- ble_gattc_disc_all_dscs_cb(entry, status, 0, NULL);
- ble_gattc_entry_remove_free(entry, prev);
} else {
- entry->disc_all_dscs.prev_handle = handle;
+ entry->disc_all_dscs.prev_handle = idata->attr_handle;
}
}
@@ -1954,7 +1951,7 @@ ble_gattc_rx_err(uint16_t conn_handle, struct ble_att_error_rsp *rsp)
void
ble_gattc_rx_read_type_adata(struct ble_hs_conn *conn,
- struct ble_att_clt_adata *adata)
+ struct ble_att_read_type_adata *adata)
{
const struct ble_gattc_rx_adata_entry *rx_entry;
struct ble_gattc_entry *entry;
[3/3] incubator-mynewt-larva git commit: Reserve connection handle
0xffff for internal tx.
Posted by cc...@apache.org.
Reserve connection handle 0xffff for internal tx.
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/7587a373
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/7587a373
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/7587a373
Branch: refs/heads/master
Commit: 7587a3735bddd556905629ef720d3627caa5a564
Parents: d05dcac
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Jan 7 18:54:23 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Jan 7 18:56:11 2016 -0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_hs.h | 2 ++
net/nimble/host/src/ble_att_svr.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7587a373/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 8781d19..036913e 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -20,6 +20,8 @@
#include <inttypes.h>
#include "host/ble_att.h"
+#define BLE_HS_CONN_HANDLE_NONE 0xffff
+
#define BLE_HS_EAGAIN 1
#define BLE_HS_EALREADY 2
#define BLE_HS_EINVAL 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/7587a373/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 ef9a338..9e12022 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -331,7 +331,7 @@ ble_att_svr_read(struct ble_hs_conn *conn, struct ble_att_svr_entry *entry,
int rc;
if (conn == NULL) {
- conn_handle = 0xffff; /* XXX */
+ conn_handle = BLE_HS_CONN_HANDLE_NONE;
} else {
conn_handle = conn->bhc_handle;
@@ -403,7 +403,7 @@ ble_att_svr_write(struct ble_hs_conn *conn, struct ble_att_svr_entry *entry,
/* XXX: Check security. */
if (conn == NULL) {
- conn_handle = 0xffff; /* XXX */
+ conn_handle = BLE_HS_CONN_HANDLE_NONE;
} else {
conn_handle = conn->bhc_handle;
}