This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 027a56d46 nimble/host: move att_truncate_to_mtu to ble_att_svr_tx_rsp
027a56d46 is described below
commit 027a56d46ed88f63482394cf8d1b8862a29e4a06
Author: Piotr Narajowski <[email protected]>
AuthorDate: Wed Sep 25 13:56:09 2024 +0200
nimble/host: move att_truncate_to_mtu to ble_att_svr_tx_rsp
Move att_truncate_to_mtu from ble_eatt_tx to ble_att_svr_tx_rsp.
This could cause some issues when used by client.
---
nimble/host/src/ble_att_svr.c | 21 +++++++++++++++++++++
nimble/host/src/ble_eatt.c | 2 --
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c
index 145318f09..783999d99 100644
--- a/nimble/host/src/ble_att_svr.c
+++ b/nimble/host/src/ble_att_svr.c
@@ -625,6 +625,8 @@ static int
ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct
os_mbuf *om,
uint8_t att_op, uint8_t err_status, uint16_t err_handle)
{
+ struct ble_l2cap_chan *chan;
+ struct ble_hs_conn *conn;
int do_tx;
if (hs_status != 0 && err_status == 0) {
@@ -636,6 +638,24 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int
hs_status, struct os_
if (do_tx) {
if (hs_status == 0) {
+ ble_hs_lock();
+ conn = ble_hs_conn_find(conn_handle);
+ if (conn == NULL) {
+ hs_status = BLE_HS_ENOTCONN;
+ ble_hs_unlock();
+ goto done;
+ }
+
+ chan = ble_hs_conn_chan_find_by_scid(conn, cid);
+ if (chan == NULL) {
+ hs_status = BLE_HS_ENOENT;
+ ble_hs_unlock();
+ goto done;
+ }
+
+ ble_att_truncate_to_mtu(chan, om);
+ ble_hs_unlock();
+
hs_status = ble_att_tx(conn_handle, cid, om);
om = NULL;
if (hs_status) {
@@ -643,6 +663,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int
hs_status, struct os_
}
}
+done:
if (hs_status != 0) {
STATS_INC(ble_att_stats, error_rsp_tx);
diff --git a/nimble/host/src/ble_eatt.c b/nimble/host/src/ble_eatt.c
index 96666c9d0..c15f545b6 100644
--- a/nimble/host/src/ble_eatt.c
+++ b/nimble/host/src/ble_eatt.c
@@ -476,8 +476,6 @@ ble_eatt_tx(uint16_t conn_handle, uint16_t cid, struct
os_mbuf *txom)
goto error;
}
- ble_att_truncate_to_mtu(eatt->chan, txom);
-
rc = ble_l2cap_send(eatt->chan, txom);
if (rc == 0) {
goto done;