nimble/gatt: Prepare GATT for EATT

This patch adds CID to the data path for all the GATT operations.
It also updates unit tests after the change.
This commit is contained in:
Łukasz Rymanowski
2023-08-24 10:26:53 +02:00
committed by Krzysztof Kopyściński
parent dd4e011ed6
commit 86c77a41df
20 changed files with 650 additions and 458 deletions
+75 -10
View File
@@ -35,7 +35,7 @@
static uint16_t ble_att_preferred_mtu_val;
/** Dispatch table for incoming ATT requests. Sorted by op code. */
typedef int ble_att_rx_fn(uint16_t conn_handle, struct os_mbuf **om);
typedef int ble_att_rx_fn(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om);
struct ble_att_rx_dispatch_entry {
uint8_t bde_op;
ble_att_rx_fn *bde_fn;
@@ -154,13 +154,20 @@ ble_att_rx_dispatch_entry_find(uint8_t op)
}
int
ble_att_conn_chan_find(uint16_t conn_handle, struct ble_hs_conn **out_conn,
ble_att_conn_chan_find(uint16_t conn_handle, uint16_t cid, struct ble_hs_conn **out_conn,
struct ble_l2cap_chan **out_chan)
{
return ble_hs_misc_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT,
return ble_hs_misc_conn_chan_find(conn_handle, cid,
out_conn, out_chan);
}
int
ble_att_conn_chan_find_by_psm(uint16_t conn_handle, uint16_t psm, struct ble_hs_conn **out_conn,
struct ble_l2cap_chan **out_chan)
{
return ble_hs_misc_conn_chan_find(conn_handle, psm, out_conn, out_chan);
}
void
ble_att_inc_tx_stat(uint8_t att_op)
{
@@ -410,7 +417,7 @@ ble_att_truncate_to_mtu(const struct ble_l2cap_chan *att_chan,
}
uint16_t
ble_att_mtu(uint16_t conn_handle)
ble_att_mtu_by_cid(uint16_t conn_handle, uint16_t cid)
{
struct ble_l2cap_chan *chan;
struct ble_hs_conn *conn;
@@ -419,7 +426,7 @@ ble_att_mtu(uint16_t conn_handle)
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, cid, &conn, &chan);
if (rc == 0) {
mtu = ble_att_chan_mtu(chan);
} else {
@@ -431,6 +438,12 @@ ble_att_mtu(uint16_t conn_handle)
return mtu;
}
uint16_t
ble_att_mtu(uint16_t conn_handle)
{
return ble_att_mtu_by_cid(conn_handle, BLE_L2CAP_CID_ATT);
}
void
ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu)
{
@@ -446,6 +459,13 @@ ble_att_chan_mtu(const struct ble_l2cap_chan *chan)
{
uint16_t mtu;
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0
if (chan->scid != BLE_L2CAP_CID_ATT) {
/* EATT case */
return chan->coc_tx.mtu;
}
#endif
/* If either side has not exchanged MTU size, use the default. Otherwise,
* use the lesser of the two exchanged values.
*/
@@ -464,7 +484,7 @@ ble_att_chan_mtu(const struct ble_l2cap_chan *chan)
static void
ble_att_rx_handle_unknown_request(uint8_t op, uint16_t conn_handle,
struct os_mbuf **om)
uint16_t cid, struct os_mbuf **om)
{
/* If this is command (bit6 is set to 1), do nothing */
if (op & 0x40) {
@@ -472,12 +492,13 @@ ble_att_rx_handle_unknown_request(uint8_t op, uint16_t conn_handle,
}
os_mbuf_adj(*om, OS_MBUF_PKTLEN(*om));
ble_att_svr_tx_error_rsp(conn_handle, *om, op, 0,
ble_att_svr_tx_error_rsp(conn_handle, cid, *om, op, 0,
BLE_ATT_ERR_REQ_NOT_SUPPORTED);
*om = NULL;
}
static int
ble_att_rx(struct ble_l2cap_chan *chan)
{
@@ -502,7 +523,7 @@ ble_att_rx(struct ble_l2cap_chan *chan)
entry = ble_att_rx_dispatch_entry_find(op);
if (entry == NULL) {
ble_att_rx_handle_unknown_request(op, conn_handle, om);
ble_att_rx_handle_unknown_request(op, conn_handle, chan->scid, om);
return BLE_HS_ENOTSUP;
}
@@ -511,10 +532,10 @@ ble_att_rx(struct ble_l2cap_chan *chan)
/* Strip L2CAP ATT header from the front of the mbuf. */
os_mbuf_adj(*om, 1);
rc = entry->bde_fn(conn_handle, om);
rc = entry->bde_fn(conn_handle, chan->scid, om);
if (rc != 0) {
if (rc == BLE_HS_ENOTSUP) {
ble_att_rx_handle_unknown_request(op, conn_handle, om);
ble_att_rx_handle_unknown_request(op, conn_handle, chan->scid, om);
}
return rc;
}
@@ -582,6 +603,50 @@ ble_att_create_chan(uint16_t conn_handle)
return chan;
}
bool
ble_att_is_request_op(uint8_t opcode)
{
switch (opcode) {
case BLE_ATT_OP_MTU_REQ:
case BLE_ATT_OP_FIND_INFO_REQ:
case BLE_ATT_OP_FIND_TYPE_VALUE_REQ:
case BLE_ATT_OP_READ_TYPE_REQ:
case BLE_ATT_OP_READ_REQ:
case BLE_ATT_OP_READ_BLOB_REQ:
case BLE_ATT_OP_READ_MULT_REQ:
case BLE_ATT_OP_READ_GROUP_TYPE_REQ:
case BLE_ATT_OP_WRITE_REQ:
case BLE_ATT_OP_PREP_WRITE_REQ:
case BLE_ATT_OP_EXEC_WRITE_REQ:
case BLE_ATT_OP_INDICATE_REQ:
return true;
}
return false;
}
bool
ble_att_is_response_op(uint8_t opcode)
{
switch (opcode) {
case BLE_ATT_OP_MTU_RSP:
case BLE_ATT_OP_ERROR_RSP:
case BLE_ATT_OP_FIND_INFO_RSP:
case BLE_ATT_OP_FIND_TYPE_VALUE_RSP:
case BLE_ATT_OP_READ_TYPE_RSP:
case BLE_ATT_OP_INDICATE_RSP:
case BLE_ATT_OP_READ_RSP:
case BLE_ATT_OP_READ_BLOB_RSP:
case BLE_ATT_OP_READ_MULT_RSP:
case BLE_ATT_OP_READ_GROUP_TYPE_RSP:
case BLE_ATT_OP_WRITE_RSP:
case BLE_ATT_OP_PREP_WRITE_RSP:
case BLE_ATT_OP_EXEC_WRITE_RSP:
return true;
}
return false;
}
int
ble_att_init(void)
{
+73 -63
View File
@@ -32,7 +32,7 @@
*****************************************************************************/
int
ble_att_clt_rx_error(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_error(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
struct ble_att_error_rsp *rsp;
int rc;
@@ -44,7 +44,7 @@ ble_att_clt_rx_error(uint16_t conn_handle, struct os_mbuf **rxom)
rsp = (struct ble_att_error_rsp *)(*rxom)->om_data;
ble_gattc_rx_err(conn_handle, le16toh(rsp->baep_handle),
ble_gattc_rx_err(conn_handle, cid, le16toh(rsp->baep_handle),
le16toh(rsp->baep_error_code));
return 0;
@@ -69,7 +69,7 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu)
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan);
if (rc != 0) {
rc = BLE_HS_ENOTCONN;
} else if (chan->flags & BLE_L2CAP_CHAN_F_TXED_MTU) {
@@ -90,14 +90,14 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu)
req->bamc_mtu = htole16(mtu);
rc = ble_att_tx(conn_handle, txom);
rc = ble_att_tx(conn_handle, BLE_L2CAP_CID_ATT, txom);
if (rc != 0) {
return rc;
}
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan);
if (rc == 0) {
chan->flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
}
@@ -108,7 +108,7 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu)
}
int
ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
struct ble_att_mtu_cmd *cmd;
struct ble_l2cap_chan *chan;
@@ -117,13 +117,20 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
mtu = 0;
#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0
if (cid != BLE_L2CAP_CID_ATT) {
/*FIXME reject ?*/
assert(0);
}
#endif
rc = ble_hs_mbuf_pullup_base(rxom, sizeof(*cmd));
if (rc == 0) {
cmd = (struct ble_att_mtu_cmd *)(*rxom)->om_data;
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, NULL, &chan);
rc = ble_att_conn_chan_find(conn_handle, cid, NULL, &chan);
if (rc == 0) {
ble_att_set_peer_mtu(chan, le16toh(cmd->bamc_mtu));
mtu = ble_att_chan_mtu(chan);
@@ -136,7 +143,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
}
}
ble_gattc_rx_mtu(conn_handle, rc, mtu);
ble_gattc_rx_mtu(conn_handle, BLE_L2CAP_CID_ATT, rc, mtu);
return rc;
}
@@ -145,7 +152,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
*****************************************************************************/
int
ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t cid, uint16_t start_handle,
uint16_t end_handle)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_INFO
@@ -167,7 +174,7 @@ ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
req->bafq_start_handle = htole16(start_handle);
req->bafq_end_handle = htole16(end_handle);
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
static int
@@ -222,7 +229,7 @@ ble_att_clt_parse_find_info_entry(struct os_mbuf **rxom, uint8_t rsp_format,
}
int
ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **om)
ble_att_clt_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_INFO
return BLE_HS_ENOTSUP;
@@ -249,14 +256,14 @@ ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **om)
}
/* Hand find-info entry to GATT. */
ble_gattc_rx_find_info_idata(conn_handle, &idata);
ble_gattc_rx_find_info_idata(conn_handle, cid, &idata);
}
rc = 0;
done:
/* Notify GATT that response processing is done. */
ble_gattc_rx_find_info_complete(conn_handle, rc);
ble_gattc_rx_find_info_complete(conn_handle, cid, rc);
return rc;
}
@@ -269,8 +276,9 @@ done:
* anyway
*/
int
ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t start_handle,
uint16_t end_handle, uint16_t attribute_type,
ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
uint16_t attribute_type,
const void *attribute_value, int value_len)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_TYPE
@@ -295,7 +303,7 @@ ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t start_handle,
req->bavq_attr_type = htole16(attribute_type);
memcpy(req->bavq_value, attribute_value, value_len);
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
static int
@@ -321,7 +329,7 @@ ble_att_clt_parse_find_type_value_hinfo(
}
int
ble_att_clt_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_TYPE
return BLE_HS_ENOTSUP;
@@ -338,11 +346,11 @@ ble_att_clt_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
break;
}
ble_gattc_rx_find_type_value_hinfo(conn_handle, &hinfo);
ble_gattc_rx_find_type_value_hinfo(conn_handle, cid, &hinfo);
}
/* Notify GATT client that the full response has been parsed. */
ble_gattc_rx_find_type_value_complete(conn_handle, rc);
ble_gattc_rx_find_type_value_complete(conn_handle, cid, rc);
return 0;
}
@@ -352,7 +360,7 @@ ble_att_clt_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
*****************************************************************************/
int
ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle,
ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t cid, uint16_t start_handle,
uint16_t end_handle, const ble_uuid_t *uuid)
{
#if !NIMBLE_BLE_ATT_CLT_READ_TYPE
@@ -377,11 +385,11 @@ ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle,
ble_uuid_flat(uuid, req->uuid);
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
int
ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_READ_TYPE
return BLE_HS_ENOTSUP;
@@ -423,13 +431,13 @@ ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
adata.value_len = data_len - sizeof(*data);
adata.value = data->value;
ble_gattc_rx_read_type_adata(conn_handle, &adata);
ble_gattc_rx_read_type_adata(conn_handle, cid, &adata);
os_mbuf_adj(*rxom, data_len);
}
done:
/* Notify GATT that the response is done being parsed. */
ble_gattc_rx_read_type_complete(conn_handle, rc);
ble_gattc_rx_read_type_complete(conn_handle, cid, rc);
return rc;
}
@@ -439,7 +447,7 @@ done:
*****************************************************************************/
int
ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle)
ble_att_clt_tx_read(uint16_t conn_handle, uint16_t cid, uint16_t handle)
{
#if !NIMBLE_BLE_ATT_CLT_READ
return BLE_HS_ENOTSUP;
@@ -460,7 +468,7 @@ ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle)
req->barq_handle = htole16(handle);
rc = ble_att_tx(conn_handle, txom);
rc = ble_att_tx(conn_handle, cid, txom);
if (rc != 0) {
return rc;
}
@@ -469,14 +477,14 @@ ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle)
}
int
ble_att_clt_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_READ
return BLE_HS_ENOTSUP;
#endif
/* Pass the Attribute Value field to GATT. */
ble_gattc_rx_read_rsp(conn_handle, 0, rxom);
ble_gattc_rx_read_rsp(conn_handle, cid, 0, rxom);
return 0;
}
@@ -485,7 +493,7 @@ ble_att_clt_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
*****************************************************************************/
int
ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle, uint16_t offset)
ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t cid, uint16_t handle, uint16_t offset)
{
#if !NIMBLE_BLE_ATT_CLT_READ_BLOB
return BLE_HS_ENOTSUP;
@@ -507,7 +515,7 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle, uint16_t offset)
req->babq_handle = htole16(handle);
req->babq_offset = htole16(offset);
rc = ble_att_tx(conn_handle, txom);
rc = ble_att_tx(conn_handle, cid, txom);
if (rc != 0) {
return rc;
}
@@ -516,14 +524,14 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle, uint16_t offset)
}
int
ble_att_clt_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_READ_BLOB
return BLE_HS_ENOTSUP;
#endif
/* Pass the Attribute Value field to GATT. */
ble_gattc_rx_read_blob_rsp(conn_handle, 0, rxom);
ble_gattc_rx_read_blob_rsp(conn_handle, cid, 0, rxom);
return 0;
}
@@ -531,7 +539,7 @@ ble_att_clt_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
* $read multiple *
*****************************************************************************/
int
ble_att_clt_tx_read_mult(uint16_t conn_handle, const uint16_t *handles,
ble_att_clt_tx_read_mult(uint16_t conn_handle, uint16_t cid, const uint16_t *handles,
int num_handles)
{
#if !NIMBLE_BLE_ATT_CLT_READ_MULT
@@ -557,18 +565,18 @@ ble_att_clt_tx_read_mult(uint16_t conn_handle, const uint16_t *handles,
req->handles[i] = htole16(handles[i]);
}
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
int
ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_READ_MULT
return BLE_HS_ENOTSUP;
#endif
/* Pass the Attribute Value field to GATT. */
ble_gattc_rx_read_mult_rsp(conn_handle, 0, rxom);
ble_gattc_rx_read_mult_rsp(conn_handle, cid, 0, rxom);
return 0;
}
@@ -577,7 +585,7 @@ ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
*****************************************************************************/
int
ble_att_clt_tx_read_group_type(uint16_t conn_handle,
ble_att_clt_tx_read_group_type(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
const ble_uuid_t *uuid)
{
@@ -602,7 +610,7 @@ ble_att_clt_tx_read_group_type(uint16_t conn_handle,
req->bagq_end_handle = htole16(end_handle);
ble_uuid_flat(uuid, req->uuid);
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
static int
@@ -630,7 +638,7 @@ ble_att_clt_parse_read_group_type_adata(
}
int
ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE
return BLE_HS_ENOTSUP;
@@ -660,13 +668,13 @@ ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
goto done;
}
ble_gattc_rx_read_group_type_adata(conn_handle, &adata);
ble_gattc_rx_read_group_type_adata(conn_handle, cid, &adata);
os_mbuf_adj(*rxom, len);
}
done:
/* Notify GATT that the response is done being parsed. */
ble_gattc_rx_read_group_type_complete(conn_handle, rc);
ble_gattc_rx_read_group_type_complete(conn_handle, cid, rc);
return rc;
}
@@ -675,7 +683,7 @@ done:
*****************************************************************************/
int
ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t handle,
ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t cid, uint16_t handle,
struct os_mbuf *txom)
{
#if !NIMBLE_BLE_ATT_CLT_WRITE
@@ -694,12 +702,12 @@ ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t handle,
req->bawq_handle = htole16(handle);
os_mbuf_concat(txom2, txom);
return ble_att_tx(conn_handle, txom2);
return ble_att_tx(conn_handle, cid, txom2);
}
int
ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom)
ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t cid,
uint16_t handle, struct os_mbuf *txom)
{
#if !NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP
return BLE_HS_ENOTSUP;
@@ -733,18 +741,18 @@ ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle,
cmd->handle = htole16(handle);
os_mbuf_concat(txom2, txom);
return ble_att_tx(conn_handle, txom2);
return ble_att_tx(conn_handle, cid, txom2);
}
int
ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_WRITE
return BLE_HS_ENOTSUP;
#endif
/* No payload. */
ble_gattc_rx_write_rsp(conn_handle);
ble_gattc_rx_write_rsp(conn_handle, cid);
return 0;
}
@@ -753,7 +761,7 @@ ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
*****************************************************************************/
int
ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle,
ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t cid, uint16_t handle,
uint16_t offset, struct os_mbuf *txom)
{
#if !NIMBLE_BLE_ATT_CLT_PREP_WRITE
@@ -775,7 +783,7 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle,
}
if (OS_MBUF_PKTLEN(txom) >
ble_att_mtu(conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) {
ble_att_mtu_by_cid(conn_handle, cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) {
rc = BLE_HS_EINVAL;
goto err;
}
@@ -790,7 +798,7 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle,
req->bapc_offset = htole16(offset);
os_mbuf_concat(txom2, txom);
return ble_att_tx(conn_handle, txom2);
return ble_att_tx(conn_handle, cid, txom2);
err:
os_mbuf_free_chain(txom);
@@ -798,7 +806,7 @@ err:
}
int
ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_PREP_WRITE
return BLE_HS_ENOTSUP;
@@ -827,7 +835,7 @@ ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
done:
/* Notify GATT client that the full response has been parsed. */
ble_gattc_rx_prep_write_rsp(conn_handle, rc, handle, offset, rxom);
ble_gattc_rx_prep_write_rsp(conn_handle, cid, rc, handle, offset, rxom);
return rc;
}
@@ -836,7 +844,7 @@ done:
*****************************************************************************/
int
ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags)
ble_att_clt_tx_exec_write(uint16_t conn_handle, uint16_t cid, uint8_t flags)
{
#if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE
return BLE_HS_ENOTSUP;
@@ -853,7 +861,7 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags)
req->baeq_flags = flags;
rc = ble_att_tx(conn_handle, txom);
rc = ble_att_tx(conn_handle, cid, txom);
if (rc != 0) {
return rc;
}
@@ -862,13 +870,13 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags)
}
int
ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_exec_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE
return BLE_HS_ENOTSUP;
#endif
ble_gattc_rx_exec_write_rsp(conn_handle, 0);
ble_gattc_rx_exec_write_rsp(conn_handle, cid, 0);
return 0;
}
@@ -886,6 +894,7 @@ ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
struct ble_att_notify_req *req;
struct os_mbuf *txom2;
uint16_t cid;
int rc;
if (handle == 0) {
@@ -902,7 +911,8 @@ ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
req->banq_handle = htole16(handle);
os_mbuf_concat(txom2, txom);
return ble_att_tx(conn_handle, txom2);
cid = BLE_L2CAP_CID_ATT;
return ble_att_tx(conn_handle, cid, txom2);
err:
os_mbuf_free_chain(txom);
@@ -914,8 +924,8 @@ err:
*****************************************************************************/
int
ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom)
ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t cid,
uint16_t handle, struct os_mbuf *txom)
{
#if !NIMBLE_BLE_ATT_CLT_INDICATE
return BLE_HS_ENOTSUP;
@@ -939,7 +949,7 @@ ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t handle,
req->baiq_handle = htole16(handle);
os_mbuf_concat(txom2, txom);
return ble_att_tx(conn_handle, txom2);
return ble_att_tx(conn_handle, cid, txom2);
err:
os_mbuf_free_chain(txom);
@@ -947,14 +957,14 @@ err:
}
int
ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_clt_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !NIMBLE_BLE_ATT_CLT_INDICATE
return BLE_HS_ENOTSUP;
#endif
/* No payload. */
ble_gatts_rx_indicate_rsp(conn_handle);
ble_gatts_rx_indicate_rsp(conn_handle, cid);
return 0;
}
+39 -9
View File
@@ -55,28 +55,58 @@ ble_att_cmd_get(uint8_t opcode, size_t len, struct os_mbuf **txom)
}
int
ble_att_tx(uint16_t conn_handle, struct os_mbuf *txom)
ble_att_tx_with_conn(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan, struct os_mbuf *txom)
{
int rc;
struct os_mbuf_pkthdr *omp;
if (!txom) {
if (conn->client_att_busy) {
return 0;
}
omp = STAILQ_FIRST(&conn->att_tx_q);
if (omp == NULL) {
return 0;
}
STAILQ_REMOVE_HEAD(&conn->att_tx_q, omp_next);
txom = OS_MBUF_PKTHDR_TO_MBUF(omp);
}
BLE_HS_DBG_ASSERT_EVAL(txom->om_len >= 1);
if (ble_att_is_request_op(txom->om_data[0])) {
if (conn->client_att_busy) {
STAILQ_INSERT_TAIL(&conn->att_tx_q, OS_MBUF_PKTHDR(txom), omp_next);
return 0;
}
conn->client_att_busy = true;
}
ble_att_inc_tx_stat(txom->om_data[0]);
ble_att_truncate_to_mtu(chan, txom);
rc = ble_l2cap_tx(conn, chan, txom);
assert(rc == 0);
return rc;
}
int
ble_att_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom)
{
struct ble_l2cap_chan *chan;
struct ble_hs_conn *conn;
int rc;
BLE_HS_DBG_ASSERT_EVAL(txom->om_len >= 1);
ble_att_inc_tx_stat(txom->om_data[0]);
ble_hs_lock();
rc = ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_ATT, &conn,
&chan);
if (rc != 0) {
os_mbuf_free_chain(txom);
} else {
ble_att_truncate_to_mtu(chan, txom);
rc = ble_l2cap_tx(conn, chan, txom);
return rc;
}
rc = ble_att_tx_with_conn(conn, chan, txom);
ble_hs_unlock();
return rc;
}
+7 -1
View File
@@ -440,8 +440,14 @@ void ble_att_indicate_rsp_write(void *payload, int len);
void *ble_att_cmd_prepare(uint8_t opcode, size_t len, struct os_mbuf *txom);
void *ble_att_cmd_get(uint8_t opcode, size_t len, struct os_mbuf **txom);
int ble_att_tx(uint16_t conn_handle, struct os_mbuf *txom);
int ble_att_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom);
struct ble_l2cap_chan;
struct ble_hs_conn;
int ble_att_tx_with_conn(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
struct os_mbuf *txom);
bool ble_att_is_response_op(uint8_t opcode);
bool ble_att_is_request_op(uint8_t opcode);
#ifdef __cplusplus
}
#endif
+50 -45
View File
@@ -161,13 +161,15 @@ SLIST_HEAD(ble_att_clt_entry_list, ble_att_clt_entry);
/*** @gen */
struct ble_l2cap_chan *ble_att_create_chan(uint16_t conn_handle);
int ble_att_conn_chan_find(uint16_t conn_handle, struct ble_hs_conn **out_conn,
int ble_att_conn_chan_find(uint16_t conn_handle, uint16_t cid,
struct ble_hs_conn **out_conn,
struct ble_l2cap_chan **out_chan);
void ble_att_inc_tx_stat(uint8_t att_op);
void ble_att_truncate_to_mtu(const struct ble_l2cap_chan *att_chan,
struct os_mbuf *txom);
void ble_att_set_peer_mtu(struct ble_l2cap_chan *chan, uint16_t peer_mtu);
uint16_t ble_att_chan_mtu(const struct ble_l2cap_chan *chan);
uint16_t ble_att_mtu_by_cid(uint16_t conn_handle, uint16_t cid);
int ble_att_init(void);
/*** @svr */
@@ -179,33 +181,33 @@ ble_att_svr_find_by_uuid(struct ble_att_svr_entry *start_at,
const ble_uuid_t *uuid,
uint16_t end_handle);
uint16_t ble_att_svr_prev_handle(void);
int ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_svr_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
struct ble_att_svr_entry *ble_att_svr_find_by_handle(uint16_t handle_id);
int32_t ble_att_svr_ticks_until_tmo(const struct ble_att_svr_conn *svr,
ble_npl_time_t now);
int ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_svr_rx_find_type_value(uint16_t conn_handle,
int ble_att_svr_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_read_type(uint16_t conn_handle,
int ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_read_group_type(uint16_t conn_handle,
int ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_read(uint16_t conn_handle,
int ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_read_blob(uint16_t conn_handle,
int ble_att_svr_rx_read_blob(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_read_mult(uint16_t conn_handle,
int ble_att_svr_rx_read_mult(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_write(uint16_t conn_handle,
int ble_att_svr_rx_write(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_svr_rx_prep_write(uint16_t conn_handle,
int ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_svr_rx_prep_write(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_exec_write(uint16_t conn_handle,
int ble_att_svr_rx_exec_write(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_notify(uint16_t conn_handle,
int ble_att_svr_rx_notify(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_svr_rx_indicate(uint16_t conn_handle,
int ble_att_svr_rx_indicate(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
void ble_att_svr_prep_clear(struct ble_att_prep_entry_list *prep_list);
int ble_att_svr_read_handle(uint16_t conn_handle, uint16_t attr_handle,
@@ -217,7 +219,7 @@ int ble_att_svr_init(void);
void ble_att_svr_hide_range(uint16_t start_handle, uint16_t end_handle);
void ble_att_svr_restore_range(uint16_t start_handle, uint16_t end_handle);
int ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom,
int ble_att_svr_tx_error_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom,
uint8_t req_op, uint16_t handle,
uint8_t error_code);
/*** $clt */
@@ -250,48 +252,51 @@ struct ble_att_read_group_type_adata {
uint8_t *value;
};
int ble_att_clt_rx_error(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_rx_error(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu);
int ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle);
int ble_att_clt_rx_read(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle,
int ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_read(uint16_t conn_handle, uint16_t cid, uint16_t handle);
int ble_att_clt_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t cid, uint16_t handle,
uint16_t offset);
int ble_att_clt_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_read_mult(uint16_t conn_handle,
int ble_att_clt_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_read_mult(uint16_t conn_handle, uint16_t cid,
const uint16_t *handles, int num_handles);
int ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle,
int ble_att_clt_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t cid, uint16_t start_handle,
uint16_t end_handle, const ble_uuid_t *uuid);
int ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_read_group_type(uint16_t conn_handle,
int ble_att_clt_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_read_group_type(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
const ble_uuid_t *uuid128);
int ble_att_clt_rx_read_group_type(uint16_t conn_handle,
int ble_att_clt_rx_read_group_type(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t cid, uint16_t start_handle,
uint16_t end_handle);
int ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t start_handle,
int ble_att_clt_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t cid, uint16_t start_handle,
uint16_t end_handle, uint16_t attribute_type,
const void *attribute_value, int value_len);
int ble_att_clt_rx_find_type_value(uint16_t conn_handle,
int ble_att_clt_rx_find_type_value(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom);
int ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom);
int ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle,
uint16_t offset, struct os_mbuf *txom);
int ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags);
int ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t cid,
uint16_t handle, struct os_mbuf *txom);
int ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t cid,
uint16_t handle, struct os_mbuf *txom);
int ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t cid,
uint16_t handle, uint16_t offset,
struct os_mbuf *txom);
int ble_att_clt_rx_prep_write(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom);
int ble_att_clt_tx_exec_write(uint16_t conn_handle, uint16_t cid,
uint8_t flags);
int ble_att_clt_rx_exec_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
int ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom);
int ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t handle,
struct os_mbuf *txom);
int ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom);
int ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t cid,
uint16_t handle, struct os_mbuf *txom);
int ble_att_clt_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom);
#ifdef __cplusplus
}
+56 -50
View File
@@ -578,7 +578,7 @@ ble_att_svr_write_handle(uint16_t conn_handle, uint16_t attr_handle,
}
int
ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom,
ble_att_svr_tx_error_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom,
uint8_t req_op, uint16_t handle, uint8_t error_code)
{
struct ble_att_error_rsp *rsp;
@@ -595,7 +595,7 @@ ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom,
rsp->baep_handle = htole16(handle);
rsp->baep_error_code = error_code;
return ble_att_tx(conn_handle, txom);
return ble_att_tx(conn_handle, cid, txom);
}
/**
@@ -622,7 +622,7 @@ ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom,
* field.
*/
static int
ble_att_svr_tx_rsp(uint16_t conn_handle, int hs_status, struct os_mbuf *om,
ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_mbuf *om,
uint8_t att_op, uint8_t err_status, uint16_t err_handle)
{
struct ble_l2cap_chan *chan;
@@ -640,7 +640,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, int hs_status, struct os_mbuf *om,
if (do_tx) {
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, cid, &conn, &chan);
if (rc != 0) {
/* No longer connected. */
hs_status = rc;
@@ -670,7 +670,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, int hs_status, struct os_mbuf *om,
os_mbuf_adj(om, OS_MBUF_PKTLEN(om));
}
if (om != NULL) {
ble_att_svr_tx_error_rsp(conn_handle, om, att_op,
ble_att_svr_tx_error_rsp(conn_handle, cid, om, att_op,
err_handle, err_status);
om = NULL;
}
@@ -697,7 +697,7 @@ ble_att_svr_build_mtu_rsp(uint16_t conn_handle, struct os_mbuf **rxom,
txom = NULL;
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, NULL, &chan);
rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, NULL, &chan);
if (rc == 0) {
mtu = chan->my_mtu;
}
@@ -729,7 +729,7 @@ done:
}
int
ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
struct ble_att_mtu_cmd *cmd;
struct ble_l2cap_chan *chan;
@@ -742,6 +742,11 @@ ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
txom = NULL;
mtu = 0;
if (cid != BLE_L2CAP_CID_ATT) {
/*TODO */
return BLE_ATT_ERR_INVALID_PDU;
}
rc = ble_att_svr_pullup_req_base(rxom, sizeof(*cmd), &att_err);
if (rc != 0) {
goto done;
@@ -759,12 +764,12 @@ ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_MTU_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, BLE_L2CAP_CID_ATT, rc, txom, BLE_ATT_OP_MTU_REQ,
att_err, 0);
if (rc == 0) {
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan);
if (rc == 0) {
ble_att_set_peer_mtu(chan, mtu);
chan->flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
@@ -863,7 +868,7 @@ done:
}
static int
ble_att_svr_build_find_info_rsp(uint16_t conn_handle,
ble_att_svr_build_find_info_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
struct os_mbuf **rxom,
struct os_mbuf **out_txom,
@@ -892,7 +897,7 @@ ble_att_svr_build_find_info_rsp(uint16_t conn_handle,
/* Write the variable length Information Data field, populating the format
* field as appropriate.
*/
mtu = ble_att_mtu(conn_handle);
mtu = ble_att_mtu_by_cid(conn_handle, cid);
rc = ble_att_svr_fill_info(start_handle, end_handle, txom, mtu,
&rsp->bafp_format);
if (rc != 0) {
@@ -909,7 +914,7 @@ done:
}
int
ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_FIND_INFO)
return BLE_HS_ENOTSUP;
@@ -946,7 +951,7 @@ ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom)
goto done;
}
rc = ble_att_svr_build_find_info_rsp(conn_handle,
rc = ble_att_svr_build_find_info_rsp(conn_handle, cid,
start_handle, end_handle,
rxom, &txom, &att_err);
if (rc != 0) {
@@ -957,7 +962,7 @@ ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_FIND_INFO_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_FIND_INFO_REQ,
att_err, err_handle);
return rc;
}
@@ -1172,7 +1177,7 @@ done:
}
static int
ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle,
ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle,
uint16_t end_handle,
ble_uuid16_t attr_type,
@@ -1199,7 +1204,7 @@ ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle,
}
/* Write the variable length Information Data field. */
mtu = ble_att_mtu(conn_handle);
mtu = ble_att_mtu_by_cid(conn_handle, cid);
rc = ble_att_svr_fill_type_value(conn_handle, start_handle, end_handle,
attr_type, *rxom, txom, mtu,
@@ -1216,7 +1221,7 @@ done:
}
int
ble_att_svr_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_FIND_TYPE)
return BLE_HS_ENOTSUP;
@@ -1254,7 +1259,7 @@ ble_att_svr_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
rc = BLE_HS_EBADDATA;
goto done;
}
rc = ble_att_svr_build_find_type_value_rsp(conn_handle, start_handle,
rc = ble_att_svr_build_find_type_value_rsp(conn_handle, cid, start_handle,
end_handle, attr_type, rxom,
&txom, &att_err);
if (rc != 0) {
@@ -1265,14 +1270,14 @@ ble_att_svr_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom,
BLE_ATT_OP_FIND_TYPE_VALUE_REQ, att_err,
err_handle);
return rc;
}
static int
ble_att_svr_build_read_type_rsp(uint16_t conn_handle,
ble_att_svr_build_read_type_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
const ble_uuid_t *uuid,
struct os_mbuf **rxom,
@@ -1315,7 +1320,7 @@ ble_att_svr_build_read_type_rsp(uint16_t conn_handle,
goto done;
}
mtu = ble_att_mtu(conn_handle);
mtu = ble_att_mtu_by_cid(conn_handle, cid);
/* Find all matching attributes, writing a record for each. */
entry = NULL;
@@ -1387,7 +1392,7 @@ done:
}
int
ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_READ_TYPE)
return BLE_HS_ENOTSUP;
@@ -1439,7 +1444,7 @@ ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
goto done;
}
rc = ble_att_svr_build_read_type_rsp(conn_handle, start_handle, end_handle,
rc = ble_att_svr_build_read_type_rsp(conn_handle, cid, start_handle, end_handle,
&uuid.u, rxom, &txom, &att_err,
&err_handle);
if (rc != 0) {
@@ -1449,13 +1454,13 @@ ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_TYPE_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_TYPE_REQ,
att_err, err_handle);
return rc;
}
int
ble_att_svr_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_READ)
return BLE_HS_ENOTSUP;
@@ -1498,13 +1503,13 @@ ble_att_svr_rx_read(uint16_t conn_handle, struct os_mbuf **rxom)
}
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_REQ,
att_err, err_handle);
return rc;
}
int
ble_att_svr_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_READ_BLOB)
return BLE_HS_ENOTSUP;
@@ -1551,13 +1556,13 @@ ble_att_svr_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_BLOB_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_BLOB_REQ,
att_err, err_handle);
return rc;
}
static int
ble_att_svr_build_read_mult_rsp(uint16_t conn_handle,
ble_att_svr_build_read_mult_rsp(uint16_t conn_handle, uint16_t cid,
struct os_mbuf **rxom,
struct os_mbuf **out_txom,
uint8_t *att_err,
@@ -1568,7 +1573,7 @@ ble_att_svr_build_read_mult_rsp(uint16_t conn_handle,
uint16_t mtu;
int rc;
mtu = ble_att_mtu(conn_handle);
mtu = ble_att_mtu_by_cid(conn_handle, cid);
rc = ble_att_svr_pkt(rxom, &txom, att_err);
if (rc != 0) {
@@ -1618,7 +1623,7 @@ done:
}
int
ble_att_svr_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_READ_MULT)
return BLE_HS_ENOTSUP;
@@ -1634,10 +1639,10 @@ ble_att_svr_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
err_handle = 0;
att_err = 0;
rc = ble_att_svr_build_read_mult_rsp(conn_handle, rxom, &txom, &att_err,
rc = ble_att_svr_build_read_mult_rsp(conn_handle, cid, rxom, &txom, &att_err,
&err_handle);
return ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_MULT_REQ,
return ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_MULT_REQ,
att_err, err_handle);
}
@@ -1705,7 +1710,7 @@ ble_att_svr_read_group_type_entry_write(struct os_mbuf *om, uint16_t mtu,
* @return 0 on success; BLE_HS error code on failure.
*/
static int
ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle,
ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle,
uint16_t end_handle,
const ble_uuid_t *group_uuid,
@@ -1732,7 +1737,7 @@ ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle,
*att_err = 0;
*err_handle = start_handle;
mtu = ble_att_mtu(conn_handle);
mtu = ble_att_mtu_by_cid(conn_handle, cid);
/* Just reuse the request buffer for the response. */
txom = *rxom;
@@ -1874,7 +1879,7 @@ done:
}
int
ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_READ_GROUP_TYPE)
return BLE_HS_ENOTSUP;
@@ -1934,9 +1939,10 @@ ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
goto done;
}
rc = ble_att_svr_build_read_group_type_rsp(conn_handle, start_handle,
end_handle, &uuid.u,
rxom, &txom, &att_err,
rc = ble_att_svr_build_read_group_type_rsp(conn_handle, cid,
start_handle, end_handle,
&uuid.u, rxom,
&txom, &att_err,
&err_handle);
if (rc != 0) {
goto done;
@@ -1945,7 +1951,7 @@ ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom,
BLE_ATT_OP_READ_GROUP_TYPE_REQ, att_err,
err_handle);
return rc;
@@ -1980,7 +1986,7 @@ done:
}
int
ble_att_svr_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_WRITE)
return BLE_HS_ENOTSUP;
@@ -2025,13 +2031,13 @@ ble_att_svr_rx_write(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_WRITE_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_WRITE_REQ,
att_err, handle);
return rc;
}
int
ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_WRITE_NO_RSP)
return BLE_HS_ENOTSUP;
@@ -2317,7 +2323,7 @@ ble_att_svr_insert_prep_entry(uint16_t conn_handle,
}
int
ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE)
return BLE_HS_ENOTSUP;
@@ -2392,13 +2398,13 @@ ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_PREP_WRITE_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_PREP_WRITE_REQ,
att_err, err_handle);
return rc;
}
int
ble_att_svr_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_exec_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE)
return BLE_HS_ENOTSUP;
@@ -2467,13 +2473,13 @@ done:
ble_att_svr_prep_clear(&prep_list);
}
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_EXEC_WRITE_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_EXEC_WRITE_REQ,
att_err, err_handle);
return rc;
}
int
ble_att_svr_rx_notify(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_notify(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_NOTIFY)
return BLE_HS_ENOTSUP;
@@ -2548,7 +2554,7 @@ done:
}
int
ble_att_svr_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
ble_att_svr_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom)
{
#if !MYNEWT_VAL(BLE_ATT_SVR_INDICATE)
return BLE_HS_ENOTSUP;
@@ -2606,7 +2612,7 @@ ble_att_svr_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
rc = 0;
done:
rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_INDICATE_REQ,
rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_INDICATE_REQ,
att_err, handle);
return rc;
}
+19 -19
View File
@@ -103,32 +103,32 @@ struct ble_gatts_conn {
int ble_gattc_locked_by_cur_task(void);
void ble_gatts_indicate_fail_notconn(uint16_t conn_handle);
void ble_gattc_rx_err(uint16_t conn_handle, uint16_t handle, uint16_t status);
void ble_gattc_rx_mtu(uint16_t conn_handle, int status, uint16_t chan_mtu);
void ble_gattc_rx_read_type_adata(uint16_t conn_handle,
void ble_gattc_rx_err(uint16_t conn_handle, uint16_t cid, uint16_t handle, uint16_t status);
void ble_gattc_rx_mtu(uint16_t conn_handle, uint16_t cid, int status, uint16_t chan_mtu);
void ble_gattc_rx_read_type_adata(uint16_t conn_handle, uint16_t cid,
struct ble_att_read_type_adata *adata);
void ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status);
void ble_gattc_rx_read_rsp(uint16_t conn_handle, int status,
void ble_gattc_rx_read_type_complete(uint16_t conn_handle, uint16_t cid, int status);
void ble_gattc_rx_read_rsp(uint16_t conn_handle, uint16_t cid, int status,
struct os_mbuf **rxom);
void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status,
struct os_mbuf **rxom);
void ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
void ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status,
struct os_mbuf **rxom);
void ble_gattc_rx_read_group_type_adata(
uint16_t conn_handle, struct ble_att_read_group_type_adata *adata);
void ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int rc);
void ble_gattc_rx_find_type_value_hinfo(
uint16_t conn_handle, struct ble_att_find_type_value_hinfo *hinfo);
void ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status);
void ble_gattc_rx_write_rsp(uint16_t conn_handle);
void ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
void ble_gattc_rx_read_group_type_adata(uint16_t conn_handle, uint16_t cid,
struct ble_att_read_group_type_adata *adata);
void ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, uint16_t cid, int rc);
void ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle, uint16_t cid,
struct ble_att_find_type_value_hinfo *hinfo);
void ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, uint16_t cid, int status);
void ble_gattc_rx_write_rsp(uint16_t conn_handle, uint16_t cid);
void ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, uint16_t cid, int status,
uint16_t handle, uint16_t offset,
struct os_mbuf **rxom);
void ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status);
void ble_gatts_rx_indicate_rsp(uint16_t conn_handle);
void ble_gattc_rx_find_info_idata(uint16_t conn_handle,
void ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, uint16_t cid, int status);
void ble_gatts_rx_indicate_rsp(uint16_t conn_handle, uint16_t cid);
void ble_gattc_rx_find_info_idata(uint16_t conn_handle, uint16_t cid,
struct ble_att_find_info_idata *idata);
void ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status);
void ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, int status);
void ble_gattc_connection_txable(uint16_t conn_handle);
void ble_gattc_connection_broken(uint16_t conn_handle);
int32_t ble_gattc_timer(void);
+153 -99
View File
@@ -108,6 +108,7 @@ struct ble_gattc_proc {
uint32_t exp_os_ticks;
uint16_t conn_handle;
uint16_t cid;
uint8_t op;
uint8_t flags;
@@ -694,6 +695,14 @@ ble_gattc_proc_alloc(void)
return proc;
}
static void
ble_gattc_proc_prepare(struct ble_gattc_proc *proc, uint16_t conn_handle, uint8_t op)
{
proc->conn_handle = conn_handle;
proc->op = op;
proc->cid = BLE_L2CAP_CID_ATT;
}
/**
* Frees the specified proc entry. No-op if passed a null pointer.
*/
@@ -845,6 +854,7 @@ typedef int ble_gattc_match_fn(struct ble_gattc_proc *proc, void *arg);
struct ble_gattc_criteria_conn_op {
uint16_t conn_handle;
uint16_t psm;
uint8_t op;
};
@@ -876,6 +886,28 @@ ble_gattc_proc_matches_conn_op(struct ble_gattc_proc *proc, void *arg)
return 1;
}
static int
ble_gattc_proc_matches_conn_cid_op(struct ble_gattc_proc *proc, void *arg)
{
const struct ble_gattc_criteria_conn_op *criteria;
criteria = arg;
if (criteria->conn_handle != proc->conn_handle) {
return 0;
}
if (criteria->psm != proc->cid) {
return 0;
}
if (criteria->op != proc->op && criteria->op != BLE_GATT_OP_NONE) {
return 0;
}
return 1;
}
struct ble_gattc_criteria_exp {
ble_npl_time_t now;
int32_t next_exp_in;
@@ -905,6 +937,7 @@ ble_gattc_proc_matches_expired(struct ble_gattc_proc *proc, void *arg)
struct ble_gattc_criteria_conn_rx_entry {
uint16_t conn_handle;
uint16_t cid;
const void *rx_entries;
int num_rx_entries;
const void *matching_rx_entry;
@@ -918,7 +951,8 @@ ble_gattc_proc_matches_conn_rx_entry(struct ble_gattc_proc *proc, void *arg)
criteria = arg;
if (criteria->conn_handle != BLE_HS_CONN_HANDLE_NONE &&
criteria->conn_handle != proc->conn_handle) {
criteria->conn_handle != proc->conn_handle &&
criteria->cid != proc->cid) {
return 0;
}
@@ -997,12 +1031,26 @@ ble_gattc_extract_by_conn_op(uint16_t conn_handle, uint8_t op, int max_procs,
ble_gattc_extract(ble_gattc_proc_matches_conn_op, &criteria, max_procs, dst_list);
}
static void
ble_gattc_extract_by_conn_cid_op(uint16_t conn_handle, uint16_t psm, uint8_t op,
int max_procs,
struct ble_gattc_proc_list *dst_list)
{
struct ble_gattc_criteria_conn_op criteria;
criteria.conn_handle = conn_handle;
criteria.op = op;
criteria.psm = psm;
ble_gattc_extract(ble_gattc_proc_matches_conn_cid_op, &criteria, max_procs, dst_list);
}
static struct ble_gattc_proc *
ble_gattc_extract_first_by_conn_op(uint16_t conn_handle, uint8_t op)
ble_gattc_extract_first_by_conn_cid_op(uint16_t conn_handle, uint16_t cid, uint8_t op)
{
struct ble_gattc_proc_list dst_list;
ble_gattc_extract_by_conn_op(conn_handle, op, 1, &dst_list);
ble_gattc_extract_by_conn_cid_op(conn_handle, cid, op, 1, &dst_list);
return STAILQ_FIRST(&dst_list);
}
@@ -1037,7 +1085,7 @@ ble_gattc_extract_expired(struct ble_gattc_proc_list *dst_list)
}
static struct ble_gattc_proc *
ble_gattc_extract_with_rx_entry(uint16_t conn_handle,
ble_gattc_extract_with_rx_entry(uint16_t conn_handle, uint16_t cid,
const void *rx_entries, int num_rx_entries,
const void **out_rx_entry)
{
@@ -1045,6 +1093,7 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle,
struct ble_gattc_proc *proc;
criteria.conn_handle = conn_handle;
criteria.cid = cid;
criteria.rx_entries = rx_entries;
criteria.num_rx_entries = num_rx_entries;
criteria.matching_rx_entry = NULL;
@@ -1062,6 +1111,7 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle,
* list and returned.
*
* @param conn_handle The connection handle to match against.
* @param cid Source CID of L2CAP channel used
* @param rx_entries The array of rx entries corresponding to the
* op code of the incoming response.
* @param out_rx_entry On success, the address of the matching rx
@@ -1070,9 +1120,9 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle,
* @return The matching proc entry on success;
* null on failure.
*/
#define BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, rx_entries, out_rx_entry) \
#define BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, rx_entries, out_rx_entry) \
ble_gattc_extract_with_rx_entry( \
(conn_handle), (rx_entries), \
(conn_handle), (cid), (rx_entries), \
sizeof (rx_entries) / sizeof (rx_entries)[0], \
(const void **)(out_rx_entry))
@@ -1290,7 +1340,7 @@ ble_gattc_mtu_tx(struct ble_gattc_proc *proc)
int rc;
ble_hs_lock();
rc = ble_att_conn_chan_find(proc->conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(proc->conn_handle, proc->cid, &conn, &chan);
if (rc == 0) {
mtu = chan->my_mtu;
}
@@ -1319,6 +1369,7 @@ ble_gattc_exchange_mtu(uint16_t conn_handle, ble_gatt_mtu_fn *cb, void *cb_arg)
proc->op = BLE_GATT_OP_MTU;
proc->conn_handle = conn_handle;
proc->cid = BLE_L2CAP_CID_ATT;
proc->mtu.cb = cb;
proc->mtu.cb_arg = cb_arg;
@@ -1395,7 +1446,7 @@ ble_gattc_disc_all_svcs_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
rc = ble_att_clt_tx_read_group_type(proc->conn_handle,
rc = ble_att_clt_tx_read_group_type(proc->conn_handle, proc->cid,
proc->disc_all_svcs.prev_handle + 1,
0xffff, &uuid.u);
if (rc != 0) {
@@ -1541,8 +1592,8 @@ ble_gattc_disc_all_svcs(uint16_t conn_handle, ble_gatt_disc_svc_fn *cb,
goto done;
}
proc->op = BLE_GATT_OP_DISC_ALL_SVCS;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_SVCS);
proc->disc_all_svcs.prev_handle = 0x0000;
proc->disc_all_svcs.cb = cb;
proc->disc_all_svcs.cb_arg = cb_arg;
@@ -1621,7 +1672,7 @@ ble_gattc_disc_svc_uuid_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
ble_uuid_flat(&proc->disc_svc_uuid.service_uuid.u, val);
rc = ble_att_clt_tx_find_type_value(proc->conn_handle,
rc = ble_att_clt_tx_find_type_value(proc->conn_handle, proc->cid,
proc->disc_svc_uuid.prev_handle + 1,
0xffff, BLE_ATT_UUID_PRIMARY_SERVICE,
val,
@@ -1754,8 +1805,8 @@ ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, const ble_uuid_t *uuid,
goto done;
}
proc->op = BLE_GATT_OP_DISC_SVC_UUID;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_SVC_UUID);
ble_uuid_to_any(uuid, &proc->disc_svc_uuid.service_uuid);
proc->disc_svc_uuid.prev_handle = 0x0000;
proc->disc_svc_uuid.cb = cb;
@@ -1836,7 +1887,7 @@ ble_gattc_find_inc_svcs_tx(struct ble_gattc_proc *proc)
if (proc->find_inc_svcs.cur_start == 0) {
/* Find the next included service. */
rc = ble_att_clt_tx_read_type(proc->conn_handle,
rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->cid,
proc->find_inc_svcs.prev_handle + 1,
proc->find_inc_svcs.end_handle, &uuid.u);
if (rc != 0) {
@@ -1844,7 +1895,7 @@ ble_gattc_find_inc_svcs_tx(struct ble_gattc_proc *proc)
}
} else {
/* Read the UUID of the previously found service. */
rc = ble_att_clt_tx_read(proc->conn_handle,
rc = ble_att_clt_tx_read(proc->conn_handle, proc->cid,
proc->find_inc_svcs.cur_start);
if (rc != 0) {
return rc;
@@ -2070,8 +2121,8 @@ ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle,
goto done;
}
proc->op = BLE_GATT_OP_FIND_INC_SVCS;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_FIND_INC_SVCS);
proc->find_inc_svcs.prev_handle = start_handle - 1;
proc->find_inc_svcs.end_handle = end_handle;
proc->find_inc_svcs.cb = cb;
@@ -2150,7 +2201,7 @@ ble_gattc_disc_all_chrs_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
rc = ble_att_clt_tx_read_type(proc->conn_handle,
rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->cid,
proc->disc_all_chrs.prev_handle + 1,
proc->disc_all_chrs.end_handle, &uuid.u);
if (rc != 0) {
@@ -2298,8 +2349,8 @@ ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle,
goto done;
}
proc->op = BLE_GATT_OP_DISC_ALL_CHRS;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_CHRS);
proc->disc_all_chrs.prev_handle = start_handle - 1;
proc->disc_all_chrs.end_handle = end_handle;
proc->disc_all_chrs.cb = cb;
@@ -2378,7 +2429,7 @@ ble_gattc_disc_chr_uuid_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
rc = ble_att_clt_tx_read_type(proc->conn_handle,
rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->cid,
proc->disc_chr_uuid.prev_handle + 1,
proc->disc_chr_uuid.end_handle, &uuid.u);
if (rc != 0) {
@@ -2537,8 +2588,8 @@ ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle,
goto done;
}
proc->op = BLE_GATT_OP_DISC_CHR_UUID;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_CHR_UUID);
ble_uuid_to_any(uuid, &proc->disc_chr_uuid.chr_uuid);
proc->disc_chr_uuid.prev_handle = start_handle - 1;
proc->disc_chr_uuid.end_handle = end_handle;
@@ -2617,7 +2668,7 @@ ble_gattc_disc_all_dscs_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
rc = ble_att_clt_tx_find_info(proc->conn_handle,
rc = ble_att_clt_tx_find_info(proc->conn_handle, proc->cid,
proc->disc_all_dscs.prev_handle + 1,
proc->disc_all_dscs.end_handle);
if (rc != 0) {
@@ -2747,8 +2798,8 @@ ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t start_handle,
goto done;
}
proc->op = BLE_GATT_OP_DISC_ALL_DSCS;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_DSCS);
proc->disc_all_dscs.chr_val_handle = start_handle;
proc->disc_all_dscs.prev_handle = start_handle;
proc->disc_all_dscs.end_handle = end_handle;
@@ -2858,7 +2909,7 @@ ble_gattc_read_tx(struct ble_gattc_proc *proc)
{
int rc;
rc = ble_att_clt_tx_read(proc->conn_handle, proc->read.handle);
rc = ble_att_clt_tx_read(proc->conn_handle, proc->cid, proc->read.handle);
if (rc != 0) {
return rc;
}
@@ -2885,8 +2936,8 @@ ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle,
goto done;
}
proc->op = BLE_GATT_OP_READ;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ);
proc->read.handle = attr_handle;
proc->read.cb = cb;
proc->read.cb_arg = cb_arg;
@@ -3021,7 +3072,7 @@ ble_gattc_read_uuid_rx_complete(struct ble_gattc_proc *proc, int status)
static int
ble_gattc_read_uuid_tx(struct ble_gattc_proc *proc)
{
return ble_att_clt_tx_read_type(proc->conn_handle,
return ble_att_clt_tx_read_type(proc->conn_handle, proc->cid,
proc->read_uuid.start_handle,
proc->read_uuid.end_handle,
&proc->read_uuid.chr_uuid.u);
@@ -3047,8 +3098,8 @@ ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
goto done;
}
proc->op = BLE_GATT_OP_READ_UUID;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ_UUID);
ble_uuid_to_any(uuid, &proc->read_uuid.chr_uuid);
proc->read_uuid.start_handle = start_handle;
proc->read_uuid.end_handle = end_handle;
@@ -3126,12 +3177,12 @@ ble_gattc_read_long_tx(struct ble_gattc_proc *proc)
ble_gattc_dbg_assert_proc_not_inserted(proc);
if (proc->read_long.offset == 0) {
rc = ble_att_clt_tx_read(proc->conn_handle, proc->read_long.handle);
rc = ble_att_clt_tx_read(proc->conn_handle, proc->cid, proc->read_long.handle);
if (rc != 0) {
return rc;
}
} else {
rc = ble_att_clt_tx_read_blob(proc->conn_handle,
rc = ble_att_clt_tx_read_blob(proc->conn_handle, proc->cid,
proc->read_long.handle,
proc->read_long.offset);
if (rc != 0) {
@@ -3202,7 +3253,7 @@ ble_gattc_read_long_rx_read_rsp(struct ble_gattc_proc *proc, int status,
}
/* Determine if this is the end of the attribute value. */
mtu = ble_att_mtu(proc->conn_handle);
mtu = ble_att_mtu_by_cid(proc->conn_handle, proc->cid);
if (mtu == 0) {
/* No longer connected. */
return BLE_HS_EDONE;
@@ -3243,8 +3294,8 @@ ble_gattc_read_long(uint16_t conn_handle, uint16_t handle, uint16_t offset,
goto done;
}
proc->op = BLE_GATT_OP_READ_LONG;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ_LONG);
proc->read_long.handle = handle;
proc->read_long.offset = offset;
proc->read_long.cb = cb;
@@ -3342,7 +3393,7 @@ ble_gattc_read_mult_tx(struct ble_gattc_proc *proc)
{
int rc;
rc = ble_att_clt_tx_read_mult(proc->conn_handle, proc->read_mult.handles,
rc = ble_att_clt_tx_read_mult(proc->conn_handle, proc->cid, proc->read_mult.handles,
proc->read_mult.num_handles);
if (rc != 0) {
return rc;
@@ -3379,8 +3430,8 @@ ble_gattc_read_mult(uint16_t conn_handle, const uint16_t *handles,
goto done;
}
proc->op = BLE_GATT_OP_READ_MULT;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ_MULT);
memcpy(proc->read_mult.handles, handles, num_handles * sizeof *handles);
proc->read_mult.num_handles = num_handles;
proc->read_mult.cb = cb;
@@ -3419,7 +3470,7 @@ ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
ble_gattc_log_write(attr_handle, OS_MBUF_PKTLEN(txom), 0);
rc = ble_att_clt_tx_write_cmd(conn_handle, attr_handle, txom);
rc = ble_att_clt_tx_write_cmd(conn_handle, BLE_L2CAP_CID_ATT, attr_handle, txom);
if (rc != 0) {
STATS_INC(ble_gattc_stats, write);
}
@@ -3525,15 +3576,15 @@ ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle,
goto done;
}
proc->op = BLE_GATT_OP_WRITE;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE);
proc->write.att_handle = attr_handle;
proc->write.cb = cb;
proc->write.cb_arg = cb_arg;
ble_gattc_log_write(attr_handle, OS_MBUF_PKTLEN(txom), 1);
rc = ble_att_clt_tx_write_req(conn_handle, attr_handle, txom);
rc = ble_att_clt_tx_write_req(conn_handle, proc->cid, attr_handle, txom);
txom = NULL;
if (rc != 0) {
goto done;
@@ -3633,7 +3684,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc)
om = NULL;
max_sz = ble_att_mtu(proc->conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
max_sz = ble_att_mtu_by_cid(proc->conn_handle, proc->cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
if (max_sz <= 0) {
/* Not connected. */
rc = BLE_HS_ENOTCONN;
@@ -3645,7 +3696,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc)
proc->write_long.attr.offset);
if (write_len <= 0) {
rc = ble_att_clt_tx_exec_write(proc->conn_handle,
rc = ble_att_clt_tx_exec_write(proc->conn_handle, proc->cid,
BLE_ATT_EXEC_WRITE_F_EXECUTE);
goto done;
}
@@ -3665,7 +3716,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc)
goto done;
}
rc = ble_att_clt_tx_prep_write(proc->conn_handle,
rc = ble_att_clt_tx_prep_write(proc->conn_handle, proc->cid,
proc->write_long.attr.handle,
proc->write_long.attr.offset, om);
om = NULL;
@@ -3709,9 +3760,9 @@ ble_gattc_write_long_err(struct ble_gattc_proc *proc, int status,
*/
if (proc->write_long.attr.offset > 0 &&
proc->write_long.attr.offset <
OS_MBUF_PKTLEN(proc->write_long.attr.om)) {
OS_MBUF_PKTLEN(proc->write_long.attr.om)) {
ble_att_clt_tx_exec_write(proc->conn_handle,
ble_att_clt_tx_exec_write(proc->conn_handle, proc->cid,
BLE_ATT_EXEC_WRITE_F_CANCEL);
}
@@ -3777,7 +3828,8 @@ ble_gattc_write_long_rx_prep(struct ble_gattc_proc *proc,
rc = BLE_HS_EBADDATA;
/* if data doesn't match up send cancel write */
ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_CANCEL);
ble_att_clt_tx_exec_write(proc->conn_handle, proc->cid,
BLE_ATT_EXEC_WRITE_F_CANCEL);
goto err;
} else {
/* Send follow-up request. */
@@ -3838,8 +3890,8 @@ ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle,
goto done;
}
proc->op = BLE_GATT_OP_WRITE_LONG;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE_LONG);
proc->write_long.attr.handle = attr_handle;
proc->write_long.attr.offset = offset;
proc->write_long.attr.om = txom;
@@ -3934,14 +3986,14 @@ ble_gattc_write_reliable_tx(struct ble_gattc_proc *proc)
attr_idx = proc->write_reliable.cur_attr;
if (attr_idx >= proc->write_reliable.num_attrs) {
rc = ble_att_clt_tx_exec_write(proc->conn_handle,
rc = ble_att_clt_tx_exec_write(proc->conn_handle, proc->cid,
BLE_ATT_EXEC_WRITE_F_EXECUTE);
goto done;
}
attr = proc->write_reliable.attrs + attr_idx;
max_sz = ble_att_mtu(proc->conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
max_sz = ble_att_mtu_by_cid(proc->conn_handle, proc->cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
if (max_sz <= 0) {
/* Not connected. */
rc = BLE_HS_ENOTCONN;
@@ -3964,8 +4016,8 @@ ble_gattc_write_reliable_tx(struct ble_gattc_proc *proc)
goto done;
}
rc = ble_att_clt_tx_prep_write(proc->conn_handle, attr->handle,
attr->offset, om);
rc = ble_att_clt_tx_prep_write(proc->conn_handle, proc->cid,
attr->handle, attr->offset, om);
om = NULL;
if (rc != 0) {
goto done;
@@ -4008,7 +4060,7 @@ ble_gattc_write_reliable_err(struct ble_gattc_proc *proc, int status,
*/
if (proc->write_reliable.cur_attr < proc->write_reliable.num_attrs) {
ble_att_clt_tx_exec_write(proc->conn_handle,
ble_att_clt_tx_exec_write(proc->conn_handle, proc->cid,
BLE_ATT_EXEC_WRITE_F_CANCEL);
}
}
@@ -4121,8 +4173,8 @@ ble_gattc_write_reliable(uint16_t conn_handle,
goto done;
}
proc->op = BLE_GATT_OP_WRITE_RELIABLE;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE_RELIABLE);
proc->write_reliable.num_attrs = num_attrs;
proc->write_reliable.cur_attr = 0;
proc->write_reliable.cb = cb;
@@ -4344,8 +4396,8 @@ ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
goto done;
}
proc->op = BLE_GATT_OP_INDICATE;
proc->conn_handle = conn_handle;
ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_INDICATE);
proc->indicate.chr_val_handle = chr_val_handle;
ble_gattc_log_indicate(chr_val_handle);
@@ -4370,7 +4422,7 @@ ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle,
}
}
rc = ble_att_clt_tx_indicate(conn_handle, chr_val_handle, txom);
rc = ble_att_clt_tx_indicate(conn_handle, proc->cid, chr_val_handle, txom);
txom = NULL;
if (rc != 0) {
goto done;
@@ -4431,12 +4483,12 @@ ble_gattc_indicate(uint16_t conn_handle, uint16_t chr_val_handle)
* procedure.
*/
void
ble_gattc_rx_err(uint16_t conn_handle, uint16_t handle, uint16_t status)
ble_gattc_rx_err(uint16_t conn_handle, uint16_t cid, uint16_t handle, uint16_t status)
{
struct ble_gattc_proc *proc;
ble_gattc_err_fn *err_cb;
proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_NONE);
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, BLE_GATT_OP_NONE);
if (proc != NULL) {
err_cb = ble_gattc_err_dispatch_get(proc->op);
if (err_cb != NULL) {
@@ -4451,11 +4503,13 @@ ble_gattc_rx_err(uint16_t conn_handle, uint16_t handle, uint16_t status)
* GATT procedure.
*/
void
ble_gattc_rx_mtu(uint16_t conn_handle, int status, uint16_t chan_mtu)
ble_gattc_rx_mtu(uint16_t conn_handle, uint16_t cid, int status, uint16_t chan_mtu)
{
struct ble_gattc_proc *proc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_MTU);
assert(cid == BLE_L2CAP_CID_ATT);
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, BLE_L2CAP_CID_ATT, BLE_GATT_OP_MTU);
if (proc != NULL) {
ble_gattc_mtu_cb(proc, status, 0, chan_mtu);
ble_gattc_process_status(proc, BLE_HS_EDONE);
@@ -4467,7 +4521,7 @@ ble_gattc_rx_mtu(uint16_t conn_handle, int status, uint16_t chan_mtu)
* find-information-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_find_info_idata(uint16_t conn_handle,
ble_gattc_rx_find_info_idata(uint16_t conn_handle, uint16_t cid,
struct ble_att_find_info_idata *idata)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_INFO
@@ -4477,7 +4531,7 @@ ble_gattc_rx_find_info_idata(uint16_t conn_handle,
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_ALL_DSCS);
if (proc != NULL) {
rc = ble_gattc_disc_all_dscs_rx_idata(proc, idata);
@@ -4490,7 +4544,7 @@ ble_gattc_rx_find_info_idata(uint16_t conn_handle,
* find-information-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status)
ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, int status)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_INFO
return;
@@ -4499,8 +4553,8 @@ ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status)
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
BLE_GATT_OP_DISC_ALL_DSCS);
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_ALL_DSCS);
if (proc != NULL) {
rc = ble_gattc_disc_all_dscs_rx_complete(proc, status);
ble_gattc_process_status(proc, rc);
@@ -4512,7 +4566,7 @@ ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status)
* find-by-type-value-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle,
ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle, uint16_t cid,
struct ble_att_find_type_value_hinfo *hinfo)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_TYPE
@@ -4522,7 +4576,7 @@ ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle,
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_SVC_UUID);
if (proc != NULL) {
rc = ble_gattc_disc_svc_uuid_rx_hinfo(proc, hinfo);
@@ -4535,7 +4589,7 @@ ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle,
* find-by-type-value-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status)
ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, uint16_t cid, int status)
{
#if !NIMBLE_BLE_ATT_CLT_FIND_TYPE
return;
@@ -4544,8 +4598,8 @@ ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status)
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
BLE_GATT_OP_DISC_SVC_UUID);
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_SVC_UUID);
if (proc != NULL) {
rc = ble_gattc_disc_svc_uuid_rx_complete(proc, status);
ble_gattc_process_status(proc, rc);
@@ -4557,7 +4611,7 @@ ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status)
* to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_read_type_adata(uint16_t conn_handle,
ble_gattc_rx_read_type_adata(uint16_t conn_handle, uint16_t cid,
struct ble_att_read_type_adata *adata)
{
#if !NIMBLE_BLE_ATT_CLT_READ_TYPE
@@ -4568,7 +4622,7 @@ ble_gattc_rx_read_type_adata(uint16_t conn_handle,
struct ble_gattc_proc *proc;
int rc;
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle,
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid,
ble_gattc_rx_read_type_elem_entries,
&rx_entry);
if (proc != NULL) {
@@ -4582,7 +4636,7 @@ ble_gattc_rx_read_type_adata(uint16_t conn_handle,
* the appropriate active GATT procedure.
*/
void
ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status)
ble_gattc_rx_read_type_complete(uint16_t conn_handle, uint16_t cid, int status)
{
#if !NIMBLE_BLE_ATT_CLT_READ_TYPE
return;
@@ -4593,7 +4647,7 @@ ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status)
int rc;
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(
conn_handle, ble_gattc_rx_read_type_complete_entries,
conn_handle, cid, ble_gattc_rx_read_type_complete_entries,
&rx_entry);
if (proc != NULL) {
rc = rx_entry->cb(proc, status);
@@ -4606,7 +4660,7 @@ ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status)
* read-by-group-type-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_read_group_type_adata(uint16_t conn_handle,
ble_gattc_rx_read_group_type_adata(uint16_t conn_handle, uint16_t cid,
struct ble_att_read_group_type_adata *adata)
{
#if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE
@@ -4616,7 +4670,7 @@ ble_gattc_rx_read_group_type_adata(uint16_t conn_handle,
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_ALL_SVCS);
if (proc != NULL) {
rc = ble_gattc_disc_all_svcs_rx_adata(proc, adata);
@@ -4629,7 +4683,7 @@ ble_gattc_rx_read_group_type_adata(uint16_t conn_handle,
* read-by-group-type-response to the appropriate active GATT procedure.
*/
void
ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int status)
ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, uint16_t cid, int status)
{
#if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE
return;
@@ -4638,8 +4692,8 @@ ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int status)
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
BLE_GATT_OP_DISC_ALL_SVCS);
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_DISC_ALL_SVCS);
if (proc != NULL) {
rc = ble_gattc_disc_all_svcs_rx_complete(proc, status);
ble_gattc_process_status(proc, rc);
@@ -4651,7 +4705,7 @@ ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int status)
* procedure.
*/
void
ble_gattc_rx_read_rsp(uint16_t conn_handle, int status, struct os_mbuf **om)
ble_gattc_rx_read_rsp(uint16_t conn_handle, uint16_t cid, int status, struct os_mbuf **om)
{
#if !NIMBLE_BLE_ATT_CLT_READ
return;
@@ -4661,7 +4715,7 @@ ble_gattc_rx_read_rsp(uint16_t conn_handle, int status, struct os_mbuf **om)
struct ble_gattc_proc *proc;
int rc;
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle,
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid,
ble_gattc_rx_read_rsp_entries,
&rx_entry);
if (proc != NULL) {
@@ -4675,7 +4729,7 @@ ble_gattc_rx_read_rsp(uint16_t conn_handle, int status, struct os_mbuf **om)
* procedure.
*/
void
ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status,
struct os_mbuf **om)
{
#if !NIMBLE_BLE_ATT_CLT_READ_BLOB
@@ -4685,7 +4739,7 @@ ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
struct ble_gattc_proc *proc;
int rc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_READ_LONG);
if (proc != NULL) {
rc = ble_gattc_read_long_rx_read_rsp(proc, status, om);
@@ -4698,7 +4752,7 @@ ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status,
* GATT procedure.
*/
void
ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status,
struct os_mbuf **om)
{
#if !NIMBLE_BLE_ATT_CLT_READ_MULT
@@ -4707,7 +4761,7 @@ ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
struct ble_gattc_proc *proc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_READ_MULT);
if (proc != NULL) {
ble_gattc_read_mult_cb(proc, status, 0, om);
@@ -4720,7 +4774,7 @@ ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status,
* procedure.
*/
void
ble_gattc_rx_write_rsp(uint16_t conn_handle)
ble_gattc_rx_write_rsp(uint16_t conn_handle, uint16_t cid)
{
#if !NIMBLE_BLE_ATT_CLT_WRITE
return;
@@ -4728,7 +4782,7 @@ ble_gattc_rx_write_rsp(uint16_t conn_handle)
struct ble_gattc_proc *proc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_WRITE);
if (proc != NULL) {
ble_gattc_write_cb(proc, 0, 0);
@@ -4741,7 +4795,7 @@ ble_gattc_rx_write_rsp(uint16_t conn_handle)
* GATT procedure.
*/
void
ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, uint16_t cid, int status,
uint16_t handle, uint16_t offset,
struct os_mbuf **om)
{
@@ -4753,7 +4807,7 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
struct ble_gattc_proc *proc;
int rc;
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle,
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid,
ble_gattc_rx_prep_entries,
&rx_entry);
if (proc != NULL) {
@@ -4767,7 +4821,7 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
* GATT procedure.
*/
void
ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, uint16_t cid, int status)
{
#if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE
return;
@@ -4777,7 +4831,7 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
struct ble_gattc_proc *proc;
int rc;
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle,
proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid,
ble_gattc_rx_exec_entries, &rx_entry);
if (proc != NULL) {
rc = rx_entry->cb(proc, status);
@@ -4790,7 +4844,7 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status)
* active GATT procedure.
*/
void
ble_gatts_rx_indicate_rsp(uint16_t conn_handle)
ble_gatts_rx_indicate_rsp(uint16_t conn_handle, uint16_t cid)
{
#if !NIMBLE_BLE_ATT_CLT_INDICATE
return;
@@ -4798,7 +4852,7 @@ ble_gatts_rx_indicate_rsp(uint16_t conn_handle)
struct ble_gattc_proc *proc;
proc = ble_gattc_extract_first_by_conn_op(conn_handle,
proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid,
BLE_GATT_OP_INDICATE);
if (proc != NULL) {
ble_gatts_indicate_rx_rsp(proc);
+1
View File
@@ -193,6 +193,7 @@ ble_hs_conn_alloc(uint16_t conn_handle)
}
STAILQ_INIT(&conn->bhc_tx_q);
STAILQ_INIT(&conn->att_tx_q);
STATS_INC(ble_hs_stats, conn_create);
+3
View File
@@ -102,6 +102,9 @@ struct ble_hs_conn {
#if MYNEWT_VAL(BLE_PERIODIC_ADV)
struct ble_hs_periodic_sync *psync;
#endif
STAILQ_HEAD(, os_mbuf_pkthdr) att_tx_q;
bool client_att_busy;
};
struct ble_hs_conn_addrs {
+16 -16
View File
@@ -67,9 +67,9 @@ ble_att_clt_test_tx_write_req_or_cmd(uint16_t conn_handle, uint16_t handle,
om = ble_hs_test_util_om_from_flat(value, value_len);
if (is_req) {
rc = ble_att_clt_tx_write_req(conn_handle, handle, om);
rc = ble_att_clt_tx_write_req(conn_handle, BLE_L2CAP_CID_ATT, handle, om);
} else {
rc = ble_att_clt_tx_write_cmd(conn_handle, handle, om);
rc = ble_att_clt_tx_write_cmd(conn_handle, BLE_L2CAP_CID_ATT, handle, om);
}
TEST_ASSERT(rc == 0);
}
@@ -84,19 +84,19 @@ TEST_CASE_SELF(ble_att_clt_test_tx_find_info)
conn_handle = ble_att_clt_test_misc_init();
/*** Success. */
rc = ble_att_clt_tx_find_info(conn_handle, 1, 0xffff);
rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 1, 0xffff);
TEST_ASSERT(rc == 0);
/*** Error: start handle of 0. */
rc = ble_att_clt_tx_find_info(conn_handle, 0, 0xffff);
rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 0, 0xffff);
TEST_ASSERT(rc == BLE_HS_EINVAL);
/*** Error: start handle greater than end handle. */
rc = ble_att_clt_tx_find_info(conn_handle, 500, 499);
rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 500, 499);
TEST_ASSERT(rc == BLE_HS_EINVAL);
/*** Success; start and end handles equal. */
rc = ble_att_clt_tx_find_info(conn_handle, 500, 500);
rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 500, 500);
TEST_ASSERT(rc == 0);
ble_hs_test_util_assert_mbufs_freed(NULL);
@@ -206,7 +206,7 @@ ble_att_clt_test_misc_prep_good(uint16_t handle, uint16_t offset,
conn_handle = ble_att_clt_test_misc_init();
om = ble_hs_test_util_om_from_flat(attr_data, attr_data_len);
rc = ble_att_clt_tx_prep_write(conn_handle, handle, offset, om);
rc = ble_att_clt_tx_prep_write(conn_handle, BLE_L2CAP_CID_ATT, handle, offset, om);
TEST_ASSERT(rc == 0);
om = ble_hs_test_util_prev_tx_dequeue_pullup();
@@ -232,7 +232,7 @@ ble_att_clt_test_misc_exec_good(uint8_t flags)
conn_handle = ble_att_clt_test_misc_init();
rc = ble_att_clt_tx_exec_write(conn_handle, flags);
rc = ble_att_clt_tx_exec_write(conn_handle, BLE_L2CAP_CID_ATT, flags);
TEST_ASSERT(rc == 0);
om = ble_hs_test_util_prev_tx_dequeue_pullup();
@@ -256,7 +256,7 @@ ble_att_clt_test_misc_prep_bad(uint16_t handle, uint16_t offset,
om = ble_hs_test_util_om_from_flat(attr_data, attr_data_len);
rc = ble_att_clt_tx_prep_write(conn_handle, handle, offset, om);
rc = ble_att_clt_tx_prep_write(conn_handle, BLE_L2CAP_CID_ATT, handle, offset, om);
TEST_ASSERT(rc == status);
}
@@ -287,11 +287,11 @@ TEST_CASE_SELF(ble_att_clt_test_tx_read)
conn_handle = ble_att_clt_test_misc_init();
/*** Success. */
rc = ble_att_clt_tx_read(conn_handle, 1);
rc = ble_att_clt_tx_read(conn_handle, BLE_L2CAP_CID_ATT, 1);
TEST_ASSERT(rc == 0);
/*** Error: handle of 0. */
rc = ble_att_clt_tx_read(conn_handle, 0);
rc = ble_att_clt_tx_read(conn_handle, BLE_L2CAP_CID_ATT, 0);
TEST_ASSERT(rc == BLE_HS_EINVAL);
ble_hs_test_util_assert_mbufs_freed(NULL);
@@ -333,11 +333,11 @@ TEST_CASE_SELF(ble_att_clt_test_tx_read_blob)
conn_handle = ble_att_clt_test_misc_init();
/*** Success. */
rc = ble_att_clt_tx_read_blob(conn_handle, 1, 0);
rc = ble_att_clt_tx_read_blob(conn_handle, BLE_L2CAP_CID_ATT, 1, 0);
TEST_ASSERT(rc == 0);
/*** Error: handle of 0. */
rc = ble_att_clt_tx_read_blob(conn_handle, 0, 0);
rc = ble_att_clt_tx_read_blob(conn_handle, BLE_L2CAP_CID_ATT, 0, 0);
TEST_ASSERT(rc == BLE_HS_EINVAL);
ble_hs_test_util_assert_mbufs_freed(NULL);
@@ -380,7 +380,7 @@ TEST_CASE_SELF(ble_att_clt_test_tx_read_mult)
conn_handle = ble_att_clt_test_misc_init();
/*** Success. */
rc = ble_att_clt_tx_read_mult(conn_handle, ((uint16_t[]){ 1, 2 }), 2);
rc = ble_att_clt_tx_read_mult(conn_handle, BLE_L2CAP_CID_ATT, ((uint16_t[]){ 1, 2 }), 2);
TEST_ASSERT(rc == 0);
om = ble_hs_test_util_prev_tx_dequeue_pullup();
@@ -392,7 +392,7 @@ TEST_CASE_SELF(ble_att_clt_test_tx_read_mult)
TEST_ASSERT(get_le16(om->om_data + BLE_ATT_READ_MULT_REQ_BASE_SZ + 2) == 2);
/*** Error: no handles. */
rc = ble_att_clt_tx_read_mult(conn_handle, NULL, 0);
rc = ble_att_clt_tx_read_mult(conn_handle, BLE_L2CAP_CID_ATT, NULL, 0);
TEST_ASSERT(rc == BLE_HS_EINVAL);
ble_hs_test_util_assert_mbufs_freed(NULL);
@@ -508,7 +508,7 @@ TEST_CASE_SELF(ble_att_clt_test_tx_exec_write)
ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_EXECUTE);
/*** Success: nonzero == execute. */
rc = ble_att_clt_tx_exec_write(conn_handle, 0x02);
rc = ble_att_clt_tx_exec_write(conn_handle, BLE_L2CAP_CID_ATT, 0x02);
TEST_ASSERT(rc == 0);
ble_hs_test_util_assert_mbufs_freed(NULL);
+14 -13
View File
@@ -24,6 +24,7 @@
#include "nimble/hci_common.h"
#include "ble_hs_test.h"
#include "host/ble_uuid.h"
#include "host/ble_l2cap.h"
#include "ble_hs_test_util.h"
static uint8_t *ble_att_svr_test_attr_r_1;
@@ -478,7 +479,7 @@ ble_att_svr_test_misc_verify_all_read_mult(
}
static void
ble_att_svr_test_misc_verify_tx_mtu_rsp(uint16_t conn_handle)
ble_att_svr_test_misc_verify_tx_mtu_rsp(uint16_t conn_handle, uint16_t cid)
{
struct ble_l2cap_chan *chan;
struct ble_hs_conn *conn;
@@ -487,7 +488,7 @@ ble_att_svr_test_misc_verify_tx_mtu_rsp(uint16_t conn_handle)
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, cid, &conn, &chan);
assert(rc == 0);
my_mtu = chan->my_mtu;
@@ -644,7 +645,7 @@ ble_att_svr_test_misc_mtu_exchange(uint16_t my_mtu, uint16_t peer_sent,
buf, sizeof buf);
TEST_ASSERT(rc == 0);
ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle);
ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle, BLE_L2CAP_CID_ATT);
ble_hs_lock();
rc = ble_hs_misc_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT,
@@ -1138,19 +1139,19 @@ TEST_CASE_SELF(ble_att_svr_test_find_info)
conn_handle = ble_att_svr_test_misc_init(128);
/*** Start handle of 0. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 0, 0);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, 0, 0);
TEST_ASSERT(rc != 0);
ble_hs_test_util_verify_tx_err_rsp(
BLE_ATT_OP_FIND_INFO_REQ, 0, BLE_ATT_ERR_INVALID_HANDLE);
/*** Start handle > end handle. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 101, 100);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, 101, 100);
TEST_ASSERT(rc != 0);
ble_hs_test_util_verify_tx_err_rsp(
BLE_ATT_OP_FIND_INFO_REQ, 101, BLE_ATT_ERR_INVALID_HANDLE);
/*** No attributes. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 200, 300);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, 200, 300);
TEST_ASSERT(rc != 0);
ble_hs_test_util_verify_tx_err_rsp(
BLE_ATT_OP_FIND_INFO_REQ, 200, BLE_ATT_ERR_ATTR_NOT_FOUND);
@@ -1160,13 +1161,13 @@ TEST_CASE_SELF(ble_att_svr_test_find_info)
ble_att_svr_test_misc_attr_fn_r_1, NULL);
TEST_ASSERT(rc == 0);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 200, 300);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, 200, 300);
TEST_ASSERT(rc != 0);
ble_hs_test_util_verify_tx_err_rsp(
BLE_ATT_OP_FIND_INFO_REQ, 200, BLE_ATT_ERR_ATTR_NOT_FOUND);
/*** One 128-bit entry. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle1);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, handle1, handle1);
TEST_ASSERT(rc == 0);
ble_hs_test_util_verify_tx_find_info_rsp(
((struct ble_hs_test_util_att_info_entry[]) { {
@@ -1181,7 +1182,7 @@ TEST_CASE_SELF(ble_att_svr_test_find_info)
ble_att_svr_test_misc_attr_fn_r_1, NULL);
TEST_ASSERT(rc == 0);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle2);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, handle1, handle2);
TEST_ASSERT(rc == 0);
ble_hs_test_util_verify_tx_find_info_rsp(
((struct ble_hs_test_util_att_info_entry[]) { {
@@ -1199,7 +1200,7 @@ TEST_CASE_SELF(ble_att_svr_test_find_info)
ble_att_svr_test_misc_attr_fn_r_1, NULL);
TEST_ASSERT(rc == 0);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle3);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, handle1, handle3);
TEST_ASSERT(rc == 0);
ble_hs_test_util_verify_tx_find_info_rsp(
((struct ble_hs_test_util_att_info_entry[]) { {
@@ -1213,7 +1214,7 @@ TEST_CASE_SELF(ble_att_svr_test_find_info)
} }));
/*** Remaining 16-bit entry requested. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle3, handle3);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, handle3, handle3);
TEST_ASSERT(rc == 0);
ble_hs_test_util_verify_tx_find_info_rsp(
((struct ble_hs_test_util_att_info_entry[]) { {
@@ -1936,13 +1937,13 @@ TEST_CASE_SELF(ble_att_svr_test_oom)
TEST_ASSERT_FATAL(rc == 0);
/* Ensure we were able to send a real response. */
ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle);
ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle, BLE_L2CAP_CID_ATT);
/*** Find information; always respond affirmatively, even when no mbufs. */
ble_hs_test_util_prev_tx_dequeue();
/* Receive a request. */
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 1, 100);
rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, BLE_L2CAP_CID_ATT, 1, 100);
TEST_ASSERT_FATAL(rc == 0);
/* Ensure we were able to send a real response. */
+17 -15
View File
@@ -25,6 +25,7 @@
#include "ble_hs_test.h"
#include "host/ble_gatt.h"
#include "host/ble_uuid.h"
#include "host/ble_l2cap.h"
#include "ble_hs_test_util.h"
struct ble_gatt_disc_c_test_char {
@@ -50,8 +51,8 @@ ble_gatt_disc_c_test_init(void)
}
static int
ble_gatt_disc_c_test_misc_rx_rsp_once(
uint16_t conn_handle, struct ble_gatt_disc_c_test_char *chars)
ble_gatt_disc_c_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_c_test_char *chars)
{
struct ble_att_read_type_rsp rsp;
uint8_t buf[1024];
@@ -86,14 +87,14 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(
if (chars[i].uuid->type == BLE_UUID_TYPE_16) {
if (off + BLE_ATT_READ_TYPE_ADATA_SZ_16 >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
}
} else {
if (off + BLE_ATT_READ_TYPE_ADATA_SZ_128 >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
@@ -121,7 +122,7 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(
}
static void
ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle,
ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t end_handle,
struct ble_gatt_disc_c_test_char *chars)
{
@@ -130,7 +131,7 @@ ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle,
idx = 0;
while (chars[idx].def_handle != 0) {
count = ble_gatt_disc_c_test_misc_rx_rsp_once(conn_handle,
count = ble_gatt_disc_c_test_misc_rx_rsp_once(conn_handle, cid,
chars + idx);
if (count == 0) {
break;
@@ -140,7 +141,8 @@ ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle,
if (chars[idx - 1].def_handle != end_handle) {
/* Send the pending ATT Request. */
ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_TYPE_REQ,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
chars[idx - 1].def_handle);
}
@@ -229,7 +231,7 @@ ble_gatt_disc_c_test_misc_all(uint16_t start_handle, uint16_t end_handle,
ble_gatt_disc_c_test_misc_cb, &num_left);
TEST_ASSERT(rc == 0);
ble_gatt_disc_c_test_misc_rx_rsp(2, end_handle, chars);
ble_gatt_disc_c_test_misc_rx_rsp(2, BLE_L2CAP_CID_ATT, end_handle, chars);
ble_gatt_disc_c_test_misc_verify_chars(chars, stop_after);
}
@@ -252,7 +254,7 @@ ble_gatt_disc_c_test_misc_uuid(uint16_t start_handle, uint16_t end_handle,
&stop_after);
TEST_ASSERT(rc == 0);
ble_gatt_disc_c_test_misc_rx_rsp(2, end_handle, rsp_chars);
ble_gatt_disc_c_test_misc_rx_rsp(2, BLE_L2CAP_CID_ATT, end_handle, rsp_chars);
ble_gatt_disc_c_test_misc_verify_chars(ret_chars, 0);
}
@@ -574,7 +576,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs);
num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, chrs);
/* Make sure there are still undiscovered characteristics. */
TEST_ASSERT_FATAL(num_chrs < sizeof chrs / sizeof chrs[0] - 1);
@@ -598,7 +600,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs + num_chrs);
ble_gatt_disc_c_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, chrs + num_chrs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -617,7 +619,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_all)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
@@ -663,7 +665,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_uuid)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs);
num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, chrs);
/* Make sure there are still undiscovered characteristics. */
TEST_ASSERT_FATAL(num_chrs < sizeof chrs / sizeof chrs[0] - 1);
@@ -686,7 +688,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_uuid)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs + num_chrs);
ble_gatt_disc_c_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, chrs + num_chrs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -704,7 +706,7 @@ TEST_CASE_SELF(ble_gatt_disc_c_test_oom_uuid)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
+13 -11
View File
@@ -49,8 +49,8 @@ ble_gatt_disc_d_test_init(void)
}
static int
ble_gatt_disc_d_test_misc_rx_rsp_once(
uint16_t conn_handle, struct ble_gatt_disc_d_test_dsc *dscs)
ble_gatt_disc_d_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_d_test_dsc *dscs)
{
struct ble_att_find_info_rsp rsp;
uint8_t buf[1024];
@@ -77,14 +77,14 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(
if (dscs[i].dsc_uuid.u.type == BLE_UUID_TYPE_16) {
if (off + BLE_ATT_FIND_INFO_IDATA_16_SZ >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
}
} else {
if (off + BLE_ATT_FIND_INFO_IDATA_128_SZ >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
@@ -104,7 +104,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(
off += ble_uuid_length(&dscs[i].dsc_uuid.u);
}
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, off);
TEST_ASSERT(rc == 0);
@@ -113,6 +113,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(
static void
ble_gatt_disc_d_test_misc_rx_rsp(uint16_t conn_handle,
uint16_t cid,
uint16_t end_handle,
struct ble_gatt_disc_d_test_dsc *dscs)
{
@@ -121,7 +122,7 @@ ble_gatt_disc_d_test_misc_rx_rsp(uint16_t conn_handle,
idx = 0;
while (dscs[idx].chr_val_handle != 0) {
count = ble_gatt_disc_d_test_misc_rx_rsp_once(conn_handle, dscs + idx);
count = ble_gatt_disc_d_test_misc_rx_rsp_once(conn_handle, cid, dscs + idx);
if (count == 0) {
break;
}
@@ -130,7 +131,8 @@ ble_gatt_disc_d_test_misc_rx_rsp(uint16_t conn_handle,
if (dscs[idx - 1].dsc_handle != end_handle) {
/* Send the pending ATT Request. */
ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_FIND_INFO_REQ,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid,
BLE_ATT_OP_FIND_INFO_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
end_handle);
}
@@ -223,7 +225,7 @@ ble_gatt_disc_d_test_misc_all(uint16_t chr_val_handle, uint16_t end_handle,
ble_gatt_disc_d_test_misc_cb, &num_left);
TEST_ASSERT(rc == 0);
ble_gatt_disc_d_test_misc_rx_rsp(2, end_handle, dscs);
ble_gatt_disc_d_test_misc_rx_rsp(2, BLE_L2CAP_CID_ATT, end_handle, dscs);
ble_gatt_disc_d_test_misc_verify_dscs(dscs, stop_after);
}
@@ -389,7 +391,7 @@ TEST_CASE_SELF(ble_gatt_disc_d_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
num_dscs = ble_gatt_disc_d_test_misc_rx_rsp_once(1, dscs);
num_dscs = ble_gatt_disc_d_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, dscs);
/* Make sure there are still undiscovered services. */
TEST_ASSERT_FATAL(num_dscs < sizeof dscs / sizeof dscs[0] - 1);
@@ -412,7 +414,7 @@ TEST_CASE_SELF(ble_gatt_disc_d_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_d_test_misc_rx_rsp_once(1, dscs + num_dscs);
ble_gatt_disc_d_test_misc_rx_rsp_once(1, BLE_L2CAP_CID_ATT, dscs + num_dscs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -430,7 +432,7 @@ TEST_CASE_SELF(ble_gatt_disc_d_test_oom_all)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
+26 -26
View File
@@ -56,8 +56,8 @@ ble_gatt_disc_s_test_misc_svc_length(struct ble_gatt_disc_s_test_svc *service)
}
static int
ble_gatt_disc_s_test_misc_rx_all_rsp_once(
uint16_t conn_handle, struct ble_gatt_disc_s_test_svc *services)
ble_gatt_disc_s_test_misc_rx_all_rsp_once(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_s_test_svc *services)
{
struct ble_att_read_group_type_rsp rsp;
uint8_t buf[1024];
@@ -86,14 +86,14 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(
if (services[i].uuid->type == BLE_UUID_TYPE_16) {
if (off + BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_16 >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
}
} else {
if (off + BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_128 >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle,cid)) {
/* Can't fit any more entries. */
break;
@@ -110,7 +110,7 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(
off += ble_uuid_length(services[i].uuid);
}
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, off);
TEST_ASSERT(rc == 0);
@@ -118,22 +118,22 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(
}
static void
ble_gatt_disc_s_test_misc_rx_all_rsp(
uint16_t conn_handle, struct ble_gatt_disc_s_test_svc *services)
ble_gatt_disc_s_test_misc_rx_all_rsp(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_s_test_svc *services)
{
int count;
int idx;
idx = 0;
while (services[idx].start_handle != 0) {
count = ble_gatt_disc_s_test_misc_rx_all_rsp_once(conn_handle,
count = ble_gatt_disc_s_test_misc_rx_all_rsp_once(conn_handle, cid,
services + idx);
idx += count;
}
if (services[idx - 1].end_handle != 0xffff) {
/* Send the pending ATT Request. */
ble_hs_test_util_rx_att_err_rsp(conn_handle,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid,
BLE_ATT_OP_READ_GROUP_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
services[idx - 1].start_handle);
@@ -141,8 +141,8 @@ ble_gatt_disc_s_test_misc_rx_all_rsp(
}
static int
ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
uint16_t conn_handle, struct ble_gatt_disc_s_test_svc *services)
ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_s_test_svc *services)
{
uint8_t buf[1024];
int off;
@@ -160,7 +160,7 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
}
if (off + BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ >
ble_att_mtu(conn_handle)) {
ble_att_mtu_by_cid(conn_handle, cid)) {
/* Can't fit any more entries. */
break;
@@ -173,7 +173,7 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
off += 2;
}
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, off);
TEST_ASSERT(rc == 0);
@@ -181,22 +181,22 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(
}
static void
ble_gatt_disc_s_test_misc_rx_uuid_rsp(
uint16_t conn_handle, struct ble_gatt_disc_s_test_svc *services)
ble_gatt_disc_s_test_misc_rx_uuid_rsp(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_disc_s_test_svc *services)
{
int count;
int idx;
idx = 0;
while (services[idx].start_handle != 0) {
count = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(conn_handle,
count = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(conn_handle, cid,
services + idx);
idx += count;
}
if (services[idx - 1].end_handle != 0xffff) {
/* Send the pending ATT Request. */
ble_hs_test_util_rx_att_err_rsp(conn_handle,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid,
BLE_ATT_OP_FIND_TYPE_VALUE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
services[idx - 1].start_handle);
@@ -269,7 +269,7 @@ ble_gatt_disc_s_test_misc_good_all(struct ble_gatt_disc_s_test_svc *services)
rc = ble_gattc_disc_all_svcs(2, ble_gatt_disc_s_test_misc_disc_cb, NULL);
TEST_ASSERT(rc == 0);
ble_gatt_disc_s_test_misc_rx_all_rsp(2, services);
ble_gatt_disc_s_test_misc_rx_all_rsp(2, BLE_L2CAP_CID_ATT, services);
ble_gatt_disc_s_test_misc_verify_services(services);
}
@@ -290,7 +290,7 @@ ble_gatt_disc_s_test_misc_good_uuid(
ble_hs_test_util_verify_tx_disc_svc_uuid(services[0].uuid);
ble_gatt_disc_s_test_misc_rx_uuid_rsp(2, services);
ble_gatt_disc_s_test_misc_rx_uuid_rsp(2, BLE_L2CAP_CID_ATT, services);
ble_gatt_disc_s_test_misc_verify_services(services);
}
@@ -425,7 +425,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
num_svcs = ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, svcs);
num_svcs = ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, BLE_L2CAP_CID_ATT, svcs);
/* Make sure there are still undiscovered services. */
TEST_ASSERT_FATAL(num_svcs < sizeof svcs / sizeof svcs[0] - 1);
@@ -448,7 +448,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_all)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, svcs + num_svcs);
ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, BLE_L2CAP_CID_ATT, svcs + num_svcs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -465,7 +465,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_all)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_GROUP_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
@@ -504,7 +504,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_uuid)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
num_svcs = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, svcs);
num_svcs = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, BLE_L2CAP_CID_ATT, svcs);
/* Make sure there are still undiscovered services. */
TEST_ASSERT_FATAL(num_svcs < sizeof svcs / sizeof svcs[0] - 1);
@@ -527,7 +527,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_uuid)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, svcs + num_svcs);
ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, BLE_L2CAP_CID_ATT, svcs + num_svcs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -545,7 +545,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_uuid)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_GROUP_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
@@ -579,7 +579,7 @@ TEST_CASE_SELF(ble_gatt_disc_s_test_oom_timeout)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, svcs);
ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, BLE_L2CAP_CID_ATT, svcs);
/* Keep trying to resume for 30 seconds, but never free any mbufs. Verify
* procedure eventually times out.
+19 -18
View File
@@ -90,8 +90,8 @@ ble_gatt_find_s_test_misc_verify_incs(
}
static int
ble_gatt_find_s_test_misc_rx_read_type(
uint16_t conn_handle, struct ble_gatt_find_s_test_entry *entries)
ble_gatt_find_s_test_misc_rx_read_type(uint16_t conn_handle, uint16_t cid,
struct ble_gatt_find_s_test_entry *entries)
{
struct ble_att_read_type_rsp rsp;
uint8_t buf[1024];
@@ -134,14 +134,15 @@ ble_gatt_find_s_test_misc_rx_read_type(
}
if (i == 0) {
ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_TYPE_REQ,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND, 0);
return 0;
}
ble_att_read_type_rsp_write(buf + 0, BLE_ATT_READ_TYPE_RSP_BASE_SZ, &rsp);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, off);
TEST_ASSERT(rc == 0);
@@ -149,7 +150,7 @@ ble_gatt_find_s_test_misc_rx_read_type(
}
static void
ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, const ble_uuid_t *uuid)
ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, uint16_t cid, const ble_uuid_t *uuid)
{
uint8_t buf[17];
int rc;
@@ -159,7 +160,7 @@ ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, const ble_uuid_t *uuid)
buf[0] = BLE_ATT_OP_READ_RSP;
ble_uuid_flat(uuid, buf + 1);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, 17);
TEST_ASSERT(rc == 0);
}
@@ -200,7 +201,7 @@ ble_gatt_find_s_test_misc_verify_tx_read(uint16_t handle)
}
static void
ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle,
ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, uint16_t cid,
uint16_t start_handle, uint16_t end_handle,
struct ble_gatt_find_s_test_entry *entries)
{
@@ -219,7 +220,7 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle,
idx = 0;
while (1) {
ble_gatt_find_s_test_misc_verify_tx_read_type(cur_start, end_handle);
num_found = ble_gatt_find_s_test_misc_rx_read_type(conn_handle,
num_found = ble_gatt_find_s_test_misc_rx_read_type(conn_handle, cid,
entries + idx);
if (num_found == 0) {
break;
@@ -229,7 +230,7 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle,
TEST_ASSERT(num_found == 1);
ble_gatt_find_s_test_misc_verify_tx_read(
entries[idx].start_handle);
ble_gatt_find_s_test_misc_rx_read(conn_handle,
ble_gatt_find_s_test_misc_rx_read(conn_handle, cid,
entries[idx].uuid);
}
@@ -255,7 +256,7 @@ TEST_CASE_SELF(ble_gatt_find_s_test_1)
ble_gatt_find_s_test_misc_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
NULL, NULL);
ble_gatt_find_s_test_misc_find_inc(2, 5, 10,
ble_gatt_find_s_test_misc_find_inc(2, BLE_L2CAP_CID_ATT, 5, 10,
((struct ble_gatt_find_s_test_entry[]) { {
.inc_handle = 6,
.start_handle = 35,
@@ -275,7 +276,7 @@ TEST_CASE_SELF(ble_gatt_find_s_test_1)
ble_gatt_find_s_test_misc_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
NULL, NULL);
ble_gatt_find_s_test_misc_find_inc(2, 34, 100,
ble_gatt_find_s_test_misc_find_inc(2, BLE_L2CAP_CID_ATT, 34, 100,
((struct ble_gatt_find_s_test_entry[]) { {
.inc_handle = 36,
.start_handle = 403,
@@ -290,7 +291,7 @@ TEST_CASE_SELF(ble_gatt_find_s_test_1)
ble_gatt_find_s_test_misc_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
NULL, NULL);
ble_gatt_find_s_test_misc_find_inc(2, 34, 100,
ble_gatt_find_s_test_misc_find_inc(2, BLE_L2CAP_CID_ATT, 34, 100,
((struct ble_gatt_find_s_test_entry[]) { {
.inc_handle = 36,
.start_handle = 403,
@@ -310,7 +311,7 @@ TEST_CASE_SELF(ble_gatt_find_s_test_1)
ble_gatt_find_s_test_misc_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
NULL, NULL);
ble_gatt_find_s_test_misc_find_inc(2, 1, 100,
ble_gatt_find_s_test_misc_find_inc(2, BLE_L2CAP_CID_ATT, 1, 100,
((struct ble_gatt_find_s_test_entry[]) { {
.inc_handle = 36,
.start_handle = 403,
@@ -379,7 +380,7 @@ TEST_CASE_SELF(ble_gatt_find_s_test_oom)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_find_s_test_misc_rx_read_type(1, incs);
ble_gatt_find_s_test_misc_rx_read_type(1, BLE_L2CAP_CID_ATT, incs);
/* Ensure no follow-up request got sent. It should not have gotten sent
* due to mbuf exhaustion.
@@ -402,11 +403,11 @@ TEST_CASE_SELF(ble_gatt_find_s_test_oom)
* follow-up request, so there is always an mbuf available.
*/
/* XXX: Find a way to test this. */
ble_gatt_find_s_test_misc_rx_read(1, incs[0].uuid);
ble_gatt_find_s_test_misc_rx_read(1, BLE_L2CAP_CID_ATT, incs[0].uuid);
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_find_s_test_misc_rx_read_type(1, incs + 1);
ble_gatt_find_s_test_misc_rx_read_type(1, BLE_L2CAP_CID_ATT, incs + 1);
/* Verify the procedure succeeds after mbufs become available. */
rc = os_mbuf_free_chain(oms);
@@ -414,9 +415,9 @@ TEST_CASE_SELF(ble_gatt_find_s_test_oom)
os_time_advance(ticks_until);
ble_gattc_timer();
ble_gatt_find_s_test_misc_rx_read(1, incs[1].uuid);
ble_gatt_find_s_test_misc_rx_read(1, BLE_L2CAP_CID_ATT, incs[1].uuid);
ble_hs_test_util_rx_att_err_rsp(1,
ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
1);
+23 -21
View File
@@ -160,7 +160,7 @@ ble_gatt_read_test_long_cb(uint16_t conn_handle,
}
static void
ble_gatt_read_test_misc_rx_rsp_good_raw(uint16_t conn_handle,
ble_gatt_read_test_misc_rx_rsp_good_raw(uint16_t conn_handle, uint16_t cid,
uint8_t att_op,
const void *data, int data_len)
{
@@ -174,27 +174,28 @@ ble_gatt_read_test_misc_rx_rsp_good_raw(uint16_t conn_handle,
buf[0] = att_op;
memcpy(buf + 1, data, data_len);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, 1 + data_len);
TEST_ASSERT(rc == 0);
}
static void
ble_gatt_read_test_misc_rx_rsp_good(uint16_t conn_handle,
ble_gatt_read_test_misc_rx_rsp_good(uint16_t conn_handle, uint16_t cid,
struct ble_hs_test_util_flat_attr *attr)
{
ble_gatt_read_test_misc_rx_rsp_good_raw(conn_handle, BLE_ATT_OP_READ_RSP,
ble_gatt_read_test_misc_rx_rsp_good_raw(conn_handle, cid,
BLE_ATT_OP_READ_RSP,
attr->value,
attr->value_len);
}
static void
ble_gatt_read_test_misc_rx_rsp_bad(uint16_t conn_handle,
ble_gatt_read_test_misc_rx_rsp_bad(uint16_t conn_handle, uint16_t cid,
uint8_t att_error, uint16_t err_handle)
{
/* Send the pending ATT Read Request. */
ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_REQ,
ble_hs_test_util_rx_att_err_rsp(conn_handle, cid, BLE_ATT_OP_READ_REQ,
att_error, err_handle);
}
@@ -255,7 +256,7 @@ ble_gatt_read_test_misc_verify_good(struct ble_hs_test_util_flat_attr *attr)
rc = ble_gattc_read(2, attr->handle, ble_gatt_read_test_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_good(2, attr);
ble_gatt_read_test_misc_rx_rsp_good(2, BLE_L2CAP_CID_ATT, attr);
TEST_ASSERT(ble_gatt_read_test_num_attrs == 1);
TEST_ASSERT(ble_gatt_read_test_attrs[0].conn_handle == 2);
@@ -278,7 +279,7 @@ ble_gatt_read_test_misc_verify_bad(uint8_t att_status,
rc = ble_gattc_read(2, attr->handle, ble_gatt_read_test_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, attr->handle);
ble_gatt_read_test_misc_rx_rsp_bad(2, BLE_L2CAP_CID_ATT, att_status, attr->handle);
TEST_ASSERT(ble_gatt_read_test_num_attrs == 0);
TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2);
@@ -309,7 +310,8 @@ ble_gatt_read_test_misc_uuid_verify_good(
while (1) {
num_read = ble_gatt_read_test_misc_uuid_rx_rsp_good(2, attrs + idx);
if (num_read == 0) {
ble_hs_test_util_rx_att_err_rsp(2, BLE_ATT_OP_READ_TYPE_REQ,
ble_hs_test_util_rx_att_err_rsp(2, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_READ_TYPE_REQ,
BLE_ATT_ERR_ATTR_NOT_FOUND,
start_handle);
break;
@@ -369,7 +371,7 @@ ble_gatt_read_test_misc_long_verify_good(
} else {
att_op = BLE_ATT_OP_READ_BLOB_RSP;
}
ble_gatt_read_test_misc_rx_rsp_good_raw(2, att_op,
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_L2CAP_CID_ATT, att_op,
attr->value + off, chunk_sz);
rem_len -= chunk_sz;
off += chunk_sz;
@@ -401,7 +403,7 @@ ble_gatt_read_test_misc_long_verify_bad(
ble_gatt_read_test_long_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, attr->handle);
ble_gatt_read_test_misc_rx_rsp_bad(2, BLE_L2CAP_CID_ATT, att_status, attr->handle);
TEST_ASSERT(ble_gatt_read_test_num_attrs == 0);
TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2);
@@ -458,7 +460,7 @@ ble_gatt_read_test_misc_mult_verify_good(
ble_gatt_read_test_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_MULT_RSP,
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_L2CAP_CID_ATT, BLE_ATT_OP_READ_MULT_RSP,
expected_value, off);
TEST_ASSERT(ble_gatt_read_test_complete);
@@ -488,7 +490,7 @@ ble_gatt_read_test_misc_mult_verify_bad(
ble_gatt_read_test_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, err_handle);
ble_gatt_read_test_misc_rx_rsp_bad(2, BLE_L2CAP_CID_ATT, att_status, err_handle);
TEST_ASSERT(ble_gatt_read_test_num_attrs == 0);
TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2);
@@ -801,9 +803,9 @@ TEST_CASE_SELF(ble_gatt_read_test_concurrent)
rc = ble_gattc_read(2, attrs[2].handle, ble_gatt_read_test_cb, NULL);
TEST_ASSERT_FATAL(rc == 0);
ble_gatt_read_test_misc_rx_rsp_good(2, attrs + 0);
ble_gatt_read_test_misc_rx_rsp_good(2, attrs + 1);
ble_gatt_read_test_misc_rx_rsp_good(2, attrs + 2);
ble_gatt_read_test_misc_rx_rsp_good(2, BLE_L2CAP_CID_ATT, attrs + 0);
ble_gatt_read_test_misc_rx_rsp_good(2, BLE_L2CAP_CID_ATT, attrs + 1);
ble_gatt_read_test_misc_rx_rsp_good(2, BLE_L2CAP_CID_ATT, attrs + 2);
TEST_ASSERT(ble_gatt_read_test_num_attrs == 3);
@@ -852,8 +854,8 @@ TEST_CASE_SELF(ble_gatt_read_test_long_oom)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
chunk_sz = ble_att_mtu(2) - BLE_ATT_READ_RSP_BASE_SZ;
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_RSP,
chunk_sz = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_READ_RSP_BASE_SZ;
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_L2CAP_CID_ATT, BLE_ATT_OP_READ_RSP,
attr.value + off, chunk_sz);
off += chunk_sz;
@@ -875,8 +877,8 @@ TEST_CASE_SELF(ble_gatt_read_test_long_oom)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
chunk_sz = ble_att_mtu(2) - BLE_ATT_READ_RSP_BASE_SZ;
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_RSP,
chunk_sz = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_READ_RSP_BASE_SZ;
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_L2CAP_CID_ATT, BLE_ATT_OP_READ_RSP,
attr.value + off, chunk_sz);
off += chunk_sz;
@@ -897,7 +899,7 @@ TEST_CASE_SELF(ble_gatt_read_test_long_oom)
ble_gattc_timer();
chunk_sz = attr.value_len - off;
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_RSP,
ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_L2CAP_CID_ATT, BLE_ATT_OP_READ_RSP,
attr.value + off, chunk_sz);
off += chunk_sz;
+37 -36
View File
@@ -87,8 +87,8 @@ ble_gatt_write_test_rx_rsp(uint16_t conn_handle)
}
static void
ble_gatt_write_test_rx_prep_rsp(uint16_t conn_handle, uint16_t attr_handle,
uint16_t offset,
ble_gatt_write_test_rx_prep_rsp(uint16_t conn_handle, uint16_t cid,
uint16_t attr_handle, uint16_t offset,
const void *attr_data, uint16_t attr_data_len)
{
struct ble_att_prep_write_cmd rsp;
@@ -102,19 +102,19 @@ ble_gatt_write_test_rx_prep_rsp(uint16_t conn_handle, uint16_t attr_handle,
memcpy(buf + BLE_ATT_PREP_WRITE_CMD_BASE_SZ, attr_data, attr_data_len);
rc = ble_hs_test_util_l2cap_rx_payload_flat(
conn_handle, BLE_L2CAP_CID_ATT, buf,
conn_handle, cid, buf,
BLE_ATT_PREP_WRITE_CMD_BASE_SZ + attr_data_len);
TEST_ASSERT(rc == 0);
}
static void
ble_gatt_write_test_rx_exec_rsp(uint16_t conn_handle)
ble_gatt_write_test_rx_exec_rsp(uint16_t conn_handle, uint16_t cid)
{
uint8_t op;
int rc;
op = BLE_ATT_OP_EXEC_WRITE_RSP;
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
&op, 1);
TEST_ASSERT(rc == 0);
}
@@ -129,10 +129,10 @@ ble_gatt_write_test_misc_long_good(int attr_len)
ble_gatt_write_test_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
ble_hs_test_util_create_conn(2, ((uint8_t[]) {2,3,4,5,6,7,8,9}),
NULL, NULL);
mtu = ble_att_mtu(2);
mtu = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT);
rc = ble_hs_test_util_gatt_write_long_flat(
2, 100, ble_gatt_write_test_attr_value, attr_len,
@@ -152,7 +152,7 @@ ble_gatt_write_test_misc_long_good(int attr_len)
/* Receive Prep Write response. */
ble_gatt_write_test_rx_prep_rsp(
2, 100, off, ble_gatt_write_test_attr_value + off, len);
2, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len);
/* Verify callback hasn't gotten called. */
TEST_ASSERT(!ble_gatt_write_test_cb_called);
@@ -164,13 +164,13 @@ ble_gatt_write_test_misc_long_good(int attr_len)
ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
/* Receive Exec Write response. */
ble_gatt_write_test_rx_exec_rsp(2);
ble_gatt_write_test_rx_exec_rsp(2, BLE_L2CAP_CID_ATT);
/* Verify callback got called. */
TEST_ASSERT(ble_gatt_write_test_cb_called);
}
typedef void ble_gatt_write_test_long_fail_fn(uint16_t conn_handle,
typedef void ble_gatt_write_test_long_fail_fn(uint16_t conn_handle, uint16_t cid,
int off, int len);
static void
@@ -185,9 +185,9 @@ ble_gatt_write_test_misc_long_bad(int attr_len,
ble_gatt_write_test_init();
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
ble_hs_test_util_create_conn(2, ((uint8_t[]) {2,3,4,5,6,7,8,9}),
NULL, NULL);
mtu = ble_att_mtu(2);
mtu = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT);
rc = ble_hs_test_util_gatt_write_long_flat(
2, 100, ble_gatt_write_test_attr_value, attr_len,
@@ -214,9 +214,9 @@ ble_gatt_write_test_misc_long_bad(int attr_len,
}
if (!fail_now) {
ble_gatt_write_test_rx_prep_rsp(
2, 100, off, ble_gatt_write_test_attr_value + off, len);
2, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len);
} else {
cb(2, off, len);
cb(2, BLE_L2CAP_CID_ATT, off, len);
break;
}
@@ -233,38 +233,38 @@ ble_gatt_write_test_misc_long_bad(int attr_len,
}
static void
ble_gatt_write_test_misc_long_fail_handle(uint16_t conn_handle,
ble_gatt_write_test_misc_long_fail_handle(uint16_t conn_handle, uint16_t cid,
int off, int len)
{
ble_gatt_write_test_rx_prep_rsp(
conn_handle, 99, off, ble_gatt_write_test_attr_value + off,
conn_handle, cid, 99, off, ble_gatt_write_test_attr_value + off,
len);
}
static void
ble_gatt_write_test_misc_long_fail_offset(uint16_t conn_handle,
ble_gatt_write_test_misc_long_fail_offset(uint16_t conn_handle, uint16_t cid,
int off, int len)
{
ble_gatt_write_test_rx_prep_rsp(
conn_handle, 100, off + 1, ble_gatt_write_test_attr_value + off,
conn_handle, cid, 100, off + 1, ble_gatt_write_test_attr_value + off,
len);
}
static void
ble_gatt_write_test_misc_long_fail_value(uint16_t conn_handle,
ble_gatt_write_test_misc_long_fail_value(uint16_t conn_handle, uint16_t cid,
int off, int len)
{
ble_gatt_write_test_rx_prep_rsp(
conn_handle, 100, off, ble_gatt_write_test_attr_value + off + 1,
conn_handle, cid, 100, off, ble_gatt_write_test_attr_value + off + 1,
len);
}
static void
ble_gatt_write_test_misc_long_fail_length(uint16_t conn_handle,
ble_gatt_write_test_misc_long_fail_length(uint16_t conn_handle, uint16_t cid,
int off, int len)
{
ble_gatt_write_test_rx_prep_rsp(
conn_handle, 100, off, ble_gatt_write_test_attr_value + off,
conn_handle, cid, 100, off, ble_gatt_write_test_attr_value + off,
len - 1);
}
@@ -313,9 +313,9 @@ ble_gatt_write_test_misc_reliable_good(
flat_attrs + num_attrs);
}
ble_hs_test_util_create_conn(2, ((uint8_t[]){2,3,4,5,6,7,8,9}),
ble_hs_test_util_create_conn(2, ((uint8_t[]) {2,3,4,5,6,7,8,9}),
NULL, NULL);
mtu = ble_att_mtu(2);
mtu = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT);
rc = ble_gattc_write_reliable(2, attrs, num_attrs,
ble_gatt_write_test_reliable_cb_good, NULL);
@@ -336,7 +336,7 @@ ble_gatt_write_test_misc_reliable_good(
attr->value + off, len);
/* Receive Prep Write response. */
ble_gatt_write_test_rx_prep_rsp(2, attr->handle, off,
ble_gatt_write_test_rx_prep_rsp(2, BLE_L2CAP_CID_ATT, attr->handle, off,
attr->value + off, len);
/* Verify callback hasn't gotten called. */
@@ -353,7 +353,7 @@ ble_gatt_write_test_misc_reliable_good(
ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
/* Receive Exec Write response. */
ble_gatt_write_test_rx_exec_rsp(2);
ble_gatt_write_test_rx_exec_rsp(2, BLE_L2CAP_CID_ATT);
/* Verify callback got called. */
TEST_ASSERT(ble_gatt_write_test_cb_called);
@@ -599,7 +599,7 @@ TEST_CASE_SELF(ble_gatt_write_test_long_queue_full)
/* Receive Prep Write response. */
len = BLE_ATT_MTU_DFLT - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
ble_gatt_write_test_rx_prep_rsp(
2, 100, off, ble_gatt_write_test_attr_value + off, len);
2, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len);
/* Verify callback hasn't gotten called. */
TEST_ASSERT(!ble_gatt_write_test_cb_called);
@@ -611,7 +611,8 @@ TEST_CASE_SELF(ble_gatt_write_test_long_queue_full)
TEST_ASSERT(ble_hs_test_util_prev_tx_dequeue() != NULL);
/* Receive queue full error. */
ble_hs_test_util_rx_att_err_rsp(2, BLE_ATT_OP_PREP_WRITE_REQ,
ble_hs_test_util_rx_att_err_rsp(2, BLE_L2CAP_CID_ATT,
BLE_ATT_OP_PREP_WRITE_REQ,
BLE_ATT_ERR_PREPARE_QUEUE_FULL, 100);
/* Verify callback was called. */
@@ -654,14 +655,14 @@ TEST_CASE_SELF(ble_gatt_write_test_long_oom)
ble_gatt_write_test_cb_good, NULL);
TEST_ASSERT_FATAL(rc == 0);
chunk_sz = ble_att_mtu(2) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
chunk_sz = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
ble_hs_test_util_verify_tx_prep_write(attr.handle, off,
attr.value + off, chunk_sz);
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_write_test_rx_prep_rsp(2, attr.handle, off, attr.value + off,
ble_gatt_write_test_rx_prep_rsp(2, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off,
chunk_sz);
off += chunk_sz;
@@ -688,7 +689,7 @@ TEST_CASE_SELF(ble_gatt_write_test_long_oom)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_write_test_rx_prep_rsp(
2, attr.handle, off, attr.value + off, chunk_sz);
2, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, chunk_sz);
off += chunk_sz;
/* Ensure no follow-up request got sent. It should not have gotten sent
@@ -711,7 +712,7 @@ TEST_CASE_SELF(ble_gatt_write_test_long_oom)
ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
/* Receive Exec Write response. */
ble_gatt_write_test_rx_exec_rsp(2);
ble_gatt_write_test_rx_exec_rsp(2, BLE_L2CAP_CID_ATT);
/* Verify callback got called. */
TEST_ASSERT(ble_gatt_write_test_cb_called);
@@ -750,14 +751,14 @@ TEST_CASE_SELF(ble_gatt_write_test_reliable_oom)
ble_gatt_write_test_reliable_cb_good, NULL);
TEST_ASSERT_FATAL(rc == 0);
chunk_sz = ble_att_mtu(2) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
chunk_sz = ble_att_mtu_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ;
ble_hs_test_util_verify_tx_prep_write(attr.handle, off,
attr.value + off, chunk_sz);
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_write_test_rx_prep_rsp(2, attr.handle, off, attr.value + off,
ble_gatt_write_test_rx_prep_rsp(2, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off,
chunk_sz);
off += chunk_sz;
@@ -784,7 +785,7 @@ TEST_CASE_SELF(ble_gatt_write_test_reliable_oom)
/* Exhaust the msys pool. Leave one mbuf for the forthcoming response. */
oms = ble_hs_test_util_mbuf_alloc_all_but(1);
ble_gatt_write_test_rx_prep_rsp(
2, attr.handle, off, attr.value + off, chunk_sz);
2, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, chunk_sz);
off += chunk_sz;
/* Ensure no follow-up request got sent. It should not have gotten sent
@@ -807,7 +808,7 @@ TEST_CASE_SELF(ble_gatt_write_test_reliable_oom)
ble_hs_test_util_verify_tx_exec_write(BLE_ATT_EXEC_WRITE_F_EXECUTE);
/* Receive Exec Write response. */
ble_gatt_write_test_rx_exec_rsp(2);
ble_gatt_write_test_rx_exec_rsp(2, BLE_L2CAP_CID_ATT);
/* Verify callback got called. */
TEST_ASSERT(ble_gatt_write_test_cb_called);
+5 -4
View File
@@ -741,7 +741,7 @@ ble_hs_test_util_set_att_mtu(uint16_t conn_handle, uint16_t mtu)
ble_hs_lock();
rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan);
assert(rc == 0);
chan->my_mtu = mtu;
chan->peer_mtu = mtu;
@@ -772,6 +772,7 @@ ble_hs_test_util_rx_att_mtu_cmd(uint16_t conn_handle, int is_req, uint16_t mtu)
int
ble_hs_test_util_rx_att_find_info_req(uint16_t conn_handle,
uint16_t cid,
uint16_t start_handle,
uint16_t end_handle)
{
@@ -784,7 +785,7 @@ ble_hs_test_util_rx_att_find_info_req(uint16_t conn_handle,
ble_att_find_info_req_write(buf, sizeof buf, &req);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, sizeof buf);
return rc;
@@ -1070,7 +1071,7 @@ ble_hs_test_util_rx_att_indicate_req(uint16_t conn_handle,
}
void
ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint8_t req_op,
ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint16_t cid, uint8_t req_op,
uint8_t error_code, uint16_t err_handle)
{
struct ble_att_error_rsp rsp;
@@ -1083,7 +1084,7 @@ ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint8_t req_op,
ble_att_error_rsp_write(buf, sizeof buf, &rsp);
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT,
rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid,
buf, sizeof buf);
TEST_ASSERT(rc == 0);
}
+4 -2
View File
@@ -173,6 +173,7 @@ void ble_hs_test_util_set_att_mtu(uint16_t conn_handle, uint16_t mtu);
int ble_hs_test_util_rx_att_mtu_cmd(uint16_t conn_handle, int is_req,
uint16_t mtu);
int ble_hs_test_util_rx_att_find_info_req(uint16_t conn_handle,
uint16_t cid,
uint16_t start_handle,
uint16_t end_handle);
int ble_hs_test_util_rx_att_find_type_value_req(uint16_t conn_handle,
@@ -228,8 +229,9 @@ int ble_hs_test_util_rx_att_indicate_req(uint16_t conn_handle,
uint16_t attr_handle,
void *attr_val,
uint16_t attr_len);
void ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint8_t req_op,
uint8_t error_code, uint16_t err_handle);
void ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint16_t cid,
uint8_t req_op, uint8_t error_code,
uint16_t err_handle);
void ble_hs_test_util_verify_tx_prep_write(uint16_t attr_handle,
uint16_t offset,
const void *data, int data_len);