mynewt-nimble
mynewt-nimble copied to clipboard
Fixed a check in ble_att_clt_tx_prep_write() api
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().
Hi @sjanc , Can you please take a look?
Style check summary
No suggestions at this time!
Hi @sjanc , can you please take a look at this?
#AutoPTS run mynewt GATT/CL/GAW
Scheduled PR #https://github.com/apache/mynewt-nimble/pull/1428#issuecomment-1410996839 after 10:25:44.
AutoPTS Bot results: No failed test found.
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)..