Skip to content

Commit 30370ff

Browse files
committed
host/ble_gattc: Cancel prepered writes if data doesn't match in response
If data received in ble_gattc_write_long_rx_prep() doesn't match data sent in prepare write request we need not only return error in function, but also send ATT_Execute_Write_Response with flag set to BLE_ATT_EXEC_WRITE_F_CANCEL. This is affecting GATT/CL/GAW/BI-32-C
1 parent 43a7439 commit 30370ff

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

nimble/host/src/ble_gattc.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,17 +3765,20 @@ ble_gattc_write_long_rx_prep(struct ble_gattc_proc *proc,
37653765
proc->write_long.length) != 0) {
37663766

37673767
rc = BLE_HS_EBADDATA;
3768-
goto err;
3769-
}
37703768

3771-
/* Send follow-up request. */
3772-
proc->write_long.attr.offset += OS_MBUF_PKTLEN(om);
3773-
rc = ble_gattc_write_long_resume(proc);
3774-
if (rc != 0) {
3769+
/* if data doesn't match up send cancel write */
3770+
ble_att_clt_tx_exec_write(proc->conn_handle, BLE_ATT_EXEC_WRITE_F_CANCEL);
37753771
goto err;
3776-
}
3772+
} else {
3773+
/* Send follow-up request. */
3774+
proc->write_long.attr.offset += OS_MBUF_PKTLEN(om);
3775+
rc = ble_gattc_write_long_resume(proc);
3776+
if (rc != 0) {
3777+
goto err;
3778+
}
37773779

3778-
return 0;
3780+
return 0;
3781+
}
37793782

37803783
err:
37813784
/* XXX: Might need to cancel pending writes. */

0 commit comments

Comments
 (0)