@@ -640,10 +640,9 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock {
640
640
connection_handle_t connection_handle,
641
641
uint16_t attribute_handle,
642
642
uint8_t * data,
643
- uint16_t write_length,
644
- uint16_t chunk_size
643
+ uint16_t write_length
645
644
) : ProcedureControlBlock(WRITE_PROCEDURE, connection_handle),
646
- attribute_handle (attribute_handle), write_length(write_length), chunk_size(chunk_size), offset(0 ), data(data),
645
+ attribute_handle (attribute_handle), write_length(write_length), offset(0 ), data(data),
647
646
prepare_success(false ), status(BLE_ERROR_INITIALIZATION_INCOMPLETE), error_code(0xFF ) {
648
647
}
649
648
@@ -725,10 +724,10 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock {
725
724
726
725
void handle_prepare_write_response (GattClient* client, const AttPrepareWriteResponse& write_response) {
727
726
ble_error_t err = BLE_ERROR_UNSPECIFIED;
728
- uint16_t mtu_size = client->get_mtu (connection_handle);
729
- offset += chunk_size;
727
+ offset += write_response.partial_value .size ();
730
728
uint16_t data_left = write_length - offset; /* offset is guaranteed to be less of equal to write_length */
731
729
if (data_left) {
730
+ uint16_t chunk_size = client->get_mtu (connection_handle) - PREPARE_WRITE_HEADER_LENGTH;
732
731
if (chunk_size > data_left) {
733
732
chunk_size = data_left;
734
733
}
@@ -836,7 +835,6 @@ struct GattClient::WriteControlBlock : public ProcedureControlBlock {
836
835
uint16_t attribute_handle;
837
836
uint16_t write_length;
838
837
uint16_t offset;
839
- uint16_t chunk_size;
840
838
uint8_t * data;
841
839
bool prepare_success;
842
840
ble_error_t status;
@@ -1190,8 +1188,7 @@ ble_error_t GattClient::write(
1190
1188
connection_handle,
1191
1189
attribute_handle,
1192
1190
data,
1193
- length,
1194
- mtu - PREPARE_WRITE_HEADER_LENGTH
1191
+ length
1195
1192
);
1196
1193
1197
1194
if (write_pcb == nullptr ) {
0 commit comments