Skip to content

Commit ffcfffb

Browse files
committed
Jira794 Central writeInt API behaves differently when use on various Peripherals
1. Check the type and call the right functions 2. Changed files libraries/CurieBLE/src/internal/BLECallbacks.cpp - faked write response CB libraries/CurieBLE/src/internal/BLECallbacks.h libraries/CurieBLE/src/internal/BLECharacteristicImp.cpp - update the call
1 parent 7c97231 commit ffcfffb

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

libraries/CurieBLE/src/internal/BLECallbacks.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,8 @@ void ble_central_device_found(const bt_addr_le_t *addr,
223223
ad, len);
224224
}
225225

226+
void ble_on_write_no_rsp_complete(struct bt_conn *conn, uint8_t err,
227+
const void *data)
228+
{
229+
}
226230

libraries/CurieBLE/src/internal/BLECallbacks.h

+3
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,8 @@ uint8_t profile_service_read_rsp_process(bt_conn_t *conn,
7474
const void *data,
7575
uint16_t length);
7676

77+
void ble_on_write_no_rsp_complete(struct bt_conn *conn, uint8_t err,
78+
const void *data);
79+
7780
#endif
7881

libraries/CurieBLE/src/internal/BLECharacteristicImp.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,25 @@ bool BLECharacteristicImp::write(const unsigned char value[],
655655
return false;
656656
}
657657

658-
// Send read request
659-
retval = bt_gatt_write_without_response(conn,
660-
_value_handle,
661-
value,
662-
length,
663-
false);
658+
// Send write request
659+
if (_gatt_chrc.properties | BT_GATT_CHRC_WRITE_WITHOUT_RESP)
660+
{
661+
retval = bt_gatt_write_without_response(conn,
662+
_value_handle,
663+
value,
664+
length,
665+
false);
666+
}
667+
else if (_gatt_chrc.properties | BT_GATT_CHRC_WRITE)
668+
{
669+
retval = bt_gatt_write(conn,
670+
_value_handle,
671+
0,
672+
value,
673+
length,
674+
ble_on_write_no_rsp_complete);
675+
676+
}
664677
bt_conn_unref(conn);
665678
return (0 == retval);
666679
}

0 commit comments

Comments
 (0)