From 74c95610a2e45404fda46774abe6e6e70c40f1b2 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 29 May 2024 12:38:21 +0530 Subject: [PATCH] Revert "feat(nimble): Added support for Enhanced ATT or ATT over Enhanced L2CAP Credit Based Flow Control Mode" This reverts commit 1be1f55eaaf32e6499e707ea284d65eb3164e98c. --- nimble/host/include/host/ble_att.h | 9 +- nimble/host/include/host/ble_gap.h | 26 - nimble/host/include/host/ble_gatt.h | 26 - nimble/host/pkg.yml | 3 - .../gatt/include/services/gatt/ble_svc_gatt.h | 2 +- nimble/host/services/gatt/src/ble_svc_gatt.c | 12 - nimble/host/src/ble_att.c | 181 +----- nimble/host/src/ble_att_clt.c | 175 ++--- nimble/host/src/ble_att_cmd.c | 54 +- nimble/host/src/ble_att_cmd_priv.h | 22 +- nimble/host/src/ble_att_priv.h | 112 ++-- nimble/host/src/ble_att_svr.c | 209 +++--- nimble/host/src/ble_eatt.c | 601 ------------------ nimble/host/src/ble_eatt_priv.h | 58 -- nimble/host/src/ble_gap.c | 21 - nimble/host/src/ble_gap_priv.h | 1 - nimble/host/src/ble_gatt_priv.h | 40 +- nimble/host/src/ble_gattc.c | 429 +++---------- nimble/host/src/ble_hs.c | 8 +- nimble/host/src/ble_hs_conn.c | 1 - nimble/host/src/ble_hs_conn_priv.h | 6 - nimble/host/src/ble_hs_priv.h | 1 - nimble/host/src/ble_l2cap_coc.c | 2 +- nimble/host/syscfg.yml | 37 -- nimble/host/test/src/ble_att_clt_test.c | 53 +- nimble/host/test/src/ble_att_svr_test.c | 27 +- nimble/host/test/src/ble_gatt_conn_test.c | 36 -- nimble/host/test/src/ble_gatt_disc_c_test.c | 32 +- nimble/host/test/src/ble_gatt_disc_d_test.c | 24 +- nimble/host/test/src/ble_gatt_disc_s_test.c | 52 +- nimble/host/test/src/ble_gatt_find_s_test.c | 37 +- nimble/host/test/src/ble_gatt_read_test.c | 44 +- nimble/host/test/src/ble_gatt_write_test.c | 73 ++- nimble/host/test/src/ble_hs_test_util.c | 9 +- nimble/host/test/src/ble_hs_test_util.h | 6 +- nimble/host/test/syscfg.yml | 1 - nimble/include/nimble/nimble_opt_auto.h | 4 - .../examples/linux/include/logcfg/logcfg.h | 7 - .../examples/linux/include/syscfg/syscfg.h | 24 - .../linux_blemesh/include/logcfg/logcfg.h | 7 - .../linux_blemesh/include/syscfg/syscfg.h | 24 - .../examples/nuttx/include/syscfg/syscfg.h | 4 - porting/nimble/include/logcfg/logcfg.h | 7 - porting/nimble/include/syscfg/syscfg.h | 24 - porting/npl/riot/include/logcfg/logcfg.h | 7 - porting/npl/riot/include/syscfg/syscfg.h | 24 - 46 files changed, 518 insertions(+), 2044 deletions(-) delete mode 100644 nimble/host/src/ble_eatt.c delete mode 100644 nimble/host/src/ble_eatt_priv.h diff --git a/nimble/host/include/host/ble_att.h b/nimble/host/include/host/ble_att.h index 29c21393f..a4665aa3d 100644 --- a/nimble/host/include/host/ble_att.h +++ b/nimble/host/include/host/ble_att.h @@ -189,6 +189,7 @@ struct os_mbuf; /** Execute Write Response. */ #define BLE_ATT_OP_EXEC_WRITE_RSP 0x19 + /** Read Multiple Variable Lenght Request */ #define BLE_ATT_OP_READ_MULT_VAR_REQ 0x20 @@ -204,13 +205,8 @@ struct os_mbuf; /** Indicate Response. */ #define BLE_ATT_OP_INDICATE_RSP 0x1e -/** Multiple Handle Value Length Notification Request */ -#define BLE_ATT_OP_NOTIFY_MULTI_REQ 0x23 - /** Write Command. */ #define BLE_ATT_OP_WRITE_CMD 0x52 - -/** Signed Write Command */ #define BLE_ATT_OP_SIGNED_WRITE_CMD 0xD2 /** @} */ @@ -347,9 +343,6 @@ uint16_t ble_att_preferred_mtu(void); */ int ble_att_set_preferred_mtu(uint16_t mtu); -int ble_att_set_default_bearer_using_cid(uint16_t conn_handle, uint16_t cid); -uint16_t ble_att_get_default_bearer_cid(uint16_t conn_handle); - #ifdef __cplusplus } #endif diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index 95dc58412..ebab72b80 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -161,7 +161,6 @@ struct hci_conn_update; #define BLE_GAP_EVENT_AUTHORIZE 32 #define BLE_GAP_EVENT_TEST_UPDATE 33 #define BLE_GAP_EVENT_DATA_LEN_CHG 34 -#define BLE_GAP_EVENT_EATT 35 /* DTM events */ #define BLE_GAP_DTM_TX_START_EVT 0 @@ -1207,31 +1206,6 @@ struct ble_gap_event { int out_response; } authorize; -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - /** - * EATT Event - * - * Valid for the following event types: - * o BLE_GAP_EVENT_EATT - * - */ - struct { - /* Connection Handle */ - uint16_t conn_handle; - - /** Connected Status - * - * EATT Connected: 0 - * EATT Disconnected: 1 - */ - uint8_t status; - - /* CID of the bearer */ - uint16_t cid; - - } eatt; -#endif - #if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT) /** * Represents a event mentioning connection reattempt diff --git a/nimble/host/include/host/ble_gatt.h b/nimble/host/include/host/ble_gatt.h index af8dc1337..c2facf299 100644 --- a/nimble/host/include/host/ble_gatt.h +++ b/nimble/host/include/host/ble_gatt.h @@ -386,16 +386,6 @@ struct ble_hs_cfg; #define BLE_GATT_CHR_BT_SIG_DESC_INTERNAL 0x010F #define BLE_GATT_CHR_BT_SIG_DESC_EXTERNAL 0x0110 -/*** @server. */ -/** Represents one notification tuple in a multi notification PDU */ -struct ble_gatt_notif_entry { - /** The attribute handle on which to notify. */ - uint16_t handle; - - /** The notification value. */ - struct os_mbuf * value; -}; - /*** @client. */ /** Represents a GATT error. */ struct ble_gatt_error { @@ -861,22 +851,6 @@ int ble_gattc_write_reliable(uint16_t conn_handle, int ble_gatts_notify_custom(uint16_t conn_handle, uint16_t att_handle, struct os_mbuf *om); -/** - * Sends multiple characteristic notifications on the specified - * attribute handles. This function consumes the mbuf of the - * notification value after sending notification. - * - * @param conn_handle The connection over which to execute the - * procedure. - * @param tuples The list of attribute handles and notification - * value tuples. - * @param num_tuples The number of notifications to send. - * - * @return 0 on success; nonzero on failure. - */ -int ble_gatts_multi_notify_custom(uint16_t conn_handle, - struct ble_gatt_notif_entry * tuples, uint16_t num_tuples); - /** * Deprecated. Should not be used. Use ble_gatts_notify_custom instead. */ diff --git a/nimble/host/pkg.yml b/nimble/host/pkg.yml index cab496cae..c069283cf 100644 --- a/nimble/host/pkg.yml +++ b/nimble/host/pkg.yml @@ -41,9 +41,6 @@ pkg.deps.BLE_SM_SC: pkg.deps.BLE_MESH: - nimble/host/mesh -pkg.deps.BLE_EATT_CHAN_NUM: - - nimble/host/services/gatt - pkg.req_apis: - ble_transport - console diff --git a/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h b/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h index bb0a415bb..a035f9a12 100644 --- a/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h +++ b/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h @@ -29,7 +29,7 @@ extern "C" { struct ble_hs_cfg; -#define BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16 0x2a05 +#define BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16 0x2a05 #define BLE_SVC_GATT_CHR_SERVER_SUPPORTED_FEAT_UUID16 0x2b3a #define BLE_SVC_GATT_CHR_CLIENT_SUPPORTED_FEAT_UUID16 0x2b29 diff --git a/nimble/host/services/gatt/src/ble_svc_gatt.c b/nimble/host/services/gatt/src/ble_svc_gatt.c index 6bb9cfe23..f32b72944 100644 --- a/nimble/host/services/gatt/src/ble_svc_gatt.c +++ b/nimble/host/services/gatt/src/ble_svc_gatt.c @@ -232,16 +232,4 @@ ble_svc_gatt_init(void) rc = ble_gatts_add_svcs(ble_svc_gatt_defs); SYSINIT_PANIC_ASSERT(rc == 0); - - if (MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0) { - ble_svc_gatt_local_srv_sup_feat |= (1 << BLE_SVC_GATT_SRV_SUP_FEAT_EATT_BIT); - } - - if (MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0) { - ble_svc_gatt_local_cl_sup_feat |= (1 << BLE_SVC_GATT_CLI_SUP_FEAT_EATT_BIT); - } - - if (MYNEWT_VAL(BLE_ATT_SVR_NOTIFY_MULTI) > 0) { - ble_svc_gatt_local_cl_sup_feat |= (1 << BLE_SVC_GATT_CLI_SUP_FEAT_MULT_NTF_BIT); - } } diff --git a/nimble/host/src/ble_att.c b/nimble/host/src/ble_att.c index e014cc3d0..91e770808 100644 --- a/nimble/host/src/ble_att.c +++ b/nimble/host/src/ble_att.c @@ -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, uint16_t cid, struct os_mbuf **om); +typedef int ble_att_rx_fn(uint16_t conn_handle, struct os_mbuf **om); struct ble_att_rx_dispatch_entry { uint8_t bde_op; ble_att_rx_fn *bde_fn; @@ -71,7 +71,6 @@ static const struct ble_att_rx_dispatch_entry ble_att_rx_dispatch[] = { { BLE_ATT_OP_INDICATE_RSP, ble_att_clt_rx_indicate }, { BLE_ATT_OP_READ_MULT_VAR_REQ, ble_att_svr_rx_read_mult_var }, { BLE_ATT_OP_READ_MULT_VAR_RSP, ble_att_clt_rx_read_mult_var }, - { BLE_ATT_OP_NOTIFY_MULTI_REQ, ble_att_svr_rx_notify_multi }, { BLE_ATT_OP_WRITE_CMD, ble_att_svr_rx_write_no_rsp }, { BLE_ATT_OP_SIGNED_WRITE_CMD, ble_att_svr_rx_signed_write }, }; @@ -133,8 +132,6 @@ STATS_NAME_START(ble_att_stats) STATS_NAME(ble_att_stats, indicate_req_tx) STATS_NAME(ble_att_stats, indicate_rsp_rx) STATS_NAME(ble_att_stats, indicate_rsp_tx) - STATS_NAME(ble_att_stats, multi_notify_req_rx) - STATS_NAME(ble_att_stats, multi_notify_req_tx) STATS_NAME(ble_att_stats, write_cmd_rx) STATS_NAME(ble_att_stats, write_cmd_tx) STATS_NAME_END(ble_att_stats) @@ -160,21 +157,13 @@ ble_att_rx_dispatch_entry_find(uint8_t op) } int -ble_att_conn_chan_find(uint16_t conn_handle, uint16_t cid, struct ble_hs_conn **out_conn, +ble_att_conn_chan_find(uint16_t conn_handle, struct ble_hs_conn **out_conn, struct ble_l2cap_chan **out_chan) { - return ble_hs_misc_conn_chan_find(conn_handle, cid, + return ble_hs_misc_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, 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) { @@ -283,10 +272,6 @@ ble_att_inc_tx_stat(uint8_t att_op) STATS_INC(ble_att_stats, indicate_rsp_tx); break; - case BLE_ATT_OP_NOTIFY_MULTI_REQ: - STATS_INC(ble_att_stats, multi_notify_req_tx); - break; - case BLE_ATT_OP_WRITE_CMD: STATS_INC(ble_att_stats, write_cmd_tx); break; @@ -404,10 +389,6 @@ ble_att_inc_rx_stat(uint8_t att_op) STATS_INC(ble_att_stats, indicate_rsp_rx); break; - case BLE_ATT_OP_NOTIFY_MULTI_REQ: - STATS_INC(ble_att_stats, multi_notify_req_rx); - break; - case BLE_ATT_OP_WRITE_CMD: STATS_INC(ble_att_stats, write_cmd_rx); break; @@ -432,7 +413,7 @@ ble_att_truncate_to_mtu(const struct ble_l2cap_chan *att_chan, } uint16_t -ble_att_mtu_by_cid(uint16_t conn_handle, uint16_t cid) +ble_att_mtu(uint16_t conn_handle) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; @@ -441,7 +422,7 @@ ble_att_mtu_by_cid(uint16_t conn_handle, uint16_t cid) ble_hs_lock(); - rc = ble_att_conn_chan_find(conn_handle, cid, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); if (rc == 0) { mtu = ble_att_chan_mtu(chan); } else { @@ -453,12 +434,6 @@ ble_att_mtu_by_cid(uint16_t conn_handle, uint16_t cid) 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) { @@ -474,16 +449,6 @@ ble_att_chan_mtu(const struct ble_l2cap_chan *chan) { uint16_t mtu; -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - if (chan->psm == BLE_EATT_PSM) { - /* The ATT_MTU for the Enhanced ATT bearer shall be set to the minimum of the - * MTU field values of the two devices. Reference: - * Core v5.4 Vol 3 Part G 5.3.1 ATT_MTU - */ - return min(chan->coc_tx.mtu, chan->coc_rx.mtu); - } -#endif - /* If either side has not exchanged MTU size, use the default. Otherwise, * use the lesser of the two exchanged values. */ @@ -502,7 +467,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, - uint16_t cid, struct os_mbuf **om) + struct os_mbuf **om) { /* If this is command (bit6 is set to 1), do nothing */ if (op & 0x40) { @@ -510,37 +475,27 @@ 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, cid, *om, op, 0, + ble_att_svr_tx_error_rsp(conn_handle, *om, op, 0, BLE_ATT_ERR_REQ_NOT_SUPPORTED); *om = NULL; } -static void -ble_att_send_outstanding_after_response(uint16_t conn_handle) -{ - struct ble_hs_conn *conn; - struct ble_l2cap_chan *chan; - int rc; - - ble_hs_lock(); - rc = ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_ATT, &conn, - &chan); - if (rc) { - return; - } - conn->client_att_busy = false; - ble_att_tx_with_conn(conn, chan, NULL); - ble_hs_unlock(); -} - static int -ble_att_rx_extended(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om) +ble_att_rx(struct ble_l2cap_chan *chan) { const struct ble_att_rx_dispatch_entry *entry; uint8_t op; + uint16_t conn_handle; + struct os_mbuf **om; int rc; + conn_handle = ble_l2cap_get_conn_handle(chan); + if (conn_handle == BLE_HS_CONN_HANDLE_NONE) { + return BLE_HS_ENOTCONN; + } + + om = &chan->rx_buf; BLE_HS_DBG_ASSERT(*om != NULL); rc = os_mbuf_copydata(*om, 0, 1, &op); @@ -548,13 +503,9 @@ ble_att_rx_extended(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om) return BLE_HS_EMSGSIZE; } - if (cid == BLE_L2CAP_CID_ATT && ble_att_is_response_op(op)) { - ble_att_send_outstanding_after_response(conn_handle); - } - entry = ble_att_rx_dispatch_entry_find(op); if (entry == NULL) { - ble_att_rx_handle_unknown_request(op, conn_handle, cid, om); + ble_att_rx_handle_unknown_request(op, conn_handle, om); return BLE_HS_ENOTSUP; } @@ -563,10 +514,10 @@ ble_att_rx_extended(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om) /* Strip L2CAP ATT header from the front of the mbuf. */ os_mbuf_adj(*om, 1); - rc = entry->bde_fn(conn_handle, cid, om); + rc = entry->bde_fn(conn_handle, om); if (rc != 0) { if (rc == BLE_HS_ENOTSUP) { - ble_att_rx_handle_unknown_request(op, conn_handle, cid, om); + ble_att_rx_handle_unknown_request(op, conn_handle, om); } return rc; } @@ -574,19 +525,6 @@ ble_att_rx_extended(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om) return 0; } -static int -ble_att_rx(struct ble_l2cap_chan *chan) -{ - uint16_t conn_handle; - - conn_handle = ble_l2cap_get_conn_handle(chan); - if (conn_handle == BLE_HS_CONN_HANDLE_NONE) { - return BLE_HS_ENOTCONN; - } - - return ble_att_rx_extended(conn_handle, chan->scid, &chan->rx_buf); -} - uint16_t ble_att_preferred_mtu(void) { @@ -647,85 +585,6 @@ 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: - case BLE_ATT_OP_READ_MULT_VAR_REQ: - case BLE_ATT_OP_NOTIFY_MULTI_REQ: - case BLE_ATT_OP_WRITE_CMD: - case BLE_ATT_OP_SIGNED_WRITE_CMD: - case BLE_ATT_OP_NOTIFY_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: - case BLE_ATT_OP_READ_MULT_VAR_RSP: - return true; - } - - return false; -} - -int -ble_att_set_default_bearer_using_cid(uint16_t conn_handle, uint16_t cid) { -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) - struct ble_hs_conn * conn; - - conn = ble_hs_conn_find(conn_handle); - if (conn == NULL) { - return BLE_HS_ENOTCONN; - } - conn->default_cid = cid; - return 0; -#endif - return BLE_HS_ENOTSUP; -} - -uint16_t -ble_att_get_default_bearer_cid(uint16_t conn_handle) { -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) - struct ble_hs_conn * conn; - - conn = ble_hs_conn_find(conn_handle); - if (conn == NULL) { - return 0; - } - return conn->default_cid; -#endif - return 0; -} - int ble_att_init(void) { @@ -740,8 +599,6 @@ ble_att_init(void) return BLE_HS_EOS; } - ble_eatt_init(ble_att_rx_extended); - return 0; } diff --git a/nimble/host/src/ble_att_clt.c b/nimble/host/src/ble_att_clt.c index 9336c89f3..2b62e27b8 100644 --- a/nimble/host/src/ble_att_clt.c +++ b/nimble/host/src/ble_att_clt.c @@ -37,7 +37,7 @@ *****************************************************************************/ int -ble_att_clt_rx_error(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_error(uint16_t conn_handle, struct os_mbuf **rxom) { struct ble_att_error_rsp *rsp; int rc; @@ -49,7 +49,7 @@ ble_att_clt_rx_error(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) rsp = (struct ble_att_error_rsp *)(*rxom)->om_data; - ble_gattc_rx_err(conn_handle, cid, le16toh(rsp->baep_handle), + ble_gattc_rx_err(conn_handle, le16toh(rsp->baep_handle), le16toh(rsp->baep_error_code)); return 0; @@ -74,7 +74,7 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu) ble_hs_lock(); - rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); if (rc != 0) { rc = BLE_HS_ENOTCONN; } else if (chan->flags & BLE_L2CAP_CHAN_F_TXED_MTU) { @@ -95,14 +95,14 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu) req->bamc_mtu = htole16(mtu); - rc = ble_att_tx(conn_handle, BLE_L2CAP_CID_ATT, txom); + rc = ble_att_tx(conn_handle, txom); if (rc != 0) { return rc; } ble_hs_lock(); - rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); if (rc == 0) { chan->flags |= BLE_L2CAP_CHAN_F_TXED_MTU; } @@ -113,7 +113,7 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, uint16_t mtu) } int -ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom) { struct ble_att_mtu_cmd *cmd; struct ble_l2cap_chan *chan; @@ -122,19 +122,13 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) mtu = 0; -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - if (cid != BLE_L2CAP_CID_ATT) { - return BLE_HS_ENOTSUP; - } -#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, cid, NULL, &chan); + rc = ble_att_conn_chan_find(conn_handle, NULL, &chan); if (rc == 0) { ble_att_set_peer_mtu(chan, le16toh(cmd->bamc_mtu)); mtu = ble_att_chan_mtu(chan); @@ -147,7 +141,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) } } - ble_gattc_rx_mtu(conn_handle, BLE_L2CAP_CID_ATT, rc, mtu); + ble_gattc_rx_mtu(conn_handle, rc, mtu); return rc; } @@ -156,7 +150,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) *****************************************************************************/ int -ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t cid, uint16_t start_handle, +ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle) { #if !NIMBLE_BLE_ATT_CLT_FIND_INFO @@ -178,7 +172,7 @@ ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t cid, uint16_t start_hand req->bafq_start_handle = htole16(start_handle); req->bafq_end_handle = htole16(end_handle); - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } static int @@ -233,7 +227,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, uint16_t cid, struct os_mbuf **om) +ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **om) { #if !NIMBLE_BLE_ATT_CLT_FIND_INFO return BLE_HS_ENOTSUP; @@ -260,14 +254,14 @@ ble_att_clt_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **om } /* Hand find-info entry to GATT. */ - ble_gattc_rx_find_info_idata(conn_handle, cid, &idata); + ble_gattc_rx_find_info_idata(conn_handle, &idata); } rc = 0; done: /* Notify GATT that response processing is done. */ - ble_gattc_rx_find_info_complete(conn_handle, cid, rc); + ble_gattc_rx_find_info_complete(conn_handle, rc); return rc; } @@ -280,9 +274,8 @@ done: * anyway */ 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, +ble_att_clt_tx_find_type_value(uint16_t conn_handle, 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 @@ -307,7 +300,7 @@ ble_att_clt_tx_find_type_value(uint16_t conn_handle, uint16_t cid, req->bavq_attr_type = htole16(attribute_type); memcpy(req->bavq_value, attribute_value, value_len); - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } static int @@ -333,7 +326,7 @@ ble_att_clt_parse_find_type_value_hinfo( } int -ble_att_clt_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_FIND_TYPE return BLE_HS_ENOTSUP; @@ -350,11 +343,11 @@ ble_att_clt_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbu break; } - ble_gattc_rx_find_type_value_hinfo(conn_handle, cid, &hinfo); + ble_gattc_rx_find_type_value_hinfo(conn_handle, &hinfo); } /* Notify GATT client that the full response has been parsed. */ - ble_gattc_rx_find_type_value_complete(conn_handle, cid, rc); + ble_gattc_rx_find_type_value_complete(conn_handle, rc); return 0; } @@ -364,7 +357,7 @@ ble_att_clt_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbu *****************************************************************************/ int -ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t cid, uint16_t start_handle, +ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid) { #if !NIMBLE_BLE_ATT_CLT_READ_TYPE @@ -389,11 +382,11 @@ ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t cid, uint16_t start_hand ble_uuid_flat(uuid, req->uuid); - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } int -ble_att_clt_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_READ_TYPE return BLE_HS_ENOTSUP; @@ -435,13 +428,13 @@ ble_att_clt_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx adata.value_len = data_len - sizeof(*data); adata.value = data->value; - ble_gattc_rx_read_type_adata(conn_handle, cid, &adata); + ble_gattc_rx_read_type_adata(conn_handle, &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, cid, rc); + ble_gattc_rx_read_type_complete(conn_handle, rc); return rc; } @@ -451,7 +444,7 @@ done: *****************************************************************************/ int -ble_att_clt_tx_read(uint16_t conn_handle, uint16_t cid, uint16_t handle) +ble_att_clt_tx_read(uint16_t conn_handle, uint16_t handle) { #if !NIMBLE_BLE_ATT_CLT_READ return BLE_HS_ENOTSUP; @@ -472,7 +465,7 @@ ble_att_clt_tx_read(uint16_t conn_handle, uint16_t cid, uint16_t handle) req->barq_handle = htole16(handle); - rc = ble_att_tx(conn_handle, cid, txom); + rc = ble_att_tx(conn_handle, txom); if (rc != 0) { return rc; } @@ -481,14 +474,14 @@ 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) +ble_att_clt_rx_read(uint16_t conn_handle, 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, cid, 0, rxom); + ble_gattc_rx_read_rsp(conn_handle, 0, rxom); return 0; } @@ -497,7 +490,7 @@ 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) +ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t handle, uint16_t offset) { #if !NIMBLE_BLE_ATT_CLT_READ_BLOB return BLE_HS_ENOTSUP; @@ -519,7 +512,7 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t cid, uint16_t handle, ui req->babq_handle = htole16(handle); req->babq_offset = htole16(offset); - rc = ble_att_tx(conn_handle, cid, txom); + rc = ble_att_tx(conn_handle, txom); if (rc != 0) { return rc; } @@ -528,14 +521,14 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle, uint16_t cid, uint16_t handle, ui } int -ble_att_clt_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_read_blob(uint16_t conn_handle, 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, cid, 0, rxom); + ble_gattc_rx_read_blob_rsp(conn_handle, 0, rxom); return 0; } @@ -543,8 +536,8 @@ ble_att_clt_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx * $read multiple * *****************************************************************************/ int -ble_att_clt_tx_read_mult(uint16_t conn_handle, uint16_t cid, - const uint16_t *handles, int num_handles, bool variable) +ble_att_clt_tx_read_mult(uint16_t conn_handle, const uint16_t *handles, + int num_handles, bool variable) { #if !NIMBLE_BLE_ATT_CLT_READ_MULT return BLE_HS_ENOTSUP; @@ -572,30 +565,30 @@ ble_att_clt_tx_read_mult(uint16_t conn_handle, uint16_t cid, req->handles[i] = htole16(handles[i]); } - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } int -ble_att_clt_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_read_mult(uint16_t conn_handle, 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, cid, 0, rxom, false); + ble_gattc_rx_read_mult_rsp(conn_handle, 0, rxom, false); return 0; } int -ble_att_clt_rx_read_mult_var(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_read_mult_var(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_READ_MULT_VAR return BLE_HS_ENOTSUP; #endif /* Pass the Attribute Value field to GATT. */ - ble_gattc_rx_read_mult_rsp(conn_handle, cid, 0, rxom, true); + ble_gattc_rx_read_mult_rsp(conn_handle, 0, rxom, true); return 0; } @@ -604,7 +597,7 @@ ble_att_clt_rx_read_mult_var(uint16_t conn_handle, uint16_t cid, struct os_mbuf *****************************************************************************/ int -ble_att_clt_tx_read_group_type(uint16_t conn_handle, uint16_t cid, +ble_att_clt_tx_read_group_type(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid) { @@ -629,7 +622,7 @@ ble_att_clt_tx_read_group_type(uint16_t conn_handle, uint16_t cid, req->bagq_end_handle = htole16(end_handle); ble_uuid_flat(uuid, req->uuid); - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } static int @@ -657,7 +650,7 @@ ble_att_clt_parse_read_group_type_adata( } int -ble_att_clt_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE return BLE_HS_ENOTSUP; @@ -687,13 +680,13 @@ ble_att_clt_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbu goto done; } - ble_gattc_rx_read_group_type_adata(conn_handle, cid, &adata); + ble_gattc_rx_read_group_type_adata(conn_handle, &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, cid, rc); + ble_gattc_rx_read_group_type_complete(conn_handle, rc); return rc; } @@ -702,7 +695,7 @@ done: *****************************************************************************/ int -ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t cid, uint16_t handle, +ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t handle, struct os_mbuf *txom) { #if !NIMBLE_BLE_ATT_CLT_WRITE @@ -721,12 +714,12 @@ ble_att_clt_tx_write_req(uint16_t conn_handle, uint16_t cid, uint16_t handle, req->bawq_handle = htole16(handle); os_mbuf_concat(txom2, txom); - return ble_att_tx(conn_handle, cid, txom2); + return ble_att_tx(conn_handle, txom2); } int -ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t cid, - uint16_t handle, struct os_mbuf *txom) +ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle, + struct os_mbuf *txom) { #if !NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP return BLE_HS_ENOTSUP; @@ -760,24 +753,24 @@ ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t cid, cmd->handle = htole16(handle); os_mbuf_concat(txom2, txom); - return ble_att_tx(conn_handle, cid, txom2); + return ble_att_tx(conn_handle, txom2); } int -ble_att_clt_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_WRITE return BLE_HS_ENOTSUP; #endif /* No payload. */ - ble_gattc_rx_write_rsp(conn_handle, cid); + ble_gattc_rx_write_rsp(conn_handle); return 0; } int -ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t cid, uint16_t handle, - uint8_t *csrk, uint32_t counter, struct os_mbuf *txom) +ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t handle, uint8_t *csrk, + uint32_t counter, struct os_mbuf *txom) { #if !NIMBLE_BLE_ATT_CLT_SIGNED_WRITE return BLE_HS_ENOTSUP; @@ -863,7 +856,7 @@ ble_att_clt_tx_signed_write_cmd(uint16_t conn_handle, uint16_t cid, uint16_t han if(message != NULL) nimble_platform_mem_free(message); os_mbuf_concat(txom2, txom); - return ble_att_tx(conn_handle, cid, txom2); + return ble_att_tx(conn_handle, txom2); err: if(message != NULL) nimble_platform_mem_free(message); os_mbuf_free_chain(txom2); @@ -875,7 +868,7 @@ err: *****************************************************************************/ int -ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t cid, uint16_t handle, +ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle, uint16_t offset, struct os_mbuf *txom) { #if !NIMBLE_BLE_ATT_CLT_PREP_WRITE @@ -904,7 +897,7 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t cid, uint16_t handle, #endif if (OS_MBUF_PKTLEN(txom) > - ble_att_mtu_by_cid(conn_handle, cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) { + ble_att_mtu(conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) { rc = BLE_HS_EINVAL; goto err; } @@ -919,7 +912,7 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t cid, uint16_t handle, req->bapc_offset = htole16(offset); os_mbuf_concat(txom2, txom); - return ble_att_tx(conn_handle, cid, txom2); + return ble_att_tx(conn_handle, txom2); err: os_mbuf_free_chain(txom); @@ -927,7 +920,7 @@ err: } int -ble_att_clt_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_PREP_WRITE return BLE_HS_ENOTSUP; @@ -956,7 +949,7 @@ ble_att_clt_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **r done: /* Notify GATT client that the full response has been parsed. */ - ble_gattc_rx_prep_write_rsp(conn_handle, cid, rc, handle, offset, rxom); + ble_gattc_rx_prep_write_rsp(conn_handle, rc, handle, offset, rxom); return rc; } @@ -965,7 +958,7 @@ done: *****************************************************************************/ int -ble_att_clt_tx_exec_write(uint16_t conn_handle, uint16_t cid, uint8_t flags) +ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags) { #if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE return BLE_HS_ENOTSUP; @@ -982,7 +975,7 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle, uint16_t cid, uint8_t flags) req->baeq_flags = flags; - rc = ble_att_tx(conn_handle, cid, txom); + rc = ble_att_tx(conn_handle, txom); if (rc != 0) { return rc; } @@ -991,13 +984,13 @@ 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) +ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE return BLE_HS_ENOTSUP; #endif - ble_gattc_rx_exec_write_rsp(conn_handle, cid, 0); + ble_gattc_rx_exec_write_rsp(conn_handle, 0); return 0; } @@ -1015,7 +1008,6 @@ 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) { @@ -1032,49 +1024,20 @@ ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle, req->banq_handle = htole16(handle); os_mbuf_concat(txom2, txom); - cid = ble_eatt_get_available_chan_cid(conn_handle, BLE_GATT_OP_DUMMY); - rc = ble_att_tx(conn_handle, cid, txom2); - ble_eatt_release_chan(conn_handle, BLE_GATT_OP_DUMMY); - return rc; + return ble_att_tx(conn_handle, txom2); err: os_mbuf_free_chain(txom); return rc; } -/***************************************************************************** -* $multi handle value notification * -*****************************************************************************/ - -int -ble_att_clt_tx_multi_notify(uint16_t conn_handle, struct os_mbuf * om) -{ -#if !NIMBLE_BLE_ATT_CLT_MULTI_NOTIFY - return BLE_HS_ENOTSUP; -#endif - - struct os_mbuf * txom; - uint16_t cid; - int rc; - - if (ble_att_cmd_get(BLE_ATT_OP_NOTIFY_MULTI_REQ, 0, &txom) == NULL) { - return BLE_HS_ENOMEM; - } - - os_mbuf_concat(txom, om); - cid = ble_eatt_get_available_chan_cid(conn_handle, BLE_GATT_OP_DUMMY); - rc = ble_att_tx(conn_handle, cid, txom); - ble_eatt_release_chan(conn_handle, BLE_GATT_OP_DUMMY); - return rc; -} - /***************************************************************************** * $handle value indication * *****************************************************************************/ int -ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t cid, - uint16_t handle, struct os_mbuf *txom) +ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t handle, + struct os_mbuf *txom) { #if !NIMBLE_BLE_ATT_CLT_INDICATE return BLE_HS_ENOTSUP; @@ -1098,7 +1061,7 @@ ble_att_clt_tx_indicate(uint16_t conn_handle, uint16_t cid, req->baiq_handle = htole16(handle); os_mbuf_concat(txom2, txom); - return ble_att_tx(conn_handle, cid, txom2); + return ble_att_tx(conn_handle, txom2); err: os_mbuf_free_chain(txom); @@ -1106,14 +1069,14 @@ err: } int -ble_att_clt_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_clt_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom) { #if !NIMBLE_BLE_ATT_CLT_INDICATE return BLE_HS_ENOTSUP; #endif /* No payload. */ - ble_gatts_rx_indicate_rsp(conn_handle, cid); + ble_gatts_rx_indicate_rsp(conn_handle); return 0; } diff --git a/nimble/host/src/ble_att_cmd.c b/nimble/host/src/ble_att_cmd.c index d263b3de3..6669392f1 100644 --- a/nimble/host/src/ble_att_cmd.c +++ b/nimble/host/src/ble_att_cmd.c @@ -55,66 +55,28 @@ ble_att_cmd_get(uint8_t opcode, size_t len, struct os_mbuf **txom) } int -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_EATT_LOG_DEBUG("%s: wakeup will send %p\n", __func__, txom); - } - - BLE_HS_DBG_ASSERT_EVAL(txom->om_len >= 1); - - if (ble_att_is_request_op(txom->om_data[0])) { - if (conn->client_att_busy) { - BLE_EATT_LOG_DEBUG("ATT Queue %p, client busy %d\n", txom, 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) +ble_att_tx(uint16_t conn_handle, struct os_mbuf *txom) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; int rc; -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - if (cid != BLE_L2CAP_CID_ATT) { - return ble_eatt_tx(conn_handle, cid, txom); - } -#endif + 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); - return rc; + } else { + ble_att_truncate_to_mtu(chan, txom); + rc = ble_l2cap_tx(conn, chan, txom); } - rc = ble_att_tx_with_conn(conn, chan, txom); ble_hs_unlock(); + return rc; } diff --git a/nimble/host/src/ble_att_cmd_priv.h b/nimble/host/src/ble_att_cmd_priv.h index 5deb6812e..54052a985 100644 --- a/nimble/host/src/ble_att_cmd_priv.h +++ b/nimble/host/src/ble_att_cmd_priv.h @@ -309,20 +309,6 @@ struct ble_att_exec_write_req { */ #define BLE_ATT_EXEC_WRITE_RSP_SZ 1 -/** - * | Parameter | Size (octets) | - * +-----------------------------------------------+-------------------+ - * | Attribute Opcode | 1 | - * | Attribute Handle Length Value Tuple List | 8 to (ATT_MTU-1) | - */ -#define BLE_ATT_NOTIFY_MULTI_REQ_BASE_SZ 9 - -struct ble_att_tuple_list { - uint16_t handle; - uint16_t value_len; - uint8_t data[0]; -} __attribute__((packed)); - /** * | Parameter | Size (octets) | * +------------------------------------+-------------------+ @@ -468,14 +454,8 @@ 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, uint16_t cid, struct os_mbuf *txom); +int ble_att_tx(uint16_t conn_handle, 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 diff --git a/nimble/host/src/ble_att_priv.h b/nimble/host/src/ble_att_priv.h index 2250458ea..0e723de92 100644 --- a/nimble/host/src/ble_att_priv.h +++ b/nimble/host/src/ble_att_priv.h @@ -102,8 +102,6 @@ STATS_SECT_START(ble_att_stats) STATS_SECT_ENTRY(indicate_req_tx) STATS_SECT_ENTRY(indicate_rsp_rx) STATS_SECT_ENTRY(indicate_rsp_tx) - STATS_SECT_ENTRY(multi_notify_req_rx) - STATS_SECT_ENTRY(multi_notify_req_tx) STATS_SECT_ENTRY(write_cmd_rx) STATS_SECT_ENTRY(write_cmd_tx) STATS_SECT_END @@ -173,15 +171,13 @@ 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, uint16_t cid, - struct ble_hs_conn **out_conn, +int ble_att_conn_chan_find(uint16_t conn_handle, 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 */ @@ -194,38 +190,36 @@ 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, uint16_t cid, struct os_mbuf **rxom); +int ble_att_svr_rx_mtu(uint16_t conn_handle, 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, uint16_t cid, struct os_mbuf **rxom); -int ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid, +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, struct os_mbuf **rxom); -int ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_read_blob(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_read_mult_var(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read_mult_var(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_read_mult(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_write(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_write(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom); -int ble_att_svr_rx_signed_write(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, +int ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom); +int ble_att_svr_rx_signed_write(uint16_t conn_handle, struct os_mbuf **rxom); +int ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_exec_write(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_notify(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_notify(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_svr_rx_notify_multi(uint16_t conn_handle, uint16_t cid, - struct os_mbuf **rxom); -int ble_att_svr_rx_indicate(uint16_t conn_handle, uint16_t cid, +int ble_att_svr_rx_indicate(uint16_t conn_handle, 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, @@ -237,7 +231,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, uint16_t cid, struct os_mbuf *txom, +int ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom, uint8_t req_op, uint16_t handle, uint8_t error_code); /*** $clt */ @@ -270,56 +264,52 @@ struct ble_att_read_group_type_adata { uint8_t *value; }; -int ble_att_clt_rx_error(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom); +int ble_att_clt_rx_error(uint16_t conn_handle, 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, 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, +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, uint16_t offset); -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, +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, const uint16_t *handles, int num_handles, bool variable); -int ble_att_clt_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom); -int ble_att_clt_rx_read_mult_var(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, +int ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom); +int ble_att_clt_rx_read_mult_var(uint16_t conn_handle, struct os_mbuf **rxom); +int ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid); -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, +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, 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, uint16_t cid, +int ble_att_clt_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom); -int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t cid, uint16_t start_handle, +int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle, uint16_t end_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, +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, 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, uint16_t cid, +int ble_att_clt_rx_find_type_value(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_tx_signed_write_cmd(uint16_t conn_handle, uint16_t cid, - uint16_t handle, uint8_t * csrk, - uint32_t counter, struct os_mbuf * txom); -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_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_tx_signed_write_cmd(uint16_t conn_handle, uint16_t handle, + uint8_t * csrk, uint32_t counter, + struct os_mbuf * txom); +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_notify(uint16_t conn_handle, uint16_t handle, struct os_mbuf *txom); -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); -int ble_att_clt_tx_multi_notify(uint16_t conn_handle, struct os_mbuf * om); +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); #ifdef __cplusplus } diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c index 4b905c8f9..f15b4b0b2 100644 --- a/nimble/host/src/ble_att_svr.c +++ b/nimble/host/src/ble_att_svr.c @@ -623,7 +623,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, uint16_t cid, struct os_mbuf *txom, +ble_att_svr_tx_error_rsp(uint16_t conn_handle, struct os_mbuf *txom, uint8_t req_op, uint16_t handle, uint8_t error_code) { struct ble_att_error_rsp *rsp; @@ -640,7 +640,7 @@ ble_att_svr_tx_error_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txo rsp->baep_handle = htole16(handle); rsp->baep_error_code = error_code; - return ble_att_tx(conn_handle, cid, txom); + return ble_att_tx(conn_handle, txom); } /** @@ -667,10 +667,13 @@ ble_att_svr_tx_error_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txo * field. */ static int -ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_mbuf *om, +ble_att_svr_tx_rsp(uint16_t conn_handle, int hs_status, struct os_mbuf *om, uint8_t att_op, uint8_t err_status, uint16_t err_handle) { + struct ble_l2cap_chan *chan; + struct ble_hs_conn *conn; int do_tx; + int rc; if (hs_status != 0 && err_status == 0) { /* Processing failed, but err_status of 0 means don't send error. */ @@ -680,14 +683,28 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_ } if (do_tx) { - if (hs_status == 0) { - hs_status = ble_att_tx(conn_handle, cid, om); - om = NULL; - if (hs_status) { - err_status = BLE_ATT_ERR_UNLIKELY; - } + ble_hs_lock(); + + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); + if (rc != 0) { + /* No longer connected. */ + hs_status = rc; + } else { + if (hs_status == 0) { + BLE_HS_DBG_ASSERT(om != NULL); + + ble_att_inc_tx_stat(om->om_data[0]); + ble_att_truncate_to_mtu(chan, om); + hs_status = ble_l2cap_tx(conn, chan, om); + om = NULL; + if (hs_status != 0) { + err_status = BLE_ATT_ERR_UNLIKELY; + } + } } + ble_hs_unlock(); + if (hs_status != 0) { STATS_INC(ble_att_stats, error_rsp_tx); @@ -698,7 +715,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_ os_mbuf_adj(om, OS_MBUF_PKTLEN(om)); } if (om != NULL) { - ble_att_svr_tx_error_rsp(conn_handle, cid, om, att_op, + ble_att_svr_tx_error_rsp(conn_handle, om, att_op, err_handle, err_status); om = NULL; } @@ -725,7 +742,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, BLE_L2CAP_CID_ATT, NULL, &chan); + rc = ble_att_conn_chan_find(conn_handle, NULL, &chan); if (rc == 0) { mtu = chan->my_mtu; } @@ -757,7 +774,7 @@ done: } int -ble_att_svr_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom) { struct ble_att_mtu_cmd *cmd; struct ble_l2cap_chan *chan; @@ -770,10 +787,6 @@ ble_att_svr_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) txom = NULL; mtu = 0; - if (cid != BLE_L2CAP_CID_ATT) { - return BLE_HS_ENOTSUP; - } - rc = ble_att_svr_pullup_req_base(rxom, sizeof(*cmd), &att_err); if (rc != 0) { goto done; @@ -791,12 +804,12 @@ ble_att_svr_rx_mtu(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, BLE_L2CAP_CID_ATT, rc, txom, BLE_ATT_OP_MTU_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_MTU_REQ, att_err, 0); if (rc == 0) { ble_hs_lock(); - rc = ble_att_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); if (rc == 0) { ble_att_set_peer_mtu(chan, mtu); chan->flags |= BLE_L2CAP_CHAN_F_TXED_MTU; @@ -895,7 +908,7 @@ done: } static int -ble_att_svr_build_find_info_rsp(uint16_t conn_handle, uint16_t cid, +ble_att_svr_build_find_info_rsp(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, struct os_mbuf **rxom, struct os_mbuf **out_txom, @@ -924,7 +937,7 @@ ble_att_svr_build_find_info_rsp(uint16_t conn_handle, uint16_t cid, /* Write the variable length Information Data field, populating the format * field as appropriate. */ - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); rc = ble_att_svr_fill_info(start_handle, end_handle, txom, mtu, &rsp->bafp_format); if (rc != 0) { @@ -941,7 +954,7 @@ done: } int -ble_att_svr_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_FIND_INFO) return BLE_HS_ENOTSUP; @@ -978,7 +991,7 @@ ble_att_svr_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx goto done; } - rc = ble_att_svr_build_find_info_rsp(conn_handle, cid, + rc = ble_att_svr_build_find_info_rsp(conn_handle, start_handle, end_handle, rxom, &txom, &att_err); if (rc != 0) { @@ -989,7 +1002,7 @@ ble_att_svr_rx_find_info(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_FIND_INFO_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_FIND_INFO_REQ, att_err, err_handle); return rc; } @@ -1204,7 +1217,7 @@ done: } static int -ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle, uint16_t cid, +ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, ble_uuid16_t attr_type, @@ -1231,7 +1244,7 @@ ble_att_svr_build_find_type_value_rsp(uint16_t conn_handle, uint16_t cid, } /* Write the variable length Information Data field. */ - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); rc = ble_att_svr_fill_type_value(conn_handle, start_handle, end_handle, attr_type, *rxom, txom, mtu, @@ -1248,7 +1261,7 @@ done: } int -ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_find_type_value(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_FIND_TYPE) return BLE_HS_ENOTSUP; @@ -1286,7 +1299,7 @@ ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbu rc = BLE_HS_EBADDATA; goto done; } - rc = ble_att_svr_build_find_type_value_rsp(conn_handle, cid, start_handle, + rc = ble_att_svr_build_find_type_value_rsp(conn_handle, start_handle, end_handle, attr_type, rxom, &txom, &att_err); if (rc != 0) { @@ -1297,7 +1310,7 @@ ble_att_svr_rx_find_type_value(uint16_t conn_handle, uint16_t cid, struct os_mbu rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_FIND_TYPE_VALUE_REQ, att_err, err_handle); return rc; @@ -1335,7 +1348,7 @@ static uint8_t * ble_att_svr_get_csfs(uint16_t conn_handle) { #endif static int -ble_att_svr_build_read_type_rsp(uint16_t conn_handle, uint16_t cid, +ble_att_svr_build_read_type_rsp(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *uuid, struct os_mbuf **rxom, @@ -1378,7 +1391,7 @@ ble_att_svr_build_read_type_rsp(uint16_t conn_handle, uint16_t cid, goto done; } - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); /* Find all matching attributes, writing a record for each. */ entry = NULL; @@ -1450,7 +1463,7 @@ done: } int -ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ_TYPE) return BLE_HS_ENOTSUP; @@ -1511,7 +1524,7 @@ ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx goto done; } #endif - rc = ble_att_svr_build_read_type_rsp(conn_handle, cid, start_handle, end_handle, + rc = ble_att_svr_build_read_type_rsp(conn_handle, start_handle, end_handle, &uuid.u, rxom, &txom, &att_err, &err_handle); if (rc != 0) { @@ -1521,13 +1534,13 @@ ble_att_svr_rx_read_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_TYPE_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_TYPE_REQ, att_err, err_handle); return rc; } int -ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ) return BLE_HS_ENOTSUP; @@ -1584,13 +1597,13 @@ ble_att_svr_rx_read(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) } done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_REQ, att_err, err_handle); return rc; } int -ble_att_svr_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read_blob(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ_BLOB) return BLE_HS_ENOTSUP; @@ -1652,13 +1665,13 @@ ble_att_svr_rx_read_blob(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_BLOB_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, 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, uint16_t cid, +ble_att_svr_build_read_mult_rsp(uint16_t conn_handle, struct os_mbuf **rxom, struct os_mbuf **out_txom, uint8_t *att_err, @@ -1669,7 +1682,7 @@ ble_att_svr_build_read_mult_rsp(uint16_t conn_handle, uint16_t cid, uint16_t mtu; int rc; - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); rc = ble_att_svr_pkt(rxom, &txom, att_err); if (rc != 0) { @@ -1719,7 +1732,7 @@ done: } int -ble_att_svr_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ_MULT) return BLE_HS_ENOTSUP; @@ -1750,18 +1763,18 @@ ble_att_svr_rx_read_mult(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx ble_hs_unlock(); #endif - rc = ble_att_svr_build_read_mult_rsp(conn_handle, cid, rxom, &txom, &att_err, + rc = ble_att_svr_build_read_mult_rsp(conn_handle, rxom, &txom, &att_err, &err_handle); #if MYNEWT_VAL(BLE_GATT_CACHING) done : #endif - return ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_READ_MULT_REQ, + return ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_MULT_REQ, att_err, err_handle); } static int -ble_att_svr_build_read_mult_rsp_var(uint16_t conn_handle, uint16_t cid, +ble_att_svr_build_read_mult_rsp_var(uint16_t conn_handle, struct os_mbuf **rxom, struct os_mbuf **out_txom, uint8_t *att_err, @@ -1774,7 +1787,7 @@ ble_att_svr_build_read_mult_rsp_var(uint16_t conn_handle, uint16_t cid, struct os_mbuf *tmp = NULL; int rc; - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); rc = ble_att_svr_pkt(rxom, &txom, att_err); if (rc != 0) { @@ -1843,7 +1856,7 @@ done: } int -ble_att_svr_rx_read_mult_var(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read_mult_var(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ_MULT) return BLE_HS_ENOTSUP; @@ -1874,13 +1887,13 @@ ble_att_svr_rx_read_mult_var(uint16_t conn_handle, uint16_t cid, struct os_mbuf ble_hs_unlock(); #endif - rc = ble_att_svr_build_read_mult_rsp_var(conn_handle, cid, rxom, &txom, &att_err, + rc = ble_att_svr_build_read_mult_rsp_var(conn_handle, rxom, &txom, &att_err, &err_handle); #if MYNEWT_VAL(BLE_GATT_CACHING) done: #endif - return ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, + return ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_MULT_VAR_REQ, att_err, err_handle); } @@ -1949,7 +1962,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, uint16_t cid, +ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, const ble_uuid_t *group_uuid, @@ -1979,7 +1992,7 @@ ble_att_svr_build_read_group_type_rsp(uint16_t conn_handle, uint16_t cid, entry = NULL; - mtu = ble_att_mtu_by_cid(conn_handle, cid); + mtu = ble_att_mtu(conn_handle); /* Just reuse the request buffer for the response. */ txom = *rxom; @@ -2121,7 +2134,7 @@ done: } int -ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_read_group_type(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_READ_GROUP_TYPE) return BLE_HS_ENOTSUP; @@ -2190,10 +2203,9 @@ ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbu goto done; } - rc = ble_att_svr_build_read_group_type_rsp(conn_handle, cid, - start_handle, end_handle, - &uuid.u, rxom, - &txom, &att_err, + rc = ble_att_svr_build_read_group_type_rsp(conn_handle, start_handle, + end_handle, &uuid.u, + rxom, &txom, &att_err, &err_handle); if (rc != 0) { goto done; @@ -2202,7 +2214,7 @@ ble_att_svr_rx_read_group_type(uint16_t conn_handle, uint16_t cid, struct os_mbu rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_READ_GROUP_TYPE_REQ, att_err, err_handle); return rc; @@ -2237,7 +2249,7 @@ done: } int -ble_att_svr_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_WRITE) return BLE_HS_ENOTSUP; @@ -2297,13 +2309,13 @@ ble_att_svr_rx_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_WRITE_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_WRITE_REQ, att_err, handle); return rc; } int -ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_WRITE_NO_RSP) return BLE_HS_ENOTSUP; @@ -2340,9 +2352,9 @@ ble_att_svr_rx_write_no_rsp(uint16_t conn_handle, uint16_t cid, struct os_mbuf * } int -ble_att_svr_rx_signed_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_signed_write(uint16_t conn_handle, struct os_mbuf **rxom) { -#if !MYNEWT_VAL(BLE_ATT_SVR_SIGNED_WRITE) || MYNEWT_VAL(BLE_EATT_CHAN_NUM) +#if !MYNEWT_VAL(BLE_ATT_SVR_SIGNED_WRITE) return BLE_HS_ENOTSUP; #endif @@ -2715,7 +2727,7 @@ ble_att_svr_insert_prep_entry(uint16_t conn_handle, } int -ble_att_svr_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE) return BLE_HS_ENOTSUP; @@ -2805,13 +2817,13 @@ ble_att_svr_rx_prep_write(uint16_t conn_handle, uint16_t cid, struct os_mbuf **r rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_PREP_WRITE_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, 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, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_QUEUED_WRITE) return BLE_HS_ENOTSUP; @@ -2895,13 +2907,13 @@ done: ble_att_svr_prep_clear(&prep_list); } - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_EXEC_WRITE_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_EXEC_WRITE_REQ, att_err, err_handle); return rc; } int -ble_att_svr_rx_notify(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_notify(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_NOTIFY) return BLE_HS_ENOTSUP; @@ -2943,69 +2955,6 @@ ble_att_svr_rx_notify(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) return 0; } -int -ble_att_svr_rx_notify_multi(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) -{ -#if !MYNEWT_VAL(BLE_ATT_SVR_NOTIFY_MULTI) - return BLE_HS_ENOTSUP; -#endif - - struct ble_att_tuple_list *req; - uint16_t handle; - int rc; - uint16_t pkt_len; - struct os_mbuf *tmp; - uint16_t attr_len; - - pkt_len = OS_MBUF_PKTLEN(*rxom); - while (pkt_len > 0) { - rc = ble_att_svr_pullup_req_base(rxom, sizeof(struct ble_att_tuple_list), NULL); - if (rc != 0) { - return BLE_HS_ENOMEM; - } - - req = (struct ble_att_tuple_list *)(*rxom)->om_data; - - handle = le16toh(req->handle); - attr_len = le16toh(req->value_len); - - os_mbuf_adj(*rxom, 4); - - if (attr_len > BLE_ATT_ATTR_MAX_LEN) { - BLE_HS_LOG_ERROR("attr length (%d) > max (%d)", - attr_len, BLE_ATT_ATTR_MAX_LEN); - rc = BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; - goto done; - } - - tmp = os_msys_get_pkthdr(attr_len, 0); - if (!tmp) { - BLE_HS_LOG_ERROR("not enough resources, aborting"); - rc = BLE_ATT_ERR_INSUFFICIENT_RES; - goto done; - } - - rc = os_mbuf_appendfrom(tmp, *rxom, 0, attr_len); - if (rc) { - BLE_HS_LOG_ERROR("not enough resources, aborting"); - rc = BLE_ATT_ERR_INSUFFICIENT_RES; - goto done; - } - - ble_gap_notify_rx_event(conn_handle, handle, tmp, 0); - - os_mbuf_adj(*rxom, attr_len); - pkt_len = OS_MBUF_PKTLEN(*rxom); - } - - rc = 0; -done: - os_mbuf_free_chain(*rxom); - *rxom = NULL; - - return rc; -} - /** * @return 0 on success; nonzero on failure. */ @@ -3039,7 +2988,7 @@ done: } int -ble_att_svr_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxom) +ble_att_svr_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom) { #if !MYNEWT_VAL(BLE_ATT_SVR_INDICATE) return BLE_HS_ENOTSUP; @@ -3097,7 +3046,7 @@ ble_att_svr_rx_indicate(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rxo rc = 0; done: - rc = ble_att_svr_tx_rsp(conn_handle, cid, rc, txom, BLE_ATT_OP_INDICATE_REQ, + rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_INDICATE_REQ, att_err, handle); return rc; } diff --git a/nimble/host/src/ble_eatt.c b/nimble/host/src/ble_eatt.c deleted file mode 100644 index 86e237fb3..000000000 --- a/nimble/host/src/ble_eatt.c +++ /dev/null @@ -1,601 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "syscfg/syscfg.h" - -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - -#include -#include -#include "host/ble_hs_log.h" -#include "ble_att_cmd_priv.h" -#include "ble_hs_priv.h" -#include "ble_l2cap_priv.h" -#include "ble_eatt_priv.h" -#include "services/gatt/ble_svc_gatt.h" - -struct ble_eatt { - SLIST_ENTRY(ble_eatt) next; - uint16_t conn_handle; - struct ble_l2cap_chan *chan; - uint8_t client_op; - - /* Packet transmit queue */ - STAILQ_HEAD(, os_mbuf_pkthdr) eatt_tx_q; - - struct ble_npl_event setup_ev; - struct ble_npl_event wakeup_ev; -}; - -SLIST_HEAD(ble_eatt_list, ble_eatt); - -static struct ble_eatt_list g_ble_eatt_list; -static ble_eatt_att_rx_fn ble_eatt_att_rx_cb; - -#define BLE_EATT_DATABUF_SIZE ( \ - MYNEWT_VAL(BLE_EATT_MTU) + \ - 2 + \ - sizeof (struct os_mbuf_pkthdr) + \ - sizeof (struct os_mbuf)) - -#define BLE_EATT_MEMBLOCK_SIZE \ - (OS_ALIGN(BLE_EATT_DATABUF_SIZE, 4)) - -#define BLE_EATT_MEMPOOL_SIZE \ - OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_EATT_CHAN_NUM) + 1, BLE_EATT_MEMBLOCK_SIZE) -static os_membuf_t ble_eatt_conn_mem[ - OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_EATT_CHAN_NUM), - sizeof(struct ble_eatt)) -]; -static struct os_mempool ble_eatt_conn_pool; -static os_membuf_t ble_eatt_sdu_coc_mem[BLE_EATT_MEMPOOL_SIZE]; -struct os_mbuf_pool ble_eatt_sdu_os_mbuf_pool; -static struct os_mempool ble_eatt_sdu_mbuf_mempool; - -static struct ble_gap_event_listener ble_eatt_listener; - -static struct ble_npl_event g_read_sup_cl_feat_ev; -static struct ble_npl_event g_read_sup_srv_feat_ev; - -static void ble_eatt_setup_cb(struct ble_npl_event *ev); -static void ble_eatt_start(uint16_t conn_handle); - -static struct ble_eatt * -ble_eatt_find_not_busy(uint16_t conn_handle) -{ - struct ble_eatt *eatt; - - SLIST_FOREACH(eatt, &g_ble_eatt_list, next) { - if ((eatt->conn_handle == conn_handle) && !eatt->client_op && eatt->chan) { - return eatt; - } - } - return NULL; -} - -static struct ble_eatt * -ble_eatt_find_by_conn_handle(uint16_t conn_handle) -{ - struct ble_eatt *eatt; - - SLIST_FOREACH(eatt, &g_ble_eatt_list, next) { - if (eatt->conn_handle == conn_handle) { - return eatt; - } - } - return NULL; - -} - -static struct ble_eatt * -ble_eatt_find_by_conn_handle_and_busy_op(uint16_t conn_handle, uint8_t op) -{ - struct ble_eatt *eatt; - - SLIST_FOREACH(eatt, &g_ble_eatt_list, next) { - if (eatt->conn_handle == conn_handle && eatt->client_op == op) { - return eatt; - } - } - return NULL; - -} - -static struct ble_eatt * -ble_eatt_find(uint16_t conn_handle, uint16_t cid) -{ - struct ble_eatt *eatt; - - SLIST_FOREACH(eatt, &g_ble_eatt_list, next) { - if ((eatt->conn_handle == conn_handle) && - (eatt->chan) && - (eatt->chan->scid == cid)) { - return eatt; - } - } - return NULL; - -} - -static int -ble_eatt_prepare_rx_sdu(struct ble_l2cap_chan *chan) -{ - int rc; - struct os_mbuf *om; - - om = os_mbuf_get_pkthdr(&ble_eatt_sdu_os_mbuf_pool, 0); - if (!om) { - BLE_EATT_LOG_ERROR("eatt: no memory for sdu\n"); - return BLE_HS_ENOMEM; - } - - rc = ble_l2cap_recv_ready(chan, om); - if (rc) { - BLE_EATT_LOG_ERROR("eatt: Failed to supply RX SDU conn_handle 0x%04x (status=%d)\n", - chan->conn_handle, rc); - os_mbuf_free_chain(om); - } - return rc; -} - -static void -ble_eatt_wakeup_cb(struct ble_npl_event *ev) -{ - struct ble_eatt *eatt; - struct os_mbuf *txom; - struct os_mbuf_pkthdr *omp; - struct ble_l2cap_chan_info info; - - eatt = ble_npl_event_get_arg(ev); - assert(eatt); - - omp = STAILQ_FIRST(&eatt->eatt_tx_q); - if (omp != NULL) { - STAILQ_REMOVE_HEAD(&eatt->eatt_tx_q, omp_next); - - txom = OS_MBUF_PKTHDR_TO_MBUF(omp); - ble_l2cap_get_chan_info(eatt->chan, &info); - ble_eatt_tx(eatt->conn_handle, info.dcid, txom); - } -} - -static struct ble_eatt * -ble_eatt_alloc(void) -{ - struct ble_eatt *eatt; - - eatt = os_memblock_get(&ble_eatt_conn_pool); - if (eatt) { - SLIST_INSERT_HEAD(&g_ble_eatt_list, eatt, next); - } else { - BLE_EATT_LOG_DEBUG("eatt: Failed to allocate new eatt context\n"); - return NULL; - } - - eatt->conn_handle = BLE_HS_CONN_HANDLE_NONE; - eatt->chan = NULL; - eatt->client_op = 0; - - STAILQ_INIT(&eatt->eatt_tx_q); - ble_npl_event_init(&eatt->setup_ev, ble_eatt_setup_cb, eatt); - ble_npl_event_init(&eatt->wakeup_ev, ble_eatt_wakeup_cb, eatt); - return eatt; -} - -static void -ble_eatt_free(struct ble_eatt *eatt) -{ - struct os_mbuf_pkthdr *omp; - - while ((omp = STAILQ_FIRST(&eatt->eatt_tx_q)) != NULL) { - STAILQ_REMOVE_HEAD(&eatt->eatt_tx_q, omp_next); - os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp)); - } - - SLIST_REMOVE(&g_ble_eatt_list, eatt, ble_eatt, next); - os_memblock_put(&ble_eatt_conn_pool, eatt); -} - -static int -ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg) -{ - struct ble_eatt *eatt = arg; - struct ble_gap_conn_desc desc; - uint8_t opcode; - int rc; - - switch (event->type) { - case BLE_L2CAP_EVENT_COC_CONNECTED: - BLE_EATT_LOG_DEBUG("eatt: Connected \n"); - if (event->connect.status) { - ble_eatt_free(eatt); - return 0; - } - eatt->chan = event->connect.chan; - ble_gap_eatt_event(event->connect.conn_handle, 0, event->connect.chan->scid); - break; - case BLE_L2CAP_EVENT_COC_DISCONNECTED: - BLE_EATT_LOG_DEBUG("eatt: Disconnected \n"); - ble_eatt_free(eatt); - ble_gap_eatt_event(event->disconnect.conn_handle, 1, event->disconnect.chan->scid); - break; - case BLE_L2CAP_EVENT_COC_ACCEPT: - BLE_EATT_LOG_DEBUG("eatt: Accept request\n"); - - eatt = ble_eatt_alloc(); - if (!eatt) { - return BLE_HS_ENOMEM; - } - eatt->conn_handle = event->accept.conn_handle; - event->accept.chan->cb_arg = eatt; - - rc = ble_eatt_prepare_rx_sdu(event->accept.chan); - if (rc) { - ble_eatt_free(eatt); - return rc; - } - break; - case BLE_L2CAP_EVENT_COC_TX_UNSTALLED: - ble_npl_eventq_put(ble_hs_evq_get(), &eatt->wakeup_ev); - break; - case BLE_L2CAP_EVENT_COC_DATA_RECEIVED: - assert(eatt->chan == event->receive.chan); - opcode = event->receive.sdu_rx->om_data[0]; - if (ble_att_is_response_op(opcode)) { - ble_npl_eventq_put(ble_hs_evq_get(), &eatt->wakeup_ev); - } else if (!ble_att_is_request_op(opcode)) { - /* As per BLE 5.4 Standard, Vol. 3, Part G, section 5.3.2 - * (ENHANCED ATT BEARER L2CAP INTEROPERABILITY REQUIREMENTS: - * Channel Requirements): - * All packets sent on this L2CAP channel shall be Attribute PDUs. - * - * Disconnect peer with invalid behavior. - */ - ble_l2cap_disconnect(eatt->chan); - return BLE_HS_EREJECT; - } - - assert (!ble_gap_conn_find(event->receive.conn_handle, &desc)); - /* As per BLE 5.4 Standard, Vol. 3, Part G, section 5.3.2 - * (ENHANCED ATT BEARER L2CAP INTEROPERABILITY REQUIREMENTS: - * Channel Requirements): - * The channel shall be encrypted. - * - * Disconnect peer with invalid behavior - ATT PDU received before - * encryption. - */ - if (!desc.sec_state.encrypted) { - ble_l2cap_disconnect(eatt->chan); - return BLE_HS_EREJECT; - } - - ble_eatt_att_rx_cb(event->receive.conn_handle, eatt->chan->scid, &event->receive.sdu_rx); - if (event->receive.sdu_rx) { - os_mbuf_free_chain(event->receive.sdu_rx); - event->receive.sdu_rx = NULL; - } - rc = ble_eatt_prepare_rx_sdu(event->receive.chan); - if (rc) { - /* Receiving L2CAP data is no longer possible, terminate connection */ - ble_l2cap_disconnect(eatt->chan); - return BLE_HS_ENOMEM; - } - break; - default: - break; - } - - return 0; -} - -static void -ble_eatt_setup_cb(struct ble_npl_event *ev) -{ - struct ble_eatt *eatt; - struct os_mbuf *om; - int rc; - - eatt = ble_npl_event_get_arg(ev); - assert(eatt); - - om = os_mbuf_get_pkthdr(&ble_eatt_sdu_os_mbuf_pool, 0); - if (!om) { - ble_eatt_free(eatt); - BLE_EATT_LOG_ERROR("eatt: no memory for sdu\n"); - return; - } - - BLE_EATT_LOG_DEBUG("eatt: connecting eatt on conn_handle 0x%04x\n", eatt->conn_handle); - rc = ble_l2cap_enhanced_connect(eatt->conn_handle, BLE_EATT_PSM, - MYNEWT_VAL(BLE_EATT_MTU), 1, &om, ble_eatt_l2cap_event_fn, eatt); - if (rc) { - BLE_EATT_LOG_ERROR("eatt: Failed to connect EATT on conn_handle 0x%04x (status=%d)\n", - eatt->conn_handle, rc); - os_mbuf_free_chain(om); - ble_eatt_free(eatt); - } -} - -static int -ble_gatt_eatt_write_cl_cb(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, void *arg) -{ - if (error == NULL || (error->status != 0 && error->status != BLE_HS_EDONE)) { - BLE_EATT_LOG_DEBUG("eatt: Cannot write to Client Supported features on peer device\n"); - return 0; - } - - ble_eatt_start(conn_handle); - return 0; -} - -static int -ble_gatt_eatt_read_cl_uuid_cb(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, void *arg) -{ - uint8_t client_supported_feat; - int rc; - - if (error == NULL || (error->status != 0 && error->status != BLE_HS_EDONE)) { - BLE_EATT_LOG_DEBUG("eatt: Cannot find Client Supported features on peer device\n"); - return BLE_HS_EDONE; - } - - if (attr == NULL) { - BLE_EATT_LOG_ERROR("eatt: Invalid attribute \n"); - return BLE_HS_EDONE; - } - - if (error->status == 0) { - client_supported_feat = MYNEWT_VAL(BLE_CLIENT_SUPPORTED_FEATURES); - rc = ble_gattc_write_flat(conn_handle, attr->handle, &client_supported_feat, 1, - ble_gatt_eatt_write_cl_cb, NULL); - BLE_EATT_LOG_DEBUG("eatt: %s , write rc = %d \n", __func__, rc); - assert(rc == 0); - return 0; - } - - return BLE_HS_EDONE; -} - -static int -ble_gatt_eatt_read_uuid_cb(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, void *arg) -{ - uint8_t supported_features; - int rc; - - if (error == NULL || (error->status != 0 && error->status != BLE_HS_EDONE)) { - BLE_EATT_LOG_DEBUG("eatt: Cannot find Server Supported features on peer device\n"); - return BLE_HS_EDONE; - } - - if (attr == NULL) { - BLE_EATT_LOG_ERROR("eatt: Invalid attribute \n"); - return BLE_HS_EDONE; - } - - rc = os_mbuf_copydata(attr->om, 0, 1, &supported_features); - if (rc) { - BLE_EATT_LOG_ERROR("eatt: Cannot read srv supported features \n"); - return BLE_HS_EDONE; - } - - if (supported_features & 0x01) { - ble_npl_event_set_arg(&g_read_sup_cl_feat_ev, (void *)((uintptr_t) conn_handle)); - ble_npl_eventq_put(ble_hs_evq_get(), &g_read_sup_cl_feat_ev); - } - return BLE_HS_EDONE; -} - -static void -ble_gatt_eatt_read_svr_uuid(struct ble_npl_event *ev) -{ - uint16_t conn_handle; - - conn_handle = (uint16_t)((uintptr_t)(ble_npl_event_get_arg(ev))); - - ble_gattc_read_by_uuid(conn_handle, 1, 0xffff, - BLE_UUID16_DECLARE(BLE_SVC_GATT_CHR_SERVER_SUPPORTED_FEAT_UUID16), - ble_gatt_eatt_read_uuid_cb, NULL); -} - -static void -ble_gatt_eatt_read_cl_uuid(struct ble_npl_event *ev) -{ - uint16_t conn_handle; - - conn_handle = (uint16_t)((uintptr_t)(ble_npl_event_get_arg(ev))); - - ble_gattc_read_by_uuid(conn_handle, 1, 0xffff, - BLE_UUID16_DECLARE(BLE_SVC_GATT_CHR_CLIENT_SUPPORTED_FEAT_UUID16), - ble_gatt_eatt_read_cl_uuid_cb, NULL); -} - -static int -ble_eatt_gap_event(struct ble_gap_event *event, void *arg) -{ - struct ble_eatt *eatt; - - switch (event->type) { - case BLE_GAP_EVENT_ENC_CHANGE: - if (event->enc_change.status != 0) { - return 0; - } - - /* Don't try to connect if already connected */ - if (ble_eatt_find_by_conn_handle(event->enc_change.conn_handle)) { - return 0; - } - - BLE_EATT_LOG_DEBUG("eatt: Encryption enabled, connecting EATT (conn_handle=0x%04x)\n", - event->enc_change.conn_handle); - - ble_npl_event_set_arg(&g_read_sup_srv_feat_ev, (void *)((uintptr_t)(event->enc_change.conn_handle))); - ble_npl_eventq_put(ble_hs_evq_get(), &g_read_sup_srv_feat_ev); - - break; - case BLE_GAP_EVENT_DISCONNECT: - eatt = ble_eatt_find_by_conn_handle(event->disconnect.conn.conn_handle); - assert(eatt == NULL); - break; - default: - break; - } - return 0; -} - -uint16_t -ble_eatt_get_available_chan_cid(uint16_t conn_handle, uint8_t op) -{ - uint16_t default_cid; - struct ble_eatt * eatt; - - default_cid = ble_att_get_default_bearer_cid(conn_handle); - if (default_cid) { - eatt = ble_eatt_find(conn_handle, default_cid); - } else { - eatt = ble_eatt_find_not_busy(conn_handle); - } - if (!eatt) { - return BLE_L2CAP_CID_ATT; - } - - eatt->client_op = op; - return eatt->chan->scid; -} - - -void -ble_eatt_release_chan(uint16_t conn_handle, uint8_t op) -{ - struct ble_eatt * eatt; - - eatt = ble_eatt_find_by_conn_handle_and_busy_op(conn_handle, op); - if (!eatt) { - BLE_EATT_LOG_DEBUG("ble_eatt_release_chan:" - "EATT not found for conn_handle 0x%04x, operation 0x%02\n", conn_handle, op); - return; - } - - eatt->client_op = 0; -} - -int -ble_eatt_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom) -{ - struct ble_eatt *eatt; - int rc; - - BLE_EATT_LOG_DEBUG("eatt: %s, size %d ", __func__, OS_MBUF_PKTLEN(txom)); - eatt = ble_eatt_find(conn_handle, cid); - if (!eatt || !eatt->chan) { - BLE_EATT_LOG_ERROR("Eatt not available"); - rc = BLE_HS_ENOENT; - goto error; - } - - ble_att_truncate_to_mtu(eatt->chan, txom); - rc = ble_l2cap_send(eatt->chan, txom); - if (rc == 0) { - goto done; - } - - if (rc == BLE_HS_ESTALLED) { - BLE_EATT_LOG_DEBUG("ble_eatt_tx: Eatt stalled"); - } else if (rc == BLE_HS_EBUSY) { - BLE_EATT_LOG_DEBUG("ble_eatt_tx: Message queued"); - STAILQ_INSERT_HEAD(&eatt->eatt_tx_q, OS_MBUF_PKTHDR(txom), omp_next); - ble_npl_eventq_put(ble_hs_evq_get(), &eatt->wakeup_ev); - } else { - BLE_EATT_LOG_ERROR("eatt: %s, ERROR %d ", __func__, rc); - assert(0); - } -done: - return 0; - -error: - os_mbuf_free_chain(txom); - return rc; -} - -static void -ble_eatt_start(uint16_t conn_handle) -{ - struct ble_gap_conn_desc desc; - struct ble_eatt *eatt; - int rc; - - rc = ble_gap_conn_find(conn_handle, &desc); - assert(rc == 0); - if (desc.role != BLE_GAP_ROLE_MASTER) { - /* Let master to create ecoc. - */ - return; - } - - for (int i = 0; i < MYNEWT_VAL(BLE_EATT_CHAN_NUM); i++) { - eatt = ble_eatt_alloc(); - if (!eatt) { - return; - } - - eatt->conn_handle = conn_handle; - - /* Setup EATT */ - ble_npl_eventq_put(ble_hs_evq_get(), &eatt->setup_ev); - eatt = NULL; - } -} - -void -ble_eatt_init(ble_eatt_att_rx_fn att_rx_cb) -{ - int rc; - - rc = os_mempool_init(&ble_eatt_sdu_mbuf_mempool, - MYNEWT_VAL(BLE_EATT_CHAN_NUM) + 1, - BLE_EATT_MEMBLOCK_SIZE, - ble_eatt_sdu_coc_mem, - "ble_eatt_sdu"); - BLE_HS_DBG_ASSERT_EVAL(rc == 0); - - rc = os_mbuf_pool_init(&ble_eatt_sdu_os_mbuf_pool, - &ble_eatt_sdu_mbuf_mempool, - BLE_EATT_MEMBLOCK_SIZE, - MYNEWT_VAL(BLE_EATT_CHAN_NUM) + 1); - BLE_HS_DBG_ASSERT_EVAL(rc == 0); - - rc = os_mempool_init(&ble_eatt_conn_pool, MYNEWT_VAL(BLE_EATT_CHAN_NUM), - sizeof (struct ble_eatt), - ble_eatt_conn_mem, "ble_eatt_conn_pool"); - BLE_HS_DBG_ASSERT_EVAL(rc == 0); - - rc = ble_gap_event_listener_register(&ble_eatt_listener, ble_eatt_gap_event, NULL); - ble_l2cap_create_server(BLE_EATT_PSM, MYNEWT_VAL(BLE_EATT_MTU), ble_eatt_l2cap_event_fn, NULL); - - ble_npl_event_init(&g_read_sup_srv_feat_ev, ble_gatt_eatt_read_svr_uuid, NULL); - ble_npl_event_init(&g_read_sup_cl_feat_ev, ble_gatt_eatt_read_cl_uuid, NULL); - - ble_eatt_att_rx_cb = att_rx_cb; -} -#endif diff --git a/nimble/host/src/ble_eatt_priv.h b/nimble/host/src/ble_eatt_priv.h deleted file mode 100644 index 1797ce670..000000000 --- a/nimble/host/src/ble_eatt_priv.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include "syscfg/syscfg.h" -#include "os/os_mbuf.h" -#include "host/ble_l2cap.h" - -#ifndef BLE_EATT_H_ -#define BLE_EATT_H_ - -typedef int (* ble_eatt_att_rx_fn)(uint16_t conn_handle, uint16_t cid, struct os_mbuf **rx_buf); - -#define BLE_EATT_PSM (0x0027) - -#define BLE_GATT_OP_SERVER 0xF1 -#define BLE_GATT_OP_DUMMY 0xF2 - -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 -void ble_eatt_init(ble_eatt_att_rx_fn att_rx_fn); -uint16_t ble_eatt_get_available_chan_cid(uint16_t conn_handle, uint8_t op); -void ble_eatt_release_chan(uint16_t conn_handle, uint8_t op); -int ble_eatt_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom); -#else -static inline void -ble_eatt_init(ble_eatt_att_rx_fn att_rx_fn) -{ -} - -static inline void -ble_eatt_release_chan(uint16_t conn_handle, uint8_t op) -{ - -} - -static inline uint16_t -ble_eatt_get_available_chan_cid(uint16_t conn_handle, uint8_t op) -{ - return BLE_L2CAP_CID_ATT; -} - -#endif -#endif diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index c1d71eb0b..e216d04e5 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -7409,27 +7409,6 @@ ble_gap_end_test_evt(const void *buf, uint8_t len) ble_gap_event_listener_call(&event); } -/***************************************************************************** - * EATT * - *****************************************************************************/ -void -ble_gap_eatt_event(uint16_t conn_handle, uint8_t status, uint16_t cid) -{ -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) - struct ble_gap_event event; - - memset(&event, 0, sizeof event); - event.type = BLE_GAP_EVENT_EATT; - - event.eatt.conn_handle = conn_handle; - event.eatt.status = status; - event.eatt.cid = cid; - - ble_gap_event_listener_call(&event); - ble_gap_call_conn_event_cb(&event, conn_handle); -#endif -} - /***************************************************************************** * $preempt * *****************************************************************************/ diff --git a/nimble/host/src/ble_gap_priv.h b/nimble/host/src/ble_gap_priv.h index 37b0c0eac..5e05b8c67 100644 --- a/nimble/host/src/ble_gap_priv.h +++ b/nimble/host/src/ble_gap_priv.h @@ -143,7 +143,6 @@ int ble_gap_repeat_pairing_event(const struct ble_gap_repeat_pairing *rp); void ble_gap_pairing_complete_event(uint16_t conn_handle, int status); void ble_gap_vs_hci_event(const void *buf, uint8_t len); int ble_gap_authorize_event(uint16_t conn_handle, uint16_t attr_handle, int is_read); -void ble_gap_eatt_event(uint16_t conn_handle, uint8_t status, uint16_t cid); int ble_gap_master_in_progress(void); void ble_gap_preempt(void); diff --git a/nimble/host/src/ble_gatt_priv.h b/nimble/host/src/ble_gatt_priv.h index 538ffb141..34c10ed16 100644 --- a/nimble/host/src/ble_gatt_priv.h +++ b/nimble/host/src/ble_gatt_priv.h @@ -68,8 +68,6 @@ STATS_SECT_START(ble_gattc_stats) STATS_SECT_ENTRY(write_reliable_fail) STATS_SECT_ENTRY(notify) STATS_SECT_ENTRY(notify_fail) - STATS_SECT_ENTRY(multi_notify) - STATS_SECT_ENTRY(multi_notify_fail) STATS_SECT_ENTRY(indicate) STATS_SECT_ENTRY(indicate_fail) STATS_SECT_ENTRY(proc_timeout) @@ -129,32 +127,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 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, +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, struct ble_att_read_type_adata *adata); -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, +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, struct os_mbuf **rxom); -void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status, +void ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status, struct os_mbuf **rxom); -void ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status, +void ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status, struct os_mbuf **rxom, bool variable); -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, +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, uint16_t handle, uint16_t offset, struct os_mbuf **rxom); -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, +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, struct ble_att_find_info_idata *idata); -void ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, int status); +void ble_gattc_rx_find_info_complete(uint16_t conn_handle, 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); diff --git a/nimble/host/src/ble_gattc.c b/nimble/host/src/ble_gattc.c index 65a6f6728..0669b6c2f 100644 --- a/nimble/host/src/ble_gattc.c +++ b/nimble/host/src/ble_gattc.c @@ -110,7 +110,6 @@ struct ble_gattc_proc { uint32_t exp_os_ticks; uint16_t conn_handle; - uint16_t cid; uint8_t op; uint8_t flags; @@ -244,7 +243,6 @@ static ble_gattc_err_fn ble_gattc_read_err; static ble_gattc_err_fn ble_gattc_read_uuid_err; static ble_gattc_err_fn ble_gattc_read_long_err; static ble_gattc_err_fn ble_gattc_read_mult_err; -static ble_gattc_err_fn ble_gattc_read_mult_var_err; static ble_gattc_err_fn ble_gattc_write_err; static ble_gattc_err_fn ble_gattc_write_long_err; static ble_gattc_err_fn ble_gattc_write_reliable_err; @@ -262,7 +260,6 @@ static ble_gattc_err_fn * const ble_gattc_err_dispatch[BLE_GATT_OP_CNT] = { [BLE_GATT_OP_READ_UUID] = ble_gattc_read_uuid_err, [BLE_GATT_OP_READ_LONG] = ble_gattc_read_long_err, [BLE_GATT_OP_READ_MULT] = ble_gattc_read_mult_err, - [BLE_GATT_OP_READ_MULT_VAR] = ble_gattc_read_mult_var_err, [BLE_GATT_OP_WRITE] = ble_gattc_write_err, [BLE_GATT_OP_WRITE_LONG] = ble_gattc_write_long_err, [BLE_GATT_OP_WRITE_RELIABLE] = ble_gattc_write_reliable_err, @@ -298,7 +295,6 @@ ble_gattc_resume_dispatch[BLE_GATT_OP_CNT] = { [BLE_GATT_OP_READ_UUID] = NULL, [BLE_GATT_OP_READ_LONG] = ble_gattc_read_long_resume, [BLE_GATT_OP_READ_MULT] = NULL, - [BLE_GATT_OP_READ_MULT_VAR] = NULL, [BLE_GATT_OP_WRITE] = NULL, [BLE_GATT_OP_WRITE_LONG] = ble_gattc_write_long_resume, [BLE_GATT_OP_WRITE_RELIABLE] = ble_gattc_write_reliable_resume, @@ -322,7 +318,6 @@ static ble_gattc_tmo_fn ble_gattc_read_tmo; static ble_gattc_tmo_fn ble_gattc_read_uuid_tmo; static ble_gattc_tmo_fn ble_gattc_read_long_tmo; static ble_gattc_tmo_fn ble_gattc_read_mult_tmo; -static ble_gattc_tmo_fn ble_gattc_read_mult_var_tmo; static ble_gattc_tmo_fn ble_gattc_write_tmo; static ble_gattc_tmo_fn ble_gattc_write_long_tmo; static ble_gattc_tmo_fn ble_gattc_write_reliable_tmo; @@ -341,7 +336,6 @@ ble_gattc_tmo_dispatch[BLE_GATT_OP_CNT] = { [BLE_GATT_OP_READ_UUID] = ble_gattc_read_uuid_tmo, [BLE_GATT_OP_READ_LONG] = ble_gattc_read_long_tmo, [BLE_GATT_OP_READ_MULT] = ble_gattc_read_mult_tmo, - [BLE_GATT_OP_READ_MULT_VAR] = ble_gattc_read_mult_var_tmo, [BLE_GATT_OP_WRITE] = ble_gattc_write_tmo, [BLE_GATT_OP_WRITE_LONG] = ble_gattc_write_long_tmo, [BLE_GATT_OP_WRITE_RELIABLE] = ble_gattc_write_reliable_tmo, @@ -478,8 +472,6 @@ STATS_NAME_START(ble_gattc_stats) STATS_NAME(ble_gattc_stats, write_reliable_fail) STATS_NAME(ble_gattc_stats, notify) STATS_NAME(ble_gattc_stats, notify_fail) - STATS_NAME(ble_gattc_stats, multi_notify) - STATS_NAME(ble_gattc_stats, multi_notify_fail) STATS_NAME(ble_gattc_stats, indicate) STATS_NAME(ble_gattc_stats, indicate_fail) STATS_NAME(ble_gattc_stats, proc_timeout) @@ -661,15 +653,6 @@ ble_gattc_log_notify(uint16_t att_handle) BLE_HS_LOG(INFO, "att_handle=%d\n", att_handle); } -static void -ble_gattc_log_multi_notify(struct ble_gatt_notif_entry * tuples, uint16_t num) -{ - ble_gattc_log_proc_init("multi handle notify; "); - for (int i = 0; i < num; i++) { - BLE_HS_LOG(INFO, "att_handle=%d", tuples[i].handle); - } -} - static void ble_gattc_log_indicate(uint16_t att_handle) { @@ -724,14 +707,6 @@ 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_eatt_get_available_chan_cid(conn_handle, op); -} - /** * Frees the specified proc entry. No-op if passed a null pointer. */ @@ -763,12 +738,6 @@ ble_gattc_proc_free(struct ble_gattc_proc *proc) break; } -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 - if (proc->cid != BLE_L2CAP_CID_ATT) { - ble_eatt_release_chan(proc->conn_handle, proc->op); - } -#endif - #if MYNEWT_VAL(BLE_HS_DEBUG) memset(proc, 0xff, sizeof *proc); #endif @@ -889,7 +858,6 @@ 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; }; @@ -921,28 +889,6 @@ 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; @@ -972,7 +918,6 @@ 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; @@ -986,8 +931,7 @@ 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->cid != proc->cid) { + criteria->conn_handle != proc->conn_handle) { return 0; } @@ -1066,26 +1010,12 @@ 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_cid_op(uint16_t conn_handle, uint16_t cid, uint8_t op) +ble_gattc_extract_first_by_conn_op(uint16_t conn_handle, uint8_t op) { struct ble_gattc_proc_list dst_list; - ble_gattc_extract_by_conn_cid_op(conn_handle, cid, op, 1, &dst_list); + ble_gattc_extract_by_conn_op(conn_handle, op, 1, &dst_list); return STAILQ_FIRST(&dst_list); } @@ -1120,7 +1050,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, uint16_t cid, +ble_gattc_extract_with_rx_entry(uint16_t conn_handle, const void *rx_entries, int num_rx_entries, const void **out_rx_entry) { @@ -1128,7 +1058,6 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle, uint16_t cid, 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; @@ -1146,7 +1075,6 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle, uint16_t cid, * 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 @@ -1155,9 +1083,9 @@ ble_gattc_extract_with_rx_entry(uint16_t conn_handle, uint16_t cid, * @return The matching proc entry on success; * null on failure. */ -#define BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, rx_entries, out_rx_entry) \ +#define BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, rx_entries, out_rx_entry) \ ble_gattc_extract_with_rx_entry( \ - (conn_handle), (cid), (rx_entries), \ + (conn_handle), (rx_entries), \ sizeof (rx_entries) / sizeof (rx_entries)[0], \ (const void **)(out_rx_entry)) @@ -1375,7 +1303,7 @@ ble_gattc_mtu_tx(struct ble_gattc_proc *proc) int rc; ble_hs_lock(); - rc = ble_att_conn_chan_find(proc->conn_handle, proc->cid, &conn, &chan); + rc = ble_att_conn_chan_find(proc->conn_handle, &conn, &chan); if (rc == 0) { mtu = chan->my_mtu; } @@ -1404,7 +1332,6 @@ 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; @@ -1481,7 +1408,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, proc->cid, + rc = ble_att_clt_tx_read_group_type(proc->conn_handle, proc->disc_all_svcs.prev_handle + 1, 0xffff, &uuid.u); if (rc != 0) { @@ -1634,8 +1561,8 @@ ble_gattc_disc_all_svcs(uint16_t conn_handle, ble_gatt_disc_svc_fn *cb, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_SVCS); - + proc->op = BLE_GATT_OP_DISC_ALL_SVCS; + proc->conn_handle = conn_handle; proc->disc_all_svcs.prev_handle = 0x0000; proc->disc_all_svcs.cb = cb; proc->disc_all_svcs.cb_arg = cb_arg; @@ -1714,7 +1641,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, proc->cid, + rc = ble_att_clt_tx_find_type_value(proc->conn_handle, proc->disc_svc_uuid.prev_handle + 1, 0xffff, BLE_ATT_UUID_PRIMARY_SERVICE, val, @@ -1853,8 +1780,8 @@ ble_gattc_disc_svc_by_uuid(uint16_t conn_handle, const ble_uuid_t *uuid, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_SVC_UUID); - + proc->op = BLE_GATT_OP_DISC_SVC_UUID; + proc->conn_handle = conn_handle; ble_uuid_to_any(uuid, &proc->disc_svc_uuid.service_uuid); proc->disc_svc_uuid.prev_handle = 0x0000; proc->disc_svc_uuid.cb = cb; @@ -1935,7 +1862,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, proc->cid, + rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->find_inc_svcs.prev_handle + 1, proc->find_inc_svcs.end_handle, &uuid.u); if (rc != 0) { @@ -1943,7 +1870,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, proc->cid, + rc = ble_att_clt_tx_read(proc->conn_handle, proc->find_inc_svcs.cur_start); if (rc != 0) { return rc; @@ -2169,8 +2096,8 @@ ble_gattc_find_inc_svcs(uint16_t conn_handle, uint16_t start_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_FIND_INC_SVCS); - + proc->op = BLE_GATT_OP_FIND_INC_SVCS; + proc->conn_handle = conn_handle; proc->find_inc_svcs.prev_handle = start_handle - 1; proc->find_inc_svcs.end_handle = end_handle; proc->find_inc_svcs.cb = cb; @@ -2249,7 +2176,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, proc->cid, + rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->disc_all_chrs.prev_handle + 1, proc->disc_all_chrs.end_handle, &uuid.u); if (rc != 0) { @@ -2403,8 +2330,8 @@ ble_gattc_disc_all_chrs(uint16_t conn_handle, uint16_t start_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_CHRS); - + proc->op = BLE_GATT_OP_DISC_ALL_CHRS; + proc->conn_handle = conn_handle; proc->disc_all_chrs.prev_handle = start_handle - 1; proc->disc_all_chrs.end_handle = end_handle; proc->disc_all_chrs.cb = cb; @@ -2483,7 +2410,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, proc->cid, + rc = ble_att_clt_tx_read_type(proc->conn_handle, proc->disc_chr_uuid.prev_handle + 1, proc->disc_chr_uuid.end_handle, &uuid.u); if (rc != 0) { @@ -2648,8 +2575,8 @@ ble_gattc_disc_chrs_by_uuid(uint16_t conn_handle, uint16_t start_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_CHR_UUID); - + proc->op = BLE_GATT_OP_DISC_CHR_UUID; + proc->conn_handle = conn_handle; 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; @@ -2728,7 +2655,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, proc->cid, + rc = ble_att_clt_tx_find_info(proc->conn_handle, proc->disc_all_dscs.prev_handle + 1, proc->disc_all_dscs.end_handle); if (rc != 0) { @@ -2864,8 +2791,8 @@ ble_gattc_disc_all_dscs(uint16_t conn_handle, uint16_t start_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_DISC_ALL_DSCS); - + proc->op = BLE_GATT_OP_DISC_ALL_DSCS; + proc->conn_handle = conn_handle; 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; @@ -2980,7 +2907,7 @@ ble_gattc_read_tx(struct ble_gattc_proc *proc) { int rc; - rc = ble_att_clt_tx_read(proc->conn_handle, proc->cid, proc->read.handle); + rc = ble_att_clt_tx_read(proc->conn_handle, proc->read.handle); if (rc != 0) { return rc; } @@ -3007,8 +2934,8 @@ ble_gattc_read(uint16_t conn_handle, uint16_t attr_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ); - + proc->op = BLE_GATT_OP_READ; + proc->conn_handle = conn_handle; proc->read.handle = attr_handle; proc->read.cb = cb; proc->read.cb_arg = cb_arg; @@ -3143,7 +3070,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, proc->cid, + return ble_att_clt_tx_read_type(proc->conn_handle, proc->read_uuid.start_handle, proc->read_uuid.end_handle, &proc->read_uuid.chr_uuid.u); @@ -3169,8 +3096,8 @@ ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ_UUID); - + proc->op = BLE_GATT_OP_READ_UUID; + proc->conn_handle = conn_handle; ble_uuid_to_any(uuid, &proc->read_uuid.chr_uuid); proc->read_uuid.start_handle = start_handle; proc->read_uuid.end_handle = end_handle; @@ -3253,12 +3180,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->cid, proc->read_long.handle); + rc = ble_att_clt_tx_read(proc->conn_handle, proc->read_long.handle); if (rc != 0) { return rc; } } else { - rc = ble_att_clt_tx_read_blob(proc->conn_handle, proc->cid, + rc = ble_att_clt_tx_read_blob(proc->conn_handle, proc->read_long.handle, proc->read_long.offset); if (rc != 0) { @@ -3329,7 +3256,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_by_cid(proc->conn_handle, proc->cid); + mtu = ble_att_mtu(proc->conn_handle); if (mtu == 0) { /* No longer connected. */ return BLE_HS_EDONE; @@ -3370,8 +3297,8 @@ ble_gattc_read_long(uint16_t conn_handle, uint16_t handle, uint16_t offset, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_READ_LONG); - + proc->op = BLE_GATT_OP_READ_LONG; + proc->conn_handle = conn_handle; proc->read_long.handle = handle; proc->read_long.offset = offset; proc->read_long.cb = cb; @@ -3528,15 +3455,6 @@ ble_gattc_read_mult_tmo(struct ble_gattc_proc *proc) ble_gattc_read_mult_cb(proc, BLE_HS_ETIMEOUT, 0, 0); } -static void -ble_gattc_read_mult_var_tmo(struct ble_gattc_proc *proc) -{ - BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task()); - ble_gattc_dbg_assert_proc_not_inserted(proc); - - ble_gattc_read_mult_cb_var(proc, BLE_HS_ETIMEOUT, 0, 0); -} - /** * Handles an incoming ATT error response for the specified * read-multiple-characteristics proc. @@ -3549,24 +3467,12 @@ ble_gattc_read_mult_err(struct ble_gattc_proc *proc, int status, ble_gattc_read_mult_cb(proc, status, att_handle, NULL); } -/** - * Handles an incoming ATT error response for the specified - * read-multiple-variable-lengthcharacteristics proc. - */ -static void -ble_gattc_read_mult_var_err(struct ble_gattc_proc *proc, int status, - uint16_t att_handle) -{ - ble_gattc_dbg_assert_proc_not_inserted(proc); - ble_gattc_read_mult_cb_var(proc, status, att_handle, NULL); -} - static int ble_gattc_read_mult_tx(struct ble_gattc_proc *proc) { int rc; - rc = ble_att_clt_tx_read_mult(proc->conn_handle, proc->cid, proc->read_mult.handles, + rc = ble_att_clt_tx_read_mult(proc->conn_handle, proc->read_mult.handles, proc->read_mult.num_handles, proc->read_mult.variable); if (rc != 0) { return rc; @@ -3604,9 +3510,12 @@ ble_gattc_read_mult_internal(uint16_t conn_handle, const uint16_t *handles, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, - variable ? BLE_GATT_OP_READ_MULT_VAR : BLE_GATT_OP_READ_MULT); - + if (variable) { + proc->op = BLE_GATT_OP_READ_MULT_VAR; + } else { + proc->op = BLE_GATT_OP_READ_MULT; + } + proc->conn_handle = conn_handle; memcpy(proc->read_mult.handles, handles, num_handles * sizeof *handles); proc->read_mult.num_handles = num_handles; proc->read_mult.variable = variable; @@ -3664,18 +3573,15 @@ ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle, #endif int rc; - uint16_t cid; STATS_INC(ble_gattc_stats, write_no_rsp); ble_gattc_log_write(attr_handle, OS_MBUF_PKTLEN(txom), 0); - cid = ble_eatt_get_available_chan_cid(conn_handle, BLE_GATT_OP_DUMMY); - rc = ble_att_clt_tx_write_cmd(conn_handle, cid, attr_handle, txom); + rc = ble_att_clt_tx_write_cmd(conn_handle, attr_handle, txom); if (rc != 0) { STATS_INC(ble_gattc_stats, write); } - ble_eatt_release_chan(conn_handle, BLE_GATT_OP_DUMMY); return rc; } @@ -3747,7 +3653,7 @@ ble_gattc_signed_write(uint16_t conn_handle, uint16_t attr_handle, /* Converting the csrk to little endian */ swap_buf(csrk, value_sec.csrk, 16); - rc = ble_att_clt_tx_signed_write_cmd(conn_handle, BLE_L2CAP_CID_ATT, attr_handle, + rc = ble_att_clt_tx_signed_write_cmd(conn_handle, attr_handle, csrk, value_sec.sign_counter, txom); if (rc != 0) { goto err; @@ -3843,15 +3749,15 @@ ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE); - + proc->op = BLE_GATT_OP_WRITE; + proc->conn_handle = conn_handle; 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, proc->cid, attr_handle, txom); + rc = ble_att_clt_tx_write_req(conn_handle, attr_handle, txom); txom = NULL; if (rc != 0) { goto done; @@ -3956,7 +3862,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc) om = NULL; - max_sz = ble_att_mtu_by_cid(proc->conn_handle, proc->cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; + max_sz = ble_att_mtu(proc->conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; if (max_sz <= 0) { /* Not connected. */ rc = BLE_HS_ENOTCONN; @@ -3968,7 +3874,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, proc->cid, + rc = ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE); goto done; } @@ -3988,7 +3894,7 @@ ble_gattc_write_long_tx(struct ble_gattc_proc *proc) goto done; } - rc = ble_att_clt_tx_prep_write(proc->conn_handle, proc->cid, + rc = ble_att_clt_tx_prep_write(proc->conn_handle, proc->write_long.attr.handle, proc->write_long.attr.offset, om); om = NULL; @@ -4032,9 +3938,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, proc->cid, + ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_CANCEL); } @@ -4100,8 +4006,7 @@ 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, proc->cid, - BLE_ATT_EXEC_WRITE_F_CANCEL); + ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_CANCEL); goto err; } else { /* Send follow-up request. */ @@ -4162,8 +4067,8 @@ ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE_LONG); - + proc->op = BLE_GATT_OP_WRITE_LONG; + proc->conn_handle = conn_handle; proc->write_long.attr.handle = attr_handle; proc->write_long.attr.offset = offset; proc->write_long.attr.om = txom; @@ -4263,14 +4168,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, proc->cid, + rc = ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_EXECUTE); goto done; } attr = proc->write_reliable.attrs + attr_idx; - max_sz = ble_att_mtu_by_cid(proc->conn_handle, proc->cid) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; + max_sz = ble_att_mtu(proc->conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; if (max_sz <= 0) { /* Not connected. */ rc = BLE_HS_ENOTCONN; @@ -4293,8 +4198,8 @@ ble_gattc_write_reliable_tx(struct ble_gattc_proc *proc) goto done; } - rc = ble_att_clt_tx_prep_write(proc->conn_handle, proc->cid, - attr->handle, attr->offset, om); + rc = ble_att_clt_tx_prep_write(proc->conn_handle, attr->handle, + attr->offset, om); om = NULL; if (rc != 0) { goto done; @@ -4337,7 +4242,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, proc->cid, + ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_CANCEL); } } @@ -4450,8 +4355,8 @@ ble_gattc_write_reliable(uint16_t conn_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_WRITE_RELIABLE); - + proc->op = BLE_GATT_OP_WRITE_RELIABLE; + proc->conn_handle = conn_handle; proc->write_reliable.num_attrs = num_attrs; proc->write_reliable.cur_attr = 0; proc->write_reliable.cb = cb; @@ -4568,130 +4473,6 @@ done: return rc; } -int -ble_gatts_multi_notify_custom(uint16_t conn_handle, - struct ble_gatt_notif_entry * tuples, uint16_t num_tuples) -{ -#if !MYNEWT_VAL(BLE_GATT_MULTI_NOTIFY) - return BLE_HS_ENOTSUP; -#endif - - int i; - int rc; - uint16_t mtu; - uint16_t pdu_size; - int split_at; - struct os_mbuf *om = NULL; - - STATS_INC(ble_gattc_stats, multi_notify); - ble_gattc_log_multi_notify(tuples, num_tuples); - - for (i = 0; i < num_tuples; i++) { - if (tuples[i].value == NULL) { - /* No custom attribute data; read the value from the specified - * attribute - */ - tuples[i].value = ble_hs_mbuf_att_pkt(); - if (tuples[i].value == NULL) { - rc = BLE_HS_ENOMEM; - goto done; - } - rc = ble_att_svr_read_handle(BLE_HS_CONN_HANDLE_NONE, - tuples[i].handle, 0, tuples[i].value, NULL); - if (rc != 0) { - BLE_HS_LOG(ERROR, "Attribute read failed (err=0x%02x), rc"); - goto done; - } - } - } - - mtu = ble_att_mtu(conn_handle); - pdu_size = sizeof(uint8_t); /* Opcode */ - split_at = 0; - - for (i = 0; i < num_tuples; i++) { - pdu_size += (2 * sizeof(uint16_t)) + OS_MBUF_PKTLEN(tuples[i].value); - if (pdu_size > mtu) { - /* The notification will need to be split */ - if (i == split_at) { - /* Single notification too large for server, - * cannot send notify without truncating. - */ - rc = BLE_HS_ENOMEM; - goto done; - } - split_at = i; - /* Reinitialize loop */ - i--; - pdu_size = sizeof(uint8_t); - } - } - - pdu_size = sizeof(uint8_t); - split_at = 0; - om = ble_hs_mbuf_att_pkt(); - if(om == NULL) { - rc = BLE_HS_ENOMEM; - goto done; - } - for (i = 0; i < num_tuples; i++) { - pdu_size += (2 * sizeof(uint16_t)) + OS_MBUF_PKTLEN(tuples[i].value); - if (pdu_size > mtu) { - rc = ble_att_clt_tx_multi_notify(conn_handle, om); - if (rc != 0) { - goto done; - } - split_at = i; - i--; - pdu_size = sizeof(uint8_t); - om = ble_hs_mbuf_att_pkt(); - if(om == NULL) { - rc = BLE_HS_ENOMEM; - goto done; - } - continue; - } - /* Handle */ - rc = os_mbuf_copyinto(om, OS_MBUF_PKTLEN(om), - &tuples[i].handle, sizeof tuples[i].handle); - if (rc != 0) { - rc = BLE_HS_ENOMEM; - os_mbuf_free_chain(om); - goto done; - } - /* Length */ - rc = os_mbuf_copyinto(om, OS_MBUF_PKTLEN(om), - &(OS_MBUF_PKTLEN(tuples[i].value)), - sizeof(OS_MBUF_PKTLEN(tuples[i].value))); - if (rc != 0) { - rc = BLE_HS_ENOMEM; - os_mbuf_free_chain(om); - goto done; - } - /* Value */ - rc = os_mbuf_appendfrom(om, tuples[i].value, - 0, OS_MBUF_PKTLEN(tuples[i].value)); - if (rc != 0) { - rc = BLE_HS_ENOMEM; - os_mbuf_free_chain(om); - goto done; - } - } - rc = ble_att_clt_tx_multi_notify(conn_handle, om); - -done: - if (rc != 0) { - STATS_INC(ble_gattc_stats, multi_notify_fail); - } - - /* Tell the application that multiple notification transmissions were attempted. */ - for (i = 0; i < num_tuples; i++) { - ble_gap_notify_tx_event(rc, conn_handle, tuples[i].handle, 0); - os_mbuf_free_chain(tuples[i].value); - } - return rc; -} - /** * Deprecated. Should not be used. Use ble_gatts_notify_custom instead. */ @@ -4827,8 +4608,8 @@ ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle, goto done; } - ble_gattc_proc_prepare(proc, conn_handle, BLE_GATT_OP_INDICATE); - + proc->op = BLE_GATT_OP_INDICATE; + proc->conn_handle = conn_handle; proc->indicate.chr_val_handle = chr_val_handle; ble_gattc_log_indicate(chr_val_handle); @@ -4867,7 +4648,7 @@ ble_gatts_indicate_custom(uint16_t conn_handle, uint16_t chr_val_handle, } } - rc = ble_att_clt_tx_indicate(conn_handle, proc->cid, chr_val_handle, txom); + rc = ble_att_clt_tx_indicate(conn_handle, chr_val_handle, txom); txom = NULL; if (rc != 0) { goto done; @@ -4928,12 +4709,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 cid, uint16_t handle, uint16_t status) +ble_gattc_rx_err(uint16_t conn_handle, uint16_t handle, uint16_t status) { struct ble_gattc_proc *proc; ble_gattc_err_fn *err_cb; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, BLE_GATT_OP_NONE); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_NONE); if (proc != NULL) { err_cb = ble_gattc_err_dispatch_get(proc->op); if (err_cb != NULL) { @@ -4948,13 +4729,11 @@ ble_gattc_rx_err(uint16_t conn_handle, uint16_t cid, uint16_t handle, uint16_t s * GATT procedure. */ void -ble_gattc_rx_mtu(uint16_t conn_handle, uint16_t cid, int status, uint16_t chan_mtu) +ble_gattc_rx_mtu(uint16_t conn_handle, int status, uint16_t chan_mtu) { struct ble_gattc_proc *proc; - 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); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_MTU); if (proc != NULL) { ble_gattc_mtu_cb(proc, status, 0, chan_mtu); ble_gattc_process_status(proc, BLE_HS_EDONE); @@ -4966,7 +4745,7 @@ ble_gattc_rx_mtu(uint16_t conn_handle, uint16_t cid, int status, uint16_t chan_m * find-information-response to the appropriate active GATT procedure. */ void -ble_gattc_rx_find_info_idata(uint16_t conn_handle, uint16_t cid, +ble_gattc_rx_find_info_idata(uint16_t conn_handle, struct ble_att_find_info_idata *idata) { #if !NIMBLE_BLE_ATT_CLT_FIND_INFO @@ -4976,7 +4755,7 @@ ble_gattc_rx_find_info_idata(uint16_t conn_handle, uint16_t cid, struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_DISC_ALL_DSCS); if (proc != NULL) { rc = ble_gattc_disc_all_dscs_rx_idata(proc, idata); @@ -4989,7 +4768,7 @@ ble_gattc_rx_find_info_idata(uint16_t conn_handle, uint16_t cid, * find-information-response to the appropriate active GATT procedure. */ void -ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, int status) +ble_gattc_rx_find_info_complete(uint16_t conn_handle, int status) { #if !NIMBLE_BLE_ATT_CLT_FIND_INFO return; @@ -4998,8 +4777,8 @@ ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, int status) struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, - BLE_GATT_OP_DISC_ALL_DSCS); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, + 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); @@ -5011,7 +4790,7 @@ ble_gattc_rx_find_info_complete(uint16_t conn_handle, uint16_t cid, 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, uint16_t cid, +ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle, struct ble_att_find_type_value_hinfo *hinfo) { #if !NIMBLE_BLE_ATT_CLT_FIND_TYPE @@ -5021,7 +4800,7 @@ ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle, uint16_t cid, struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_DISC_SVC_UUID); if (proc != NULL) { rc = ble_gattc_disc_svc_uuid_rx_hinfo(proc, hinfo); @@ -5034,7 +4813,7 @@ ble_gattc_rx_find_type_value_hinfo(uint16_t conn_handle, uint16_t cid, * find-by-type-value-response to the appropriate active GATT procedure. */ void -ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, uint16_t cid, int status) +ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status) { #if !NIMBLE_BLE_ATT_CLT_FIND_TYPE return; @@ -5043,8 +4822,8 @@ ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, uint16_t cid, int st struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, - BLE_GATT_OP_DISC_SVC_UUID); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, + 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); @@ -5056,7 +4835,7 @@ ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, uint16_t cid, int st * to the appropriate active GATT procedure. */ void -ble_gattc_rx_read_type_adata(uint16_t conn_handle, uint16_t cid, +ble_gattc_rx_read_type_adata(uint16_t conn_handle, struct ble_att_read_type_adata *adata) { #if !NIMBLE_BLE_ATT_CLT_READ_TYPE @@ -5067,7 +4846,7 @@ ble_gattc_rx_read_type_adata(uint16_t conn_handle, uint16_t cid, struct ble_gattc_proc *proc; int rc; - proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, + proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, ble_gattc_rx_read_type_elem_entries, &rx_entry); if (proc != NULL) { @@ -5081,7 +4860,7 @@ ble_gattc_rx_read_type_adata(uint16_t conn_handle, uint16_t cid, * the appropriate active GATT procedure. */ void -ble_gattc_rx_read_type_complete(uint16_t conn_handle, uint16_t cid, int status) +ble_gattc_rx_read_type_complete(uint16_t conn_handle, int status) { #if !NIMBLE_BLE_ATT_CLT_READ_TYPE return; @@ -5092,7 +4871,7 @@ ble_gattc_rx_read_type_complete(uint16_t conn_handle, uint16_t cid, int status) int rc; proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY( - conn_handle, cid, ble_gattc_rx_read_type_complete_entries, + conn_handle, ble_gattc_rx_read_type_complete_entries, &rx_entry); if (proc != NULL) { rc = rx_entry->cb(proc, status); @@ -5105,7 +4884,7 @@ ble_gattc_rx_read_type_complete(uint16_t conn_handle, uint16_t cid, 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, uint16_t cid, +ble_gattc_rx_read_group_type_adata(uint16_t conn_handle, struct ble_att_read_group_type_adata *adata) { #if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE @@ -5115,7 +4894,7 @@ ble_gattc_rx_read_group_type_adata(uint16_t conn_handle, uint16_t cid, struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_DISC_ALL_SVCS); if (proc != NULL) { rc = ble_gattc_disc_all_svcs_rx_adata(proc, adata); @@ -5128,7 +4907,7 @@ ble_gattc_rx_read_group_type_adata(uint16_t conn_handle, uint16_t cid, * read-by-group-type-response to the appropriate active GATT procedure. */ void -ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, uint16_t cid, int status) +ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, int status) { #if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE return; @@ -5137,8 +4916,8 @@ ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, uint16_t cid, int st struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, - BLE_GATT_OP_DISC_ALL_SVCS); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, + 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); @@ -5150,7 +4929,7 @@ ble_gattc_rx_read_group_type_complete(uint16_t conn_handle, uint16_t cid, int st * procedure. */ void -ble_gattc_rx_read_rsp(uint16_t conn_handle, uint16_t cid, int status, struct os_mbuf **om) +ble_gattc_rx_read_rsp(uint16_t conn_handle, int status, struct os_mbuf **om) { #if !NIMBLE_BLE_ATT_CLT_READ return; @@ -5160,7 +4939,7 @@ ble_gattc_rx_read_rsp(uint16_t conn_handle, uint16_t cid, int status, struct os_ struct ble_gattc_proc *proc; int rc; - proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, + proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, ble_gattc_rx_read_rsp_entries, &rx_entry); if (proc != NULL) { @@ -5174,7 +4953,7 @@ ble_gattc_rx_read_rsp(uint16_t conn_handle, uint16_t cid, int status, struct os_ * procedure. */ void -ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status, +ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, int status, struct os_mbuf **om) { #if !NIMBLE_BLE_ATT_CLT_READ_BLOB @@ -5184,7 +4963,7 @@ ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status, struct ble_gattc_proc *proc; int rc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_READ_LONG); if (proc != NULL) { rc = ble_gattc_read_long_rx_read_rsp(proc, status, om); @@ -5197,7 +4976,7 @@ ble_gattc_rx_read_blob_rsp(uint16_t conn_handle, uint16_t cid, int status, * GATT procedure. */ void -ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status, +ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, int status, struct os_mbuf **om, bool variable) { #if !NIMBLE_BLE_ATT_CLT_READ_MULT @@ -5209,7 +4988,7 @@ ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status, op = variable ? BLE_GATT_OP_READ_MULT_VAR : BLE_GATT_OP_READ_MULT; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, op); + proc = ble_gattc_extract_first_by_conn_op(conn_handle, op); if (proc != NULL) { ble_gattc_read_mult_cb(proc, status, 0, om); ble_gattc_process_status(proc, BLE_HS_EDONE); @@ -5221,7 +5000,7 @@ ble_gattc_rx_read_mult_rsp(uint16_t conn_handle, uint16_t cid, int status, * procedure. */ void -ble_gattc_rx_write_rsp(uint16_t conn_handle, uint16_t cid) +ble_gattc_rx_write_rsp(uint16_t conn_handle) { #if !NIMBLE_BLE_ATT_CLT_WRITE return; @@ -5229,7 +5008,7 @@ ble_gattc_rx_write_rsp(uint16_t conn_handle, uint16_t cid) struct ble_gattc_proc *proc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_WRITE); if (proc != NULL) { ble_gattc_write_cb(proc, 0, 0); @@ -5242,7 +5021,7 @@ ble_gattc_rx_write_rsp(uint16_t conn_handle, uint16_t cid) * GATT procedure. */ void -ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, uint16_t cid, int status, +ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status, uint16_t handle, uint16_t offset, struct os_mbuf **om) { @@ -5254,7 +5033,7 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, uint16_t cid, int status, struct ble_gattc_proc *proc; int rc; - proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, + proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, ble_gattc_rx_prep_entries, &rx_entry); if (proc != NULL) { @@ -5268,7 +5047,7 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, uint16_t cid, int status, * GATT procedure. */ void -ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, uint16_t cid, int status) +ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status) { #if !NIMBLE_BLE_ATT_CLT_EXEC_WRITE return; @@ -5278,7 +5057,7 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, uint16_t cid, int status) struct ble_gattc_proc *proc; int rc; - proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, cid, + proc = BLE_GATTC_RX_EXTRACT_RX_ENTRY(conn_handle, ble_gattc_rx_exec_entries, &rx_entry); if (proc != NULL) { rc = rx_entry->cb(proc, status); @@ -5291,7 +5070,7 @@ ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, uint16_t cid, int status) * active GATT procedure. */ void -ble_gatts_rx_indicate_rsp(uint16_t conn_handle, uint16_t cid) +ble_gatts_rx_indicate_rsp(uint16_t conn_handle) { #if !NIMBLE_BLE_ATT_CLT_INDICATE return; @@ -5299,7 +5078,7 @@ ble_gatts_rx_indicate_rsp(uint16_t conn_handle, uint16_t cid) struct ble_gattc_proc *proc; - proc = ble_gattc_extract_first_by_conn_cid_op(conn_handle, cid, + proc = ble_gattc_extract_first_by_conn_op(conn_handle, BLE_GATT_OP_INDICATE); if (proc != NULL) { ble_gatts_indicate_rx_rsp(proc); diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c index 220759009..1ed13f82a 100644 --- a/nimble/host/src/ble_hs.c +++ b/nimble/host/src/ble_hs.c @@ -787,16 +787,10 @@ ble_hs_init(void) SYSINIT_PANIC_ASSERT(rc == 0); #endif - #if NIMBLE_BLE_CONNECT rc = ble_l2cap_init(); SYSINIT_PANIC_ASSERT(rc == 0); -#endif - rc = ble_gap_init(); - SYSINIT_PANIC_ASSERT(rc == 0); - -#if NIMBLE_BLE_CONNECT rc = ble_att_init(); SYSINIT_PANIC_ASSERT(rc == 0); @@ -814,6 +808,8 @@ ble_hs_init(void) rc = ble_gatts_init(); SYSINIT_PANIC_ASSERT(rc == 0); #endif + rc = ble_gap_init(); + SYSINIT_PANIC_ASSERT(rc == 0); ble_hs_stop_init(); diff --git a/nimble/host/src/ble_hs_conn.c b/nimble/host/src/ble_hs_conn.c index eb749c41a..0af96f284 100644 --- a/nimble/host/src/ble_hs_conn.c +++ b/nimble/host/src/ble_hs_conn.c @@ -194,7 +194,6 @@ 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); diff --git a/nimble/host/src/ble_hs_conn_priv.h b/nimble/host/src/ble_hs_conn_priv.h index 9bcf737d2..0e451194d 100644 --- a/nimble/host/src/ble_hs_conn_priv.h +++ b/nimble/host/src/ble_hs_conn_priv.h @@ -102,12 +102,6 @@ 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; -#if MYNEWT_VAL(BLE_EATT_CHAN_NUM) - uint16_t default_cid; -#endif }; struct ble_hs_conn_addrs { diff --git a/nimble/host/src/ble_hs_priv.h b/nimble/host/src/ble_hs_priv.h index cb97e5374..c5781ccc9 100644 --- a/nimble/host/src/ble_hs_priv.h +++ b/nimble/host/src/ble_hs_priv.h @@ -24,7 +24,6 @@ #include #include "ble_att_cmd_priv.h" #include "ble_att_priv.h" -#include "ble_eatt_priv.h" #include "ble_gap_priv.h" #include "ble_gatt_priv.h" #include "ble_hs_hci_priv.h" diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c index f55d14da3..90d2a0573 100644 --- a/nimble/host/src/ble_l2cap_coc.c +++ b/nimble/host/src/ble_l2cap_coc.c @@ -211,7 +211,7 @@ ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan) sdu_len = get_le16((*om)->om_data); - BLE_HS_LOG(DEBUG, "First LE frame received %d, SDU len: %d\n", + BLE_HS_LOG(INFO, "First LE frame received %d, SDU len: %d\n", om_total, sdu_len + 2); /* We should receive payload of size sdu_len + 2 bytes of sdu_len field */ diff --git a/nimble/host/syscfg.yml b/nimble/host/syscfg.yml index 06d1160d9..eb1abdf41 100644 --- a/nimble/host/syscfg.yml +++ b/nimble/host/syscfg.yml @@ -277,10 +277,6 @@ syscfg.defs: description: > Enables sending and receiving of GATT indications. (0/1) value: 1 - BLE_GATT_MULTI_NOTIFY: - description: > - Enables sending and receiving of GATT multi handle notifications. - value: 1 # GATT options. BLE_GATT_READ_MAX_ATTRS: @@ -303,22 +299,6 @@ syscfg.defs: due to memory exhaustion. (0/1) Units are milliseconds. (0/1) value: 1000 - # Enhanced ATT bearer options - BLE_EATT_CHAN_NUM: - description: > - Maximum number of supported EATT channels (in total). If set to 0 - EATT support it disabled. - value: 0 - restrictions: - - BLE_GATT_NOTIFY_MULTIPLE - - BLE_L2CAP_ENHANCED_COC - - 'BLE_L2CAP_COC_MAX_NUM >= BLE_EATT_CHAN_NUM' - - BLE_EATT_MTU: - description: > - MTU used for EATT channels. - value: 128 - # Supported server ATT commands. (0/1) BLE_ATT_SVR_FIND_INFO: description: > @@ -377,12 +357,6 @@ syscfg.defs: Enables processing of incoming Handle Value Notification ATT commands. (0/1) value: 1 - BLE_ATT_SVR_NOTIFY_MULTI: - description: > - Enables processing of incoming Multi Handle Value Notification ATT - commands. (0/1) - value: MYNEWT_VAL_BLE_ATT_SVR_NOTIFY && (MYNEWT_VAL_BLE_VERSION >= 52) - BLE_ATT_SVR_INDICATE: description: > Enables processing of incoming Handle Value Indication ATT @@ -493,22 +467,11 @@ syscfg.defs: description: 'Minimum level for the BLE host log.' value: 1 - BLE_EATT_LOG_MOD: - description: 'Numeric module ID to use for BLE EATT log messages.' - value: 27 - BLE_EATT_LOG_LVL: - description: 'Minimum level for the BLE EATT log.' - value: 1 - syscfg.logs: BLE_HS_LOG: module: MYNEWT_VAL(BLE_HS_LOG_MOD) level: MYNEWT_VAL(BLE_HS_LOG_LVL) - BLE_EATT_LOG: - module: MYNEWT_VAL(BLE_EATT_LOG_MOD) - level: MYNEWT_VAL(BLE_EATT_LOG_LVL) - syscfg.vals.BLE_MESH: BLE_SM_SC: 1 diff --git a/nimble/host/test/src/ble_att_clt_test.c b/nimble/host/test/src/ble_att_clt_test.c index 35d2e235d..0b6d55d31 100644 --- a/nimble/host/test/src/ble_att_clt_test.c +++ b/nimble/host/test/src/ble_att_clt_test.c @@ -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, BLE_L2CAP_CID_ATT, handle, om); + rc = ble_att_clt_tx_write_req(conn_handle, handle, om); } else { - rc = ble_att_clt_tx_write_cmd(conn_handle, BLE_L2CAP_CID_ATT, handle, om); + rc = ble_att_clt_tx_write_cmd(conn_handle, handle, om); } TEST_ASSERT(rc == 0); } @@ -78,35 +78,25 @@ TEST_CASE_SELF(ble_att_clt_test_tx_find_info) { uint16_t conn_handle; int rc; - struct ble_hs_conn *conn; ble_hs_test_util_assert_mbufs_freed(NULL); conn_handle = ble_att_clt_test_misc_init(); - ble_hs_lock(); - conn = ble_hs_conn_find(conn_handle); - ble_hs_unlock(); /*** Success. */ - rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 1, 0xffff); + rc = ble_att_clt_tx_find_info(conn_handle, 1, 0xffff); TEST_ASSERT(rc == 0); /*** Error: start handle of 0. */ - /** In unit tests we don't are not receiving response - procedure will - * not complete. Reset `client_att_busy` flag so new request can be sent - */ - conn->client_att_busy = false; - rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 0, 0xffff); + rc = ble_att_clt_tx_find_info(conn_handle, 0, 0xffff); TEST_ASSERT(rc == BLE_HS_EINVAL); /*** Error: start handle greater than end handle. */ - conn->client_att_busy = false; - rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 500, 499); + rc = ble_att_clt_tx_find_info(conn_handle, 500, 499); TEST_ASSERT(rc == BLE_HS_EINVAL); /*** Success; start and end handles equal. */ - conn->client_att_busy = false; - rc = ble_att_clt_tx_find_info(conn_handle, BLE_L2CAP_CID_ATT, 500, 500); + rc = ble_att_clt_tx_find_info(conn_handle, 500, 500); TEST_ASSERT(rc == 0); ble_hs_test_util_assert_mbufs_freed(NULL); @@ -185,14 +175,9 @@ ble_att_clt_test_case_tx_write_req_or_cmd(int is_req) uint16_t conn_handle; uint8_t value300[500] = { 0 }; uint8_t value5[5] = { 6, 7, 54, 34, 8 }; - struct ble_hs_conn *conn; conn_handle = ble_att_clt_test_misc_init(); - ble_hs_lock(); - conn = ble_hs_conn_find(conn_handle); - ble_hs_unlock(); - /*** 5-byte write. */ ble_att_clt_test_tx_write_req_or_cmd(conn_handle, 0x1234, value5, sizeof value5, is_req); @@ -200,10 +185,6 @@ ble_att_clt_test_case_tx_write_req_or_cmd(int is_req) is_req); /*** Overlong write; verify command truncated to ATT MTU. */ - /** In unit tests we are not receiving response - procedure will - * not complete. Reset `client_att_busy` flag so new request can be sent - */ - conn->client_att_busy = false; ble_att_clt_test_tx_write_req_or_cmd(conn_handle, 0xab83, value300, sizeof value300, is_req); ble_att_clt_test_misc_verify_tx_write(0xab83, value300, @@ -225,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, BLE_L2CAP_CID_ATT, handle, offset, om); + rc = ble_att_clt_tx_prep_write(conn_handle, handle, offset, om); TEST_ASSERT(rc == 0); om = ble_hs_test_util_prev_tx_dequeue_pullup(); @@ -251,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, BLE_L2CAP_CID_ATT, flags); + rc = ble_att_clt_tx_exec_write(conn_handle, flags); TEST_ASSERT(rc == 0); om = ble_hs_test_util_prev_tx_dequeue_pullup(); @@ -275,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, BLE_L2CAP_CID_ATT, handle, offset, om); + rc = ble_att_clt_tx_prep_write(conn_handle, handle, offset, om); TEST_ASSERT(rc == status); } @@ -306,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, BLE_L2CAP_CID_ATT, 1); + rc = ble_att_clt_tx_read(conn_handle, 1); TEST_ASSERT(rc == 0); /*** Error: handle of 0. */ - rc = ble_att_clt_tx_read(conn_handle, BLE_L2CAP_CID_ATT, 0); + rc = ble_att_clt_tx_read(conn_handle, 0); TEST_ASSERT(rc == BLE_HS_EINVAL); ble_hs_test_util_assert_mbufs_freed(NULL); @@ -352,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, BLE_L2CAP_CID_ATT, 1, 0); + rc = ble_att_clt_tx_read_blob(conn_handle, 1, 0); TEST_ASSERT(rc == 0); /*** Error: handle of 0. */ - rc = ble_att_clt_tx_read_blob(conn_handle, BLE_L2CAP_CID_ATT, 0, 0); + rc = ble_att_clt_tx_read_blob(conn_handle, 0, 0); TEST_ASSERT(rc == BLE_HS_EINVAL); ble_hs_test_util_assert_mbufs_freed(NULL); @@ -399,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, BLE_L2CAP_CID_ATT, ((uint16_t[]){ 1, 2 }), 2, false); + rc = ble_att_clt_tx_read_mult(conn_handle, ((uint16_t[]){ 1, 2 }), 2, false); TEST_ASSERT(rc == 0); om = ble_hs_test_util_prev_tx_dequeue_pullup(); @@ -411,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, BLE_L2CAP_CID_ATT, NULL, 0, false); + rc = ble_att_clt_tx_read_mult(conn_handle, NULL, 0, false); TEST_ASSERT(rc == BLE_HS_EINVAL); ble_hs_test_util_assert_mbufs_freed(NULL); @@ -520,14 +501,14 @@ TEST_CASE_SELF(ble_att_clt_test_tx_exec_write) uint16_t conn_handle; int rc; + conn_handle = ble_att_clt_test_misc_init(); /*** Success. */ ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_CANCEL); ble_att_clt_test_misc_exec_good(BLE_ATT_EXEC_WRITE_F_EXECUTE); /*** Success: nonzero == execute. */ - conn_handle = ble_att_clt_test_misc_init(); - rc = ble_att_clt_tx_exec_write(conn_handle, BLE_L2CAP_CID_ATT, 0x02); + rc = ble_att_clt_tx_exec_write(conn_handle, 0x02); TEST_ASSERT(rc == 0); ble_hs_test_util_assert_mbufs_freed(NULL); diff --git a/nimble/host/test/src/ble_att_svr_test.c b/nimble/host/test/src/ble_att_svr_test.c index 84394d6a5..60ab14b4e 100644 --- a/nimble/host/test/src/ble_att_svr_test.c +++ b/nimble/host/test/src/ble_att_svr_test.c @@ -24,7 +24,6 @@ #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; @@ -479,7 +478,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, uint16_t cid) +ble_att_svr_test_misc_verify_tx_mtu_rsp(uint16_t conn_handle) { struct ble_l2cap_chan *chan; struct ble_hs_conn *conn; @@ -488,7 +487,7 @@ ble_att_svr_test_misc_verify_tx_mtu_rsp(uint16_t conn_handle, uint16_t cid) ble_hs_lock(); - rc = ble_att_conn_chan_find(conn_handle, cid, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); assert(rc == 0); my_mtu = chan->my_mtu; @@ -645,7 +644,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_L2CAP_CID_ATT); + ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle); ble_hs_lock(); rc = ble_hs_misc_conn_chan_find(conn_handle, BLE_L2CAP_CID_ATT, @@ -1139,19 +1138,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, BLE_L2CAP_CID_ATT, 0, 0); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 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, BLE_L2CAP_CID_ATT, 101, 100); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 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, BLE_L2CAP_CID_ATT, 200, 300); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 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); @@ -1161,13 +1160,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, BLE_L2CAP_CID_ATT, 200, 300); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 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, BLE_L2CAP_CID_ATT, handle1, handle1); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle1); TEST_ASSERT(rc == 0); ble_hs_test_util_verify_tx_find_info_rsp( ((struct ble_hs_test_util_att_info_entry[]) { { @@ -1182,7 +1181,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, BLE_L2CAP_CID_ATT, handle1, handle2); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle2); TEST_ASSERT(rc == 0); ble_hs_test_util_verify_tx_find_info_rsp( ((struct ble_hs_test_util_att_info_entry[]) { { @@ -1200,7 +1199,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, BLE_L2CAP_CID_ATT, handle1, handle3); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle1, handle3); TEST_ASSERT(rc == 0); ble_hs_test_util_verify_tx_find_info_rsp( ((struct ble_hs_test_util_att_info_entry[]) { { @@ -1214,7 +1213,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, BLE_L2CAP_CID_ATT, handle3, handle3); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, handle3, handle3); TEST_ASSERT(rc == 0); ble_hs_test_util_verify_tx_find_info_rsp( ((struct ble_hs_test_util_att_info_entry[]) { { @@ -1937,13 +1936,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_L2CAP_CID_ATT); + ble_att_svr_test_misc_verify_tx_mtu_rsp(conn_handle); /*** 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, BLE_L2CAP_CID_ATT, 1, 100); + rc = ble_hs_test_util_rx_att_find_info_req(conn_handle, 1, 100); TEST_ASSERT_FATAL(rc == 0); /* Ensure we were able to send a real response. */ diff --git a/nimble/host/test/src/ble_gatt_conn_test.c b/nimble/host/test/src/ble_gatt_conn_test.c index d74dd6fcf..5cb94ce82 100644 --- a/nimble/host/test/src/ble_gatt_conn_test.c +++ b/nimble/host/test/src/ble_gatt_conn_test.c @@ -385,7 +385,6 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect) uint16_t attr_handle; uint16_t offset = 0; int rc; - struct ble_hs_conn *conn; ble_gatt_conn_test_util_init(); @@ -406,92 +405,65 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect) /*** Schedule some GATT procedures. */ /* Connection 1. */ mtu_arg.exp_conn_handle = 1; - ble_hs_lock(); - conn = ble_hs_conn_find(1); - ble_hs_unlock(); - - /** In unit tests we are not receiving response - procedure will - * not complete. Reset `client_att_busy` flag so new request can be sent - */ - conn->client_att_busy = false; ble_gattc_exchange_mtu(1, ble_gatt_conn_test_mtu_cb, &mtu_arg); disc_all_svcs_arg.exp_conn_handle = 1; - conn->client_att_busy = false; rc = ble_gattc_disc_all_svcs(1, ble_gatt_conn_test_disc_all_svcs_cb, &disc_all_svcs_arg); TEST_ASSERT_FATAL(rc == 0); disc_svc_uuid_arg.exp_conn_handle = 1; - conn->client_att_busy = false; rc = ble_gattc_disc_svc_by_uuid(1, BLE_UUID16_DECLARE(0x1111), ble_gatt_conn_test_disc_svc_uuid_cb, &disc_svc_uuid_arg); TEST_ASSERT_FATAL(rc == 0); find_inc_svcs_arg.exp_conn_handle = 1; - conn->client_att_busy = false; rc = ble_gattc_find_inc_svcs(1, 1, 0xffff, ble_gatt_conn_test_find_inc_svcs_cb, &find_inc_svcs_arg); TEST_ASSERT_FATAL(rc == 0); disc_all_chrs_arg.exp_conn_handle = 1; - conn->client_att_busy = false; rc = ble_gattc_disc_all_chrs(1, 1, 0xffff, ble_gatt_conn_test_disc_all_chrs_cb, &disc_all_chrs_arg); TEST_ASSERT_FATAL(rc == 0); /* Connection 2. */ - ble_hs_lock(); - conn = ble_hs_conn_find(2); - ble_hs_unlock(); - disc_all_dscs_arg.exp_conn_handle = 2; - conn->client_att_busy = false; rc = ble_gattc_disc_all_dscs(2, 3, 0xffff, ble_gatt_conn_test_disc_all_dscs_cb, &disc_all_dscs_arg); disc_chr_uuid_arg.exp_conn_handle = 2; - conn->client_att_busy = false; rc = ble_gattc_disc_chrs_by_uuid(2, 2, 0xffff, BLE_UUID16_DECLARE(0x2222), ble_gatt_conn_test_disc_chr_uuid_cb, &disc_chr_uuid_arg); read_arg.exp_conn_handle = 2; - conn->client_att_busy = false; rc = ble_gattc_read(2, BLE_GATT_BREAK_TEST_READ_ATTR_HANDLE, ble_gatt_conn_test_read_cb, &read_arg); TEST_ASSERT_FATAL(rc == 0); read_uuid_arg.exp_conn_handle = 2; - conn->client_att_busy = false; rc = ble_gattc_read_by_uuid(2, 1, 0xffff, BLE_UUID16_DECLARE(0x3333), ble_gatt_conn_test_read_uuid_cb, &read_uuid_arg); TEST_ASSERT_FATAL(rc == 0); read_long_arg.exp_conn_handle = 2; - conn->client_att_busy = false; rc = ble_gattc_read_long(2, BLE_GATT_BREAK_TEST_READ_ATTR_HANDLE, offset, ble_gatt_conn_test_read_long_cb, &read_long_arg); TEST_ASSERT_FATAL(rc == 0); /* Connection 3. */ - ble_hs_lock(); - conn = ble_hs_conn_find(3); - ble_hs_unlock(); - read_mult_arg.exp_conn_handle = 3; - conn->client_att_busy = false; rc = ble_gattc_read_mult(3, ((uint16_t[3]){5,6,7}), 3, ble_gatt_conn_test_read_mult_cb, &read_mult_arg); TEST_ASSERT_FATAL(rc == 0); write_arg.exp_conn_handle = 3; - conn->client_att_busy = false; rc = ble_hs_test_util_gatt_write_flat( 3, BLE_GATT_BREAK_TEST_WRITE_ATTR_HANDLE, ble_gatt_conn_test_write_value, sizeof ble_gatt_conn_test_write_value, @@ -499,7 +471,6 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect) TEST_ASSERT_FATAL(rc == 0); write_long_arg.exp_conn_handle = 3; - conn->client_att_busy = false; rc = ble_hs_test_util_gatt_write_long_flat( 3, BLE_GATT_BREAK_TEST_WRITE_ATTR_HANDLE, ble_gatt_conn_test_write_value, sizeof ble_gatt_conn_test_write_value, @@ -510,12 +481,10 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect) attr.offset = 0; attr.om = os_msys_get_pkthdr(0, 0); write_rel_arg.exp_conn_handle = 3; - conn->client_att_busy = false; rc = ble_gattc_write_reliable( 3, &attr, 1, ble_gatt_conn_test_write_rel_cb, &write_rel_arg); TEST_ASSERT_FATAL(rc == 0); - conn->client_att_busy = false; rc = ble_gatts_indicate(3, attr_handle); TEST_ASSERT_FATAL(rc == 0); @@ -559,11 +528,6 @@ TEST_CASE_SELF(ble_gatt_conn_test_disconnect) TEST_ASSERT(ble_gatt_conn_test_gap_event.type == 255); /* Connection 3. */ - /** This is required because of call ble_att_clt_tx_exec_write - * from ble_att_clt_tx_exec_write after broken connection - - * ble_gattc_fail_procs is called - */ - conn->client_att_busy = false; ble_gattc_connection_broken(3); TEST_ASSERT(mtu_arg.called == 1); TEST_ASSERT(disc_all_svcs_arg.called == 1); diff --git a/nimble/host/test/src/ble_gatt_disc_c_test.c b/nimble/host/test/src/ble_gatt_disc_c_test.c index d0034889f..e19db341b 100644 --- a/nimble/host/test/src/ble_gatt_disc_c_test.c +++ b/nimble/host/test/src/ble_gatt_disc_c_test.c @@ -25,7 +25,6 @@ #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 { @@ -51,8 +50,8 @@ ble_gatt_disc_c_test_init(void) } static int -ble_gatt_disc_c_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid, - struct ble_gatt_disc_c_test_char *chars) +ble_gatt_disc_c_test_misc_rx_rsp_once( + uint16_t conn_handle, struct ble_gatt_disc_c_test_char *chars) { struct ble_att_read_type_rsp rsp; uint8_t buf[1024]; @@ -87,14 +86,14 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid, if (chars[i].uuid->type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_READ_TYPE_ADATA_SZ_16 > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; } } else { if (off + BLE_ATT_READ_TYPE_ADATA_SZ_128 > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; @@ -122,7 +121,7 @@ ble_gatt_disc_c_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid, } static void -ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle, uint16_t cid, +ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle, uint16_t end_handle, struct ble_gatt_disc_c_test_char *chars) { @@ -131,7 +130,7 @@ ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle, uint16_t cid, idx = 0; while (chars[idx].def_handle != 0) { - count = ble_gatt_disc_c_test_misc_rx_rsp_once(conn_handle, cid, + count = ble_gatt_disc_c_test_misc_rx_rsp_once(conn_handle, chars + idx); if (count == 0) { break; @@ -141,8 +140,7 @@ ble_gatt_disc_c_test_misc_rx_rsp(uint16_t conn_handle, uint16_t cid, if (chars[idx - 1].def_handle != end_handle) { /* Send the pending ATT Request. */ - ble_hs_test_util_rx_att_err_rsp(conn_handle, cid, - BLE_ATT_OP_READ_TYPE_REQ, + ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, chars[idx - 1].def_handle); } @@ -231,7 +229,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, BLE_L2CAP_CID_ATT, end_handle, chars); + ble_gatt_disc_c_test_misc_rx_rsp(2, end_handle, chars); ble_gatt_disc_c_test_misc_verify_chars(chars, stop_after); } @@ -254,7 +252,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, BLE_L2CAP_CID_ATT, end_handle, rsp_chars); + ble_gatt_disc_c_test_misc_rx_rsp(2, end_handle, rsp_chars); ble_gatt_disc_c_test_misc_verify_chars(ret_chars, 0); } @@ -576,7 +574,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, BLE_L2CAP_CID_ATT, chrs); + num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs); /* Make sure there are still undiscovered characteristics. */ TEST_ASSERT_FATAL(num_chrs < sizeof chrs / sizeof chrs[0] - 1); @@ -600,7 +598,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, BLE_L2CAP_CID_ATT, chrs + num_chrs); + ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs + num_chrs); /* Ensure no follow-up request got sent. It should not have gotten sent * due to mbuf exhaustion. @@ -619,7 +617,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_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, 1); @@ -665,7 +663,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, BLE_L2CAP_CID_ATT, chrs); + num_chrs = ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs); /* Make sure there are still undiscovered characteristics. */ TEST_ASSERT_FATAL(num_chrs < sizeof chrs / sizeof chrs[0] - 1); @@ -688,7 +686,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, BLE_L2CAP_CID_ATT, chrs + num_chrs); + ble_gatt_disc_c_test_misc_rx_rsp_once(1, chrs + num_chrs); /* Ensure no follow-up request got sent. It should not have gotten sent * due to mbuf exhaustion. @@ -706,7 +704,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_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, 1); diff --git a/nimble/host/test/src/ble_gatt_disc_d_test.c b/nimble/host/test/src/ble_gatt_disc_d_test.c index acee2ef8d..e405c86f1 100644 --- a/nimble/host/test/src/ble_gatt_disc_d_test.c +++ b/nimble/host/test/src/ble_gatt_disc_d_test.c @@ -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, uint16_t cid, - struct ble_gatt_disc_d_test_dsc *dscs) +ble_gatt_disc_d_test_misc_rx_rsp_once( + uint16_t conn_handle, 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(uint16_t conn_handle, uint16_t cid, if (dscs[i].dsc_uuid.u.type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_FIND_INFO_IDATA_16_SZ > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; } } else { if (off + BLE_ATT_FIND_INFO_IDATA_128_SZ > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; @@ -104,7 +104,7 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid, off += ble_uuid_length(&dscs[i].dsc_uuid.u); } - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, off); TEST_ASSERT(rc == 0); @@ -113,7 +113,6 @@ ble_gatt_disc_d_test_misc_rx_rsp_once(uint16_t conn_handle, uint16_t cid, 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) { @@ -122,7 +121,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, cid, dscs + idx); + count = ble_gatt_disc_d_test_misc_rx_rsp_once(conn_handle, dscs + idx); if (count == 0) { break; } @@ -131,8 +130,7 @@ 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, cid, - BLE_ATT_OP_FIND_INFO_REQ, + ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_FIND_INFO_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, end_handle); } @@ -225,7 +223,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, BLE_L2CAP_CID_ATT, end_handle, dscs); + ble_gatt_disc_d_test_misc_rx_rsp(2, end_handle, dscs); ble_gatt_disc_d_test_misc_verify_dscs(dscs, stop_after); } @@ -391,7 +389,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, BLE_L2CAP_CID_ATT, dscs); + num_dscs = ble_gatt_disc_d_test_misc_rx_rsp_once(1, dscs); /* Make sure there are still undiscovered services. */ TEST_ASSERT_FATAL(num_dscs < sizeof dscs / sizeof dscs[0] - 1); @@ -414,7 +412,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, BLE_L2CAP_CID_ATT, dscs + num_dscs); + ble_gatt_disc_d_test_misc_rx_rsp_once(1, dscs + num_dscs); /* Ensure no follow-up request got sent. It should not have gotten sent * due to mbuf exhaustion. @@ -432,7 +430,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_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, 1); diff --git a/nimble/host/test/src/ble_gatt_disc_s_test.c b/nimble/host/test/src/ble_gatt_disc_s_test.c index 87735f7df..3e7a30266 100644 --- a/nimble/host/test/src/ble_gatt_disc_s_test.c +++ b/nimble/host/test/src/ble_gatt_disc_s_test.c @@ -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, uint16_t cid, - struct ble_gatt_disc_s_test_svc *services) +ble_gatt_disc_s_test_misc_rx_all_rsp_once( + uint16_t conn_handle, 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(uint16_t conn_handle, uint16_t cid, if (services[i].uuid->type == BLE_UUID_TYPE_16) { if (off + BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_16 > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; } } else { if (off + BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_128 > - ble_att_mtu_by_cid(conn_handle,cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; @@ -110,7 +110,7 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(uint16_t conn_handle, uint16_t cid, off += ble_uuid_length(services[i].uuid); } - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, off); TEST_ASSERT(rc == 0); @@ -118,22 +118,22 @@ ble_gatt_disc_s_test_misc_rx_all_rsp_once(uint16_t conn_handle, uint16_t cid, } static void -ble_gatt_disc_s_test_misc_rx_all_rsp(uint16_t conn_handle, uint16_t cid, - struct ble_gatt_disc_s_test_svc *services) +ble_gatt_disc_s_test_misc_rx_all_rsp( + uint16_t conn_handle, 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, cid, + count = ble_gatt_disc_s_test_misc_rx_all_rsp_once(conn_handle, 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, cid, + ble_hs_test_util_rx_att_err_rsp(conn_handle, 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(uint16_t conn_handle, uint16_t cid, } static int -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) +ble_gatt_disc_s_test_misc_rx_uuid_rsp_once( + uint16_t conn_handle, 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(uint16_t conn_handle, uint16_t cid, } if (off + BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ > - ble_att_mtu_by_cid(conn_handle, cid)) { + ble_att_mtu(conn_handle)) { /* Can't fit any more entries. */ break; @@ -173,7 +173,7 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(uint16_t conn_handle, uint16_t cid, off += 2; } - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, off); TEST_ASSERT(rc == 0); @@ -181,22 +181,22 @@ ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(uint16_t conn_handle, uint16_t cid, } static void -ble_gatt_disc_s_test_misc_rx_uuid_rsp(uint16_t conn_handle, uint16_t cid, - struct ble_gatt_disc_s_test_svc *services) +ble_gatt_disc_s_test_misc_rx_uuid_rsp( + uint16_t conn_handle, 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, cid, + count = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(conn_handle, 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, cid, + ble_hs_test_util_rx_att_err_rsp(conn_handle, 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, BLE_L2CAP_CID_ATT, services); + ble_gatt_disc_s_test_misc_rx_all_rsp(2, 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, BLE_L2CAP_CID_ATT, services); + ble_gatt_disc_s_test_misc_rx_uuid_rsp(2, 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, BLE_L2CAP_CID_ATT, svcs); + num_svcs = ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, 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, BLE_L2CAP_CID_ATT, svcs + num_svcs); + ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, 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_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, 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, BLE_L2CAP_CID_ATT, svcs); + num_svcs = ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, 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, BLE_L2CAP_CID_ATT, svcs + num_svcs); + ble_gatt_disc_s_test_misc_rx_uuid_rsp_once(1, 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_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, 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, BLE_L2CAP_CID_ATT, svcs); + ble_gatt_disc_s_test_misc_rx_all_rsp_once(1, svcs); /* Keep trying to resume for 30 seconds, but never free any mbufs. Verify * procedure eventually times out. diff --git a/nimble/host/test/src/ble_gatt_find_s_test.c b/nimble/host/test/src/ble_gatt_find_s_test.c index 5f8075c9a..172bdd332 100644 --- a/nimble/host/test/src/ble_gatt_find_s_test.c +++ b/nimble/host/test/src/ble_gatt_find_s_test.c @@ -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, uint16_t cid, - struct ble_gatt_find_s_test_entry *entries) +ble_gatt_find_s_test_misc_rx_read_type( + uint16_t conn_handle, struct ble_gatt_find_s_test_entry *entries) { struct ble_att_read_type_rsp rsp; uint8_t buf[1024]; @@ -134,15 +134,14 @@ ble_gatt_find_s_test_misc_rx_read_type(uint16_t conn_handle, uint16_t cid, } if (i == 0) { - ble_hs_test_util_rx_att_err_rsp(conn_handle, cid, - BLE_ATT_OP_READ_TYPE_REQ, + ble_hs_test_util_rx_att_err_rsp(conn_handle, 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, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, off); TEST_ASSERT(rc == 0); @@ -150,7 +149,7 @@ ble_gatt_find_s_test_misc_rx_read_type(uint16_t conn_handle, uint16_t cid, } static void -ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, uint16_t cid, const ble_uuid_t *uuid) +ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, const ble_uuid_t *uuid) { uint8_t buf[17]; int rc; @@ -160,7 +159,7 @@ ble_gatt_find_s_test_misc_rx_read(uint16_t conn_handle, uint16_t cid, const ble_ buf[0] = BLE_ATT_OP_READ_RSP; ble_uuid_flat(uuid, buf + 1); - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, 17); TEST_ASSERT(rc == 0); } @@ -201,7 +200,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, uint16_t cid, +ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, struct ble_gatt_find_s_test_entry *entries) { @@ -220,7 +219,7 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, uint16_t cid, 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, cid, + num_found = ble_gatt_find_s_test_misc_rx_read_type(conn_handle, entries + idx); if (num_found == 0) { break; @@ -230,7 +229,7 @@ ble_gatt_find_s_test_misc_find_inc(uint16_t conn_handle, uint16_t cid, 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, cid, + ble_gatt_find_s_test_misc_rx_read(conn_handle, entries[idx].uuid); } @@ -256,7 +255,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, BLE_L2CAP_CID_ATT, 5, 10, + ble_gatt_find_s_test_misc_find_inc(2, 5, 10, ((struct ble_gatt_find_s_test_entry[]) { { .inc_handle = 6, .start_handle = 35, @@ -276,7 +275,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, BLE_L2CAP_CID_ATT, 34, 100, + ble_gatt_find_s_test_misc_find_inc(2, 34, 100, ((struct ble_gatt_find_s_test_entry[]) { { .inc_handle = 36, .start_handle = 403, @@ -291,7 +290,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, BLE_L2CAP_CID_ATT, 34, 100, + ble_gatt_find_s_test_misc_find_inc(2, 34, 100, ((struct ble_gatt_find_s_test_entry[]) { { .inc_handle = 36, .start_handle = 403, @@ -311,7 +310,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, BLE_L2CAP_CID_ATT, 1, 100, + ble_gatt_find_s_test_misc_find_inc(2, 1, 100, ((struct ble_gatt_find_s_test_entry[]) { { .inc_handle = 36, .start_handle = 403, @@ -380,7 +379,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, BLE_L2CAP_CID_ATT, incs); + ble_gatt_find_s_test_misc_rx_read_type(1, incs); /* Ensure no follow-up request got sent. It should not have gotten sent * due to mbuf exhaustion. @@ -403,11 +402,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, BLE_L2CAP_CID_ATT, incs[0].uuid); + ble_gatt_find_s_test_misc_rx_read(1, 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, BLE_L2CAP_CID_ATT, incs + 1); + ble_gatt_find_s_test_misc_rx_read_type(1, incs + 1); /* Verify the procedure succeeds after mbufs become available. */ rc = os_mbuf_free_chain(oms); @@ -415,9 +414,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, BLE_L2CAP_CID_ATT, incs[1].uuid); + ble_gatt_find_s_test_misc_rx_read(1, incs[1].uuid); - ble_hs_test_util_rx_att_err_rsp(1, BLE_L2CAP_CID_ATT, + ble_hs_test_util_rx_att_err_rsp(1, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, 1); diff --git a/nimble/host/test/src/ble_gatt_read_test.c b/nimble/host/test/src/ble_gatt_read_test.c index a22e5a559..572b0bf1c 100644 --- a/nimble/host/test/src/ble_gatt_read_test.c +++ b/nimble/host/test/src/ble_gatt_read_test.c @@ -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, uint16_t cid, +ble_gatt_read_test_misc_rx_rsp_good_raw(uint16_t conn_handle, uint8_t att_op, const void *data, int data_len) { @@ -174,28 +174,27 @@ ble_gatt_read_test_misc_rx_rsp_good_raw(uint16_t conn_handle, uint16_t cid, buf[0] = att_op; memcpy(buf + 1, data, data_len); - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, 1 + data_len); TEST_ASSERT(rc == 0); } static void -ble_gatt_read_test_misc_rx_rsp_good(uint16_t conn_handle, uint16_t cid, +ble_gatt_read_test_misc_rx_rsp_good(uint16_t conn_handle, struct ble_hs_test_util_flat_attr *attr) { - ble_gatt_read_test_misc_rx_rsp_good_raw(conn_handle, cid, - BLE_ATT_OP_READ_RSP, + ble_gatt_read_test_misc_rx_rsp_good_raw(conn_handle, BLE_ATT_OP_READ_RSP, attr->value, attr->value_len); } static void -ble_gatt_read_test_misc_rx_rsp_bad(uint16_t conn_handle, uint16_t cid, +ble_gatt_read_test_misc_rx_rsp_bad(uint16_t conn_handle, uint8_t att_error, uint16_t err_handle) { /* Send the pending ATT Read Request. */ - ble_hs_test_util_rx_att_err_rsp(conn_handle, cid, BLE_ATT_OP_READ_REQ, + ble_hs_test_util_rx_att_err_rsp(conn_handle, BLE_ATT_OP_READ_REQ, att_error, err_handle); } @@ -256,7 +255,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, BLE_L2CAP_CID_ATT, attr); + ble_gatt_read_test_misc_rx_rsp_good(2, attr); TEST_ASSERT(ble_gatt_read_test_num_attrs == 1); TEST_ASSERT(ble_gatt_read_test_attrs[0].conn_handle == 2); @@ -279,7 +278,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, BLE_L2CAP_CID_ATT, att_status, attr->handle); + ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, attr->handle); TEST_ASSERT(ble_gatt_read_test_num_attrs == 0); TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2); @@ -310,8 +309,7 @@ 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_L2CAP_CID_ATT, - BLE_ATT_OP_READ_TYPE_REQ, + ble_hs_test_util_rx_att_err_rsp(2, BLE_ATT_OP_READ_TYPE_REQ, BLE_ATT_ERR_ATTR_NOT_FOUND, start_handle); break; @@ -371,7 +369,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, BLE_L2CAP_CID_ATT, att_op, + ble_gatt_read_test_misc_rx_rsp_good_raw(2, att_op, attr->value + off, chunk_sz); rem_len -= chunk_sz; off += chunk_sz; @@ -403,7 +401,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, BLE_L2CAP_CID_ATT, att_status, attr->handle); + ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, attr->handle); TEST_ASSERT(ble_gatt_read_test_num_attrs == 0); TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2); @@ -460,7 +458,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_L2CAP_CID_ATT, BLE_ATT_OP_READ_MULT_RSP, + ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_MULT_RSP, expected_value, off); TEST_ASSERT(ble_gatt_read_test_complete); @@ -490,7 +488,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, BLE_L2CAP_CID_ATT, att_status, err_handle); + ble_gatt_read_test_misc_rx_rsp_bad(2, att_status, err_handle); TEST_ASSERT(ble_gatt_read_test_num_attrs == 0); TEST_ASSERT(ble_gatt_read_test_bad_conn_handle == 2); @@ -803,9 +801,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, 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); + 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); TEST_ASSERT(ble_gatt_read_test_num_attrs == 3); @@ -854,8 +852,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_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, + 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, attr.value + off, chunk_sz); off += chunk_sz; @@ -877,8 +875,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_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, + 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, attr.value + off, chunk_sz); off += chunk_sz; @@ -899,7 +897,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_L2CAP_CID_ATT, BLE_ATT_OP_READ_RSP, + ble_gatt_read_test_misc_rx_rsp_good_raw(2, BLE_ATT_OP_READ_RSP, attr.value + off, chunk_sz); off += chunk_sz; diff --git a/nimble/host/test/src/ble_gatt_write_test.c b/nimble/host/test/src/ble_gatt_write_test.c index ea815c0d5..caa8e5657 100644 --- a/nimble/host/test/src/ble_gatt_write_test.c +++ b/nimble/host/test/src/ble_gatt_write_test.c @@ -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 cid, - uint16_t attr_handle, uint16_t offset, +ble_gatt_write_test_rx_prep_rsp(uint16_t conn_handle, 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 cid, 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, cid, buf, + conn_handle, BLE_L2CAP_CID_ATT, 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, uint16_t cid) +ble_gatt_write_test_rx_exec_rsp(uint16_t conn_handle) { uint8_t op; int rc; op = BLE_ATT_OP_EXEC_WRITE_RSP; - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, &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_by_cid(2, BLE_L2CAP_CID_ATT); + mtu = ble_att_mtu(2); 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, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len); + 2, 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_L2CAP_CID_ATT); + ble_gatt_write_test_rx_exec_rsp(2); /* 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, uint16_t cid, +typedef void ble_gatt_write_test_long_fail_fn(uint16_t conn_handle, 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_by_cid(2, BLE_L2CAP_CID_ATT); + mtu = ble_att_mtu(2); 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, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len); + 2, 100, off, ble_gatt_write_test_attr_value + off, len); } else { - cb(2, BLE_L2CAP_CID_ATT, off, len); + cb(2, 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, uint16_t cid, +ble_gatt_write_test_misc_long_fail_handle(uint16_t conn_handle, int off, int len) { ble_gatt_write_test_rx_prep_rsp( - conn_handle, cid, 99, off, ble_gatt_write_test_attr_value + off, + conn_handle, 99, off, ble_gatt_write_test_attr_value + off, len); } static void -ble_gatt_write_test_misc_long_fail_offset(uint16_t conn_handle, uint16_t cid, +ble_gatt_write_test_misc_long_fail_offset(uint16_t conn_handle, int off, int len) { ble_gatt_write_test_rx_prep_rsp( - conn_handle, cid, 100, off + 1, ble_gatt_write_test_attr_value + off, + conn_handle, 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, uint16_t cid, +ble_gatt_write_test_misc_long_fail_value(uint16_t conn_handle, int off, int len) { ble_gatt_write_test_rx_prep_rsp( - conn_handle, cid, 100, off, ble_gatt_write_test_attr_value + off + 1, + conn_handle, 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, uint16_t cid, +ble_gatt_write_test_misc_long_fail_length(uint16_t conn_handle, int off, int len) { ble_gatt_write_test_rx_prep_rsp( - conn_handle, cid, 100, off, ble_gatt_write_test_attr_value + off, + conn_handle, 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_by_cid(2, BLE_L2CAP_CID_ATT); + mtu = ble_att_mtu(2); 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, BLE_L2CAP_CID_ATT, attr->handle, off, + ble_gatt_write_test_rx_prep_rsp(2, 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_L2CAP_CID_ATT); + ble_gatt_write_test_rx_exec_rsp(2); /* 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, BLE_L2CAP_CID_ATT, 100, off, ble_gatt_write_test_attr_value + off, len); + 2, 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,8 +611,7 @@ 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_L2CAP_CID_ATT, - BLE_ATT_OP_PREP_WRITE_REQ, + ble_hs_test_util_rx_att_err_rsp(2, BLE_ATT_OP_PREP_WRITE_REQ, BLE_ATT_ERR_PREPARE_QUEUE_FULL, 100); /* Verify callback was called. */ @@ -655,14 +654,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_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; + chunk_sz = ble_att_mtu(2) - 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, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, + ble_gatt_write_test_rx_prep_rsp(2, attr.handle, off, attr.value + off, chunk_sz); off += chunk_sz; @@ -689,7 +688,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, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, chunk_sz); + 2, attr.handle, off, attr.value + off, chunk_sz); off += chunk_sz; /* Ensure no follow-up request got sent. It should not have gotten sent @@ -712,7 +711,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_L2CAP_CID_ATT); + ble_gatt_write_test_rx_exec_rsp(2); /* Verify callback got called. */ TEST_ASSERT(ble_gatt_write_test_cb_called); @@ -751,14 +750,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_by_cid(2, BLE_L2CAP_CID_ATT) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ; + chunk_sz = ble_att_mtu(2) - 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, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, + ble_gatt_write_test_rx_prep_rsp(2, attr.handle, off, attr.value + off, chunk_sz); off += chunk_sz; @@ -785,7 +784,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, BLE_L2CAP_CID_ATT, attr.handle, off, attr.value + off, chunk_sz); + 2, attr.handle, off, attr.value + off, chunk_sz); off += chunk_sz; /* Ensure no follow-up request got sent. It should not have gotten sent @@ -808,7 +807,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_L2CAP_CID_ATT); + ble_gatt_write_test_rx_exec_rsp(2); /* Verify callback got called. */ TEST_ASSERT(ble_gatt_write_test_cb_called); diff --git a/nimble/host/test/src/ble_hs_test_util.c b/nimble/host/test/src/ble_hs_test_util.c index f5463b3ea..c336ddf92 100644 --- a/nimble/host/test/src/ble_hs_test_util.c +++ b/nimble/host/test/src/ble_hs_test_util.c @@ -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, BLE_L2CAP_CID_ATT, &conn, &chan); + rc = ble_att_conn_chan_find(conn_handle, &conn, &chan); assert(rc == 0); chan->my_mtu = mtu; chan->peer_mtu = mtu; @@ -772,7 +772,6 @@ 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) { @@ -785,7 +784,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, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, sizeof buf); return rc; @@ -1071,7 +1070,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, uint16_t cid, uint8_t req_op, +ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint8_t req_op, uint8_t error_code, uint16_t err_handle) { struct ble_att_error_rsp rsp; @@ -1084,7 +1083,7 @@ ble_hs_test_util_rx_att_err_rsp(uint16_t conn_handle, uint16_t cid, uint8_t req_ ble_att_error_rsp_write(buf, sizeof buf, &rsp); - rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, cid, + rc = ble_hs_test_util_l2cap_rx_payload_flat(conn_handle, BLE_L2CAP_CID_ATT, buf, sizeof buf); TEST_ASSERT(rc == 0); } diff --git a/nimble/host/test/src/ble_hs_test_util.h b/nimble/host/test/src/ble_hs_test_util.h index 6d5d04c05..7a0aa3eb1 100644 --- a/nimble/host/test/src/ble_hs_test_util.h +++ b/nimble/host/test/src/ble_hs_test_util.h @@ -173,7 +173,6 @@ 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, @@ -229,9 +228,8 @@ 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, uint16_t cid, - 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, 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); diff --git a/nimble/host/test/syscfg.yml b/nimble/host/test/syscfg.yml index cfb3a8178..031b6c8ba 100644 --- a/nimble/host/test/syscfg.yml +++ b/nimble/host/test/syscfg.yml @@ -30,4 +30,3 @@ syscfg.vals: BLE_VERSION: 52 BLE_L2CAP_ENHANCED_COC: 1 BLE_TRANSPORT_LL: custom - BLE_EATT_CHAN_NUM: 0 diff --git a/nimble/include/nimble/nimble_opt_auto.h b/nimble/include/nimble/nimble_opt_auto.h index 224919938..6326abf54 100644 --- a/nimble/include/nimble/nimble_opt_auto.h +++ b/nimble/include/nimble/nimble_opt_auto.h @@ -113,10 +113,6 @@ extern "C" { #define NIMBLE_BLE_ATT_CLT_INDICATE \ (MYNEWT_VAL(BLE_GATT_INDICATE)) -#undef NIMBLE_BLE_ATT_CLT_MULTI_NOTIFY -#define NIMBLE_BLE_ATT_CLT_MULTI_NOTIFY \ - (MYNEWT_VAL(BLE_GATT_MULTI_NOTIFY)) - /** Security manager settings. */ #undef NIMBLE_BLE_SM diff --git a/porting/examples/linux/include/logcfg/logcfg.h b/porting/examples/linux/include/logcfg/logcfg.h index 9872da0bd..89af35309 100644 --- a/porting/examples/linux/include/logcfg/logcfg.h +++ b/porting/examples/linux/include/logcfg/logcfg.h @@ -8,13 +8,6 @@ #include "modlog/modlog.h" #include "log_common/log_common.h" -#define BLE_EATT_LOG_DEBUG(...) MODLOG_INFO(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - #define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) #define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) #define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) diff --git a/porting/examples/linux/include/syscfg/syscfg.h b/porting/examples/linux/include/syscfg/syscfg.h index 07bbae8c7..d089d7e60 100644 --- a/porting/examples/linux/include/syscfg/syscfg.h +++ b/porting/examples/linux/include/syscfg/syscfg.h @@ -535,10 +535,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI -#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI (MYNEWT_VAL_BLE_ATT_SVR_NOTIFY && (MYNEWT_VAL_BLE_VERSION >= 52)) -#endif - #ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE #define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) #endif @@ -579,22 +575,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) #endif -#ifndef MYNEWT_VAL_BLE_EATT_CHAN_NUM -#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (0) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_LVL -#define MYNEWT_VAL_BLE_EATT_LOG_LVL (1) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_MOD -#define MYNEWT_VAL_BLE_EATT_LOG_MOD (27) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_MTU -#define MYNEWT_VAL_BLE_EATT_MTU (128) -#endif - #ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE #define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) #endif @@ -635,10 +615,6 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY -#define MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY (1) -#endif - #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif diff --git a/porting/examples/linux_blemesh/include/logcfg/logcfg.h b/porting/examples/linux_blemesh/include/logcfg/logcfg.h index 99afa084f..520c658c6 100644 --- a/porting/examples/linux_blemesh/include/logcfg/logcfg.h +++ b/porting/examples/linux_blemesh/include/logcfg/logcfg.h @@ -8,13 +8,6 @@ #include "modlog/modlog.h" #include "log_common/log_common.h" -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - #define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) #define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) #define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) diff --git a/porting/examples/linux_blemesh/include/syscfg/syscfg.h b/porting/examples/linux_blemesh/include/syscfg/syscfg.h index bd0546baa..1df8abaf8 100644 --- a/porting/examples/linux_blemesh/include/syscfg/syscfg.h +++ b/porting/examples/linux_blemesh/include/syscfg/syscfg.h @@ -536,10 +536,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI -#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI (MYNEWT_VAL_BLE_ATT_SVR_NOTIFY && (MYNEWT_VAL_BLE_VERSION >= 52)) -#endif - #ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE #define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) #endif @@ -580,22 +576,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) #endif -#ifndef MYNEWT_VAL_BLE_EATT_CHAN_NUM -#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (0) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_LVL -#define MYNEWT_VAL_BLE_EATT_LOG_LVL (1) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_MOD -#define MYNEWT_VAL_BLE_EATT_LOG_MOD (27) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_MTU -#define MYNEWT_VAL_BLE_EATT_MTU (128) -#endif - #ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE #define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) #endif @@ -636,10 +616,6 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY -#define MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY (1) -#endif - #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif diff --git a/porting/examples/nuttx/include/syscfg/syscfg.h b/porting/examples/nuttx/include/syscfg/syscfg.h index 10adecea9..51f8c44bf 100644 --- a/porting/examples/nuttx/include/syscfg/syscfg.h +++ b/porting/examples/nuttx/include/syscfg/syscfg.h @@ -615,10 +615,6 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY -#define MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY (1) -#endif - #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif diff --git a/porting/nimble/include/logcfg/logcfg.h b/porting/nimble/include/logcfg/logcfg.h index 14633c52f..f2f227c89 100644 --- a/porting/nimble/include/logcfg/logcfg.h +++ b/porting/nimble/include/logcfg/logcfg.h @@ -166,11 +166,4 @@ #define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) #define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - #endif diff --git a/porting/nimble/include/syscfg/syscfg.h b/porting/nimble/include/syscfg/syscfg.h index e1c9971fb..cc8a60b37 100644 --- a/porting/nimble/include/syscfg/syscfg.h +++ b/porting/nimble/include/syscfg/syscfg.h @@ -538,10 +538,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI -#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI (MYNEWT_VAL_BLE_ATT_SVR_NOTIFY && (MYNEWT_VAL_BLE_VERSION >= 52)) -#endif - #ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE #define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) #endif @@ -582,22 +578,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) #endif -#ifndef MYNEWT_VAL_BLE_EATT_CHAN_NUM -#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (0) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_LVL -#define MYNEWT_VAL_BLE_EATT_LOG_LVL (1) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_MOD -#define MYNEWT_VAL_BLE_EATT_LOG_MOD (27) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_MTU -#define MYNEWT_VAL_BLE_EATT_MTU (128) -#endif - #ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE #define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) #endif @@ -638,10 +618,6 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY -#define MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY (1) -#endif - #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif diff --git a/porting/npl/riot/include/logcfg/logcfg.h b/porting/npl/riot/include/logcfg/logcfg.h index 4fe2ee015..89af35309 100644 --- a/porting/npl/riot/include/logcfg/logcfg.h +++ b/porting/npl/riot/include/logcfg/logcfg.h @@ -8,13 +8,6 @@ #include "modlog/modlog.h" #include "log_common/log_common.h" -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - #define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) #define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) #define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h index c97901376..c90322eaa 100644 --- a/porting/npl/riot/include/syscfg/syscfg.h +++ b/porting/npl/riot/include/syscfg/syscfg.h @@ -1406,10 +1406,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI -#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY_MULTI (MYNEWT_VAL_BLE_ATT_SVR_NOTIFY && (MYNEWT_VAL_BLE_VERSION >= 52)) -#endif - #ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE #define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) #endif @@ -1450,22 +1446,6 @@ #define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) #endif -#ifndef MYNEWT_VAL_BLE_EATT_CHAN_NUM -#define MYNEWT_VAL_BLE_EATT_CHAN_NUM (0) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_LVL -#define MYNEWT_VAL_BLE_EATT_LOG_LVL (1) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_LOG_MOD -#define MYNEWT_VAL_BLE_EATT_LOG_MOD (27) -#endif - -#ifndef MYNEWT_VAL_BLE_EATT_MTU -#define MYNEWT_VAL_BLE_EATT_MTU (128) -#endif - #ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE #define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) #endif @@ -1506,10 +1486,6 @@ #define MYNEWT_VAL_BLE_GATT_NOTIFY (1) #endif -#ifndef MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY -#define MYNEWT_VAL_BLE_GATT_MULTI_NOTIFY (1) -#endif - #ifndef MYNEWT_VAL_BLE_GATT_READ #define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif