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/05 03:09:14 UTC
[3/5] incubator-mynewt-larva git commit: Rearrange some att client
functions to match spec.
Rearrange some att client functions to match spec.
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/300c33ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/300c33ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/300c33ce
Branch: refs/heads/master
Commit: 300c33ce6561ed521e2d25db0c5a14b094623a42
Parents: e0e22e1
Author: Christopher Collins <cc...@gmail.com>
Authored: Fri Dec 4 15:31:00 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Fri Dec 4 18:08:24 2015 -0800
----------------------------------------------------------------------
net/nimble/host/src/ble_att.h | 12 +--
net/nimble/host/src/ble_att_clt.c | 144 ++++++++++++++++-----------------
2 files changed, 78 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/300c33ce/net/nimble/host/src/ble_att.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.h b/net/nimble/host/src/ble_att.h
index 93c74c2..b1c2ad6 100644
--- a/net/nimble/host/src/ble_att.h
+++ b/net/nimble/host/src/ble_att.h
@@ -148,6 +148,12 @@ int ble_att_clt_rx_mtu(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf **om);
int ble_att_clt_tx_read(struct ble_hs_conn *conn,
struct ble_att_read_req *req);
+int ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
+ struct ble_att_read_group_type_req *req,
+ void *uuid128);
+int ble_att_clt_rx_read_group_type_rsp(struct ble_hs_conn *conn,
+ struct ble_l2cap_chan *chan,
+ struct os_mbuf **om);
int ble_att_clt_tx_find_info(struct ble_hs_conn *conn,
struct ble_att_find_info_req *req);
int ble_att_clt_rx_find_info(struct ble_hs_conn *conn,
@@ -158,11 +164,5 @@ int ble_att_clt_tx_find_type_value(struct ble_hs_conn *conn,
int ble_att_clt_rx_find_type_value(struct ble_hs_conn *conn,
struct ble_l2cap_chan *chan,
struct os_mbuf **rxom);
-int ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
- struct ble_att_read_group_type_req *req,
- void *uuid128);
-int ble_att_clt_rx_read_group_type_rsp(struct ble_hs_conn *conn,
- struct ble_l2cap_chan *chan,
- struct os_mbuf **om);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/300c33ce/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 94cd0cc..c2eb6bc 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -295,9 +295,9 @@ err:
}
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)
+ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
+ struct ble_att_read_group_type_req *req,
+ void *uuid128)
{
struct ble_l2cap_chan *chan;
struct os_mbuf *txom;
@@ -305,27 +305,27 @@ ble_att_clt_tx_find_type_value(struct ble_hs_conn *conn,
txom = NULL;
- if (req->bavq_start_handle == 0 ||
- req->bavq_start_handle > req->bavq_end_handle) {
+ if (req->bagq_start_handle == 0 ||
+ req->bagq_start_handle > req->bagq_end_handle) {
rc = EINVAL;
goto err;
}
rc = ble_att_clt_prep_req(conn, &chan, &txom,
- BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ);
+ BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ);
if (rc != 0) {
goto err;
}
- rc = ble_att_find_type_value_req_write(txom->om_data, txom->om_len, req);
+ rc = ble_att_read_group_type_req_write(txom->om_data, txom->om_len,
+ req);
if (rc != 0) {
goto err;
}
- rc = os_mbuf_append(txom, attribute_value, value_len);
+ rc = ble_hs_uuid_append(txom, uuid128);
if (rc != 0) {
- rc = EMSGSIZE;
goto err;
}
@@ -343,60 +343,68 @@ err:
}
static int
-ble_att_clt_parse_handles_info(struct os_mbuf **om,
- struct ble_att_clt_adata *adata)
+ble_att_clt_parse_attribute_data(struct os_mbuf **om, int data_len,
+ struct ble_att_clt_adata *adata)
{
- *om = os_mbuf_pullup(*om, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
+ *om = os_mbuf_pullup(*om, data_len);
if (*om == NULL) {
return 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;
+ adata->value_len = data_len - BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
+ adata->value = (*om)->om_data + BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
return 0;
}
int
-ble_att_clt_rx_find_type_value(struct ble_hs_conn *conn,
- struct ble_l2cap_chan *chan,
- struct os_mbuf **rxom)
+ble_att_clt_rx_read_group_type_rsp(struct ble_hs_conn *conn,
+ struct ble_l2cap_chan *chan,
+ struct os_mbuf **rxom)
{
+ struct ble_att_read_group_type_rsp rsp;
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);
+ *rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
+ if (*rxom == NULL) {
+ rc = ENOMEM;
+ goto done;
+ }
- /* Parse the Handles Information List field, passing each entry to the
- * GATT.
- */
- rc = 0;
+ rc = ble_att_read_group_type_rsp_parse((*rxom)->om_data, (*rxom)->om_len,
+ &rsp);
+ if (rc != 0) {
+ goto done;
+ }
+
+ /* Strip the base from the front of the response. */
+ os_mbuf_adj(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
+
+ /* Parse the Attribute Data List field, passing each entry to the GATT. */
while (OS_MBUF_PKTLEN(*rxom) > 0) {
- rc = ble_att_clt_parse_handles_info(rxom, &adata);
+ rc = ble_att_clt_parse_attribute_data(rxom, rsp.bagp_length, &adata);
if (rc != 0) {
- break;
+ goto done;
}
- ble_gatt_rx_find_type_value_hinfo(conn, &adata);
- os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
+ ble_gatt_rx_read_group_type_adata(conn, &adata);
+ os_mbuf_adj(*rxom, rsp.bagp_length);
}
- /* Notify GATT that the full response has been parsed. */
- ble_gatt_rx_find_type_value_complete(conn, rc);
+done:
+ /* Notify GATT that the response is done being parsed. */
+ ble_gatt_rx_read_group_type_complete(conn, rc);
return 0;
}
int
-ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
- struct ble_att_read_group_type_req *req,
- void *uuid128)
+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;
@@ -404,27 +412,27 @@ ble_att_clt_tx_read_group_type(struct ble_hs_conn *conn,
txom = NULL;
- if (req->bagq_start_handle == 0 ||
- req->bagq_start_handle > req->bagq_end_handle) {
+ if (req->bavq_start_handle == 0 ||
+ req->bavq_start_handle > req->bavq_end_handle) {
rc = EINVAL;
goto err;
}
rc = ble_att_clt_prep_req(conn, &chan, &txom,
- BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ);
+ BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ);
if (rc != 0) {
goto err;
}
- rc = ble_att_read_group_type_req_write(txom->om_data, txom->om_len,
- req);
+ rc = ble_att_find_type_value_req_write(txom->om_data, txom->om_len, req);
if (rc != 0) {
goto err;
}
- rc = ble_hs_uuid_append(txom, uuid128);
+ rc = os_mbuf_append(txom, attribute_value, value_len);
if (rc != 0) {
+ rc = EMSGSIZE;
goto err;
}
@@ -442,60 +450,52 @@ err:
}
static int
-ble_att_clt_parse_attribute_data(struct os_mbuf **om, int data_len,
- struct ble_att_clt_adata *adata)
+ble_att_clt_parse_handles_info(struct os_mbuf **om,
+ struct ble_att_clt_adata *adata)
{
- *om = os_mbuf_pullup(*om, data_len);
+ *om = os_mbuf_pullup(*om, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
if (*om == NULL) {
return ENOMEM;
}
adata->att_handle = le16toh((*om)->om_data + 0);
adata->end_group_handle = le16toh((*om)->om_data + 2);
- adata->value_len = data_len - BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
- adata->value = (*om)->om_data + BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ;
+ adata->value_len = 0;
+ adata->value = NULL;
return 0;
}
int
-ble_att_clt_rx_read_group_type_rsp(struct ble_hs_conn *conn,
- struct ble_l2cap_chan *chan,
- struct os_mbuf **rxom)
+ble_att_clt_rx_find_type_value(struct ble_hs_conn *conn,
+ struct ble_l2cap_chan *chan,
+ struct os_mbuf **rxom)
{
- struct ble_att_read_group_type_rsp rsp;
struct ble_att_clt_adata adata;
int rc;
- *rxom = os_mbuf_pullup(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
- if (*rxom == NULL) {
- rc = ENOMEM;
- goto done;
- }
-
- rc = ble_att_read_group_type_rsp_parse((*rxom)->om_data, (*rxom)->om_len,
- &rsp);
- if (rc != 0) {
- goto done;
- }
-
- /* Strip the base from the front of the response. */
- os_mbuf_adj(*rxom, BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ);
+ /* 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 Attribute Data List field, passing each entry to the GATT. */
+ /* Parse the Handles Information List field, passing each entry to the
+ * GATT.
+ */
+ rc = 0;
while (OS_MBUF_PKTLEN(*rxom) > 0) {
- rc = ble_att_clt_parse_attribute_data(rxom, rsp.bagp_length, &adata);
+ rc = ble_att_clt_parse_handles_info(rxom, &adata);
if (rc != 0) {
- goto done;
+ break;
}
- ble_gatt_rx_read_group_type_adata(conn, &adata);
- os_mbuf_adj(*rxom, rsp.bagp_length);
+ ble_gatt_rx_find_type_value_hinfo(conn, &adata);
+ os_mbuf_adj(*rxom, BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ);
}
-done:
- /* Notify GATT that the response is done being parsed. */
- ble_gatt_rx_read_group_type_complete(conn, rc);
+ /* Notify GATT that the full response has been parsed. */
+ ble_gatt_rx_find_type_value_complete(conn, rc);
return 0;
}