Skip to content

Commit a733a56

Browse files
committed
fix #192 client char write() return number of writtent instead of error
1 parent 53ed8be commit a733a56

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- Added support for using the Low Frequency RC oscillator ( PR #144 thanks to @jeremypoulter )
2222
- USE_LFRC or USE_LFXO must be defined in board's variant.h
2323
- Fixed Scanner running state when timeout ( PR #186 thanks to @Ryscho )
24+
- Fixed #192 Client Characteristic write() return number of writtent instead of error code
2425

2526
## 0.8.6
2627

libraries/Bluefruit52Lib/src/BLEClientCharacteristic.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
221221
};
222222

223223
_adamsg.prepare( (void*) data, len);
224-
VERIFY_STATUS ( sd_ble_gattc_write(_service->connHandle(), &param) );
224+
VERIFY_STATUS(sd_ble_gattc_write(_service->connHandle(), &param), 0);
225225

226226
// len is always 0 in BLE_GATTC_EVT_WRITE_RSP for BLE_GATT_OP_WRITE_REQ
227227
count = (_adamsg.waitUntilComplete(BLE_GENERIC_TIMEOUT) < 0 ? 0 : len);
@@ -230,7 +230,6 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
230230
{
231231
/*------------- Long Write Sequence -------------*/
232232
// For BLE_GATT_OP_PREP_WRITE_REQ, 2 bytes are used for offset
233-
234233
ble_gattc_write_params_t param =
235234
{
236235
.write_op = BLE_GATT_OP_PREP_WRITE_REQ,
@@ -242,7 +241,7 @@ uint16_t BLEClientCharacteristic::write_resp(const void* data, uint16_t len)
242241
};
243242

244243
_adamsg.prepare( (void*) data, len);
245-
VERIFY_STATUS ( sd_ble_gattc_write(_service->connHandle(), &param) );
244+
VERIFY_STATUS(sd_ble_gattc_write(_service->connHandle(), &param), 0);
246245
count = _adamsg.waitUntilComplete( (len/(max_payload-2) + 1) * BLE_GENERIC_TIMEOUT );
247246

248247
// delay to swallow last WRITE RESPONSE
@@ -284,7 +283,7 @@ uint16_t BLEClientCharacteristic::write(const void* data, uint16_t len)
284283
while( remaining )
285284
{
286285
// 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;
288287

289288
uint16_t packet_len = min16(max_payload, remaining);
290289

@@ -304,7 +303,7 @@ uint16_t BLEClientCharacteristic::write(const void* data, uint16_t len)
304303
u8data += packet_len;
305304
}
306305

307-
return len;
306+
return len-remaining;
308307
}
309308

310309
uint16_t BLEClientCharacteristic::write8(uint8_t value)

0 commit comments

Comments
 (0)