mynewt-nimble icon indicating copy to clipboard operation
mynewt-nimble copied to clipboard

Fixed a check in ble_att_clt_tx_prep_write() api

Open IshaESP opened this issue 2 years ago • 7 comments

If application is going to send data more than MTU size using ble_gattc_write_long(), after sending first batch of data of MTU size the offset gets incremented by (MTU - BLE_ATT_PREP_WRITE_CMD_BASE_SZ). This check will always fail in that case, as offset will be equal to (MTU - BLE_ATT_PREP_WRITE_CMD_BASE_SZ), and (offset + OS_MBUF_PKTLEN(txom)) will always be greater than BLE_ATT_ATTR_MAX_LEN. Thus failing to send the whole data.


/*** Error: offset + length greater than maximum attribute size. */
ble_att_clt_test_misc_prep_bad(1, 507, attr_data, 6, BLE_HS_EINVAL);

This test case assumes that the offset will never go beyond BLE_ATT_ATTR_MAX_LEN. Considering we want to send larger buffer data lets say 2000 bytes, in that case the offset will get incremented to 512 after sending first batch of data(assuming mtu is 517). But since the api in this test case is invoked only once, it doesn't consider the case of sending fragmented data which can have higher offset values. But now, this PR addresses the issue of sending packets having data larger than MTU. Hence removing this test case.

In addition, ble_att_clt_tx_prep_write() is invoked by ble_gattc_write_long_tx() and ble_gattc_write_reliable_tx() which already takes care of the offset parameter. So no need to handle it in ble_att_clt_tx_prep_write().

IshaESP avatar Jan 18 '23 13:01 IshaESP

Hi @sjanc , Can you please take a look?

IshaESP avatar Jan 18 '23 13:01 IshaESP

Style check summary

No suggestions at this time!

apache-mynewt-bot avatar Jan 19 '23 06:01 apache-mynewt-bot

Hi @sjanc , can you please take a look at this?

IshaESP avatar Jan 23 '23 06:01 IshaESP

#AutoPTS run mynewt GATT/CL/GAW

sjanc avatar Jan 31 '23 20:01 sjanc

Scheduled PR #https://github.com/apache/mynewt-nimble/pull/1428#issuecomment-1410996839 after 10:25:44.

codecoup-tester avatar Feb 01 '23 09:02 codecoup-tester

AutoPTS Bot results: No failed test found.

codecoup-tester avatar Feb 01 '23 09:02 codecoup-tester

OK, so I'm not sure about this patch... spec clearly states that maximum attribute value shall be 512 and that data interpretation is responsibility of the higher layer. And offset is used for reading long attribute value but long here doesn't mean bigger than 512, but bigger than (ATT_MTU -1)..

sjanc avatar Feb 01 '23 13:02 sjanc