@@ -221,7 +221,7 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
221
221
};
222
222
223
223
_adamsg.prepare ( (void *) data, len);
224
- VERIFY_STATUS ( sd_ble_gattc_write (_service->connHandle (), ¶m) );
224
+ VERIFY_STATUS ( sd_ble_gattc_write (_service->connHandle (), ¶m), 0 );
225
225
226
226
// len is always 0 in BLE_GATTC_EVT_WRITE_RSP for BLE_GATT_OP_WRITE_REQ
227
227
count = (_adamsg.waitUntilComplete (BLE_GENERIC_TIMEOUT) < 0 ? 0 : len);
@@ -230,7 +230,6 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
230
230
{
231
231
/* ------------- Long Write Sequence -------------*/
232
232
// For BLE_GATT_OP_PREP_WRITE_REQ, 2 bytes are used for offset
233
-
234
233
ble_gattc_write_params_t param =
235
234
{
236
235
.write_op = BLE_GATT_OP_PREP_WRITE_REQ,
@@ -242,7 +241,7 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
242
241
};
243
242
244
243
_adamsg.prepare ( (void *) data, len);
245
- VERIFY_STATUS ( sd_ble_gattc_write (_service->connHandle (), ¶m) );
244
+ VERIFY_STATUS ( sd_ble_gattc_write (_service->connHandle (), ¶m), 0 );
246
245
count = _adamsg.waitUntilComplete ( (len/(max_payload-2 ) + 1 ) * BLE_GENERIC_TIMEOUT );
247
246
248
247
// delay to swallow last WRITE RESPONSE
@@ -284,7 +283,7 @@ uint16_t BLEClientCharacteristic::write(const void* data, uint16_t len)
284
283
while ( remaining )
285
284
{
286
285
// TODO only Write without response consume a TX buffer
287
- if ( !Bluefruit.Gap .getWriteCmdPacket (_service->connHandle ()) ) return NRF_ERROR_RESOURCES; // BLE_ERROR_NO_TX_PACKETS ;
286
+ if ( !Bluefruit.Gap .getWriteCmdPacket (_service->connHandle ()) ) break ;
288
287
289
288
uint16_t packet_len = min16 (max_payload, remaining);
290
289
@@ -304,7 +303,7 @@ uint16_t BLEClientCharacteristic::write(const void* data, uint16_t len)
304
303
u8data += packet_len;
305
304
}
306
305
307
- return len;
306
+ return len-remaining ;
308
307
}
309
308
310
309
uint16_t BLEClientCharacteristic::write8 (uint8_t value)
0 commit comments