Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Diff: common/DiscoveredCharacteristic.cpp
- Revision:
- 512:0584e40bece2
- Parent:
- 504:817c6240e9d9
--- a/common/DiscoveredCharacteristic.cpp Fri Jun 19 15:52:04 2015 +0100
+++ b/common/DiscoveredCharacteristic.cpp Fri Jun 19 15:52:05 2015 +0100
@@ -17,7 +17,8 @@
#include "DiscoveredCharacteristic.h"
#include "GattClient.h"
-GattClient::ReadCallback_t DiscoveredCharacteristic::onDataReadCallback;
+GattClient::ReadCallback_t DiscoveredCharacteristic::onDataReadCallback;
+GattClient::WriteCallback_t DiscoveredCharacteristic::onDataWriteCallback;
ble_error_t
DiscoveredCharacteristic::read(uint16_t offset) const
@@ -34,6 +35,20 @@
}
ble_error_t
+DiscoveredCharacteristic::write(uint16_t length, const uint8_t *value) const
+{
+ if (!props.write()) {
+ return BLE_ERROR_OPERATION_NOT_PERMITTED;
+ }
+
+ if (!gattc) {
+ return BLE_ERROR_INVALID_STATE;
+ }
+
+ return gattc->write(GattClient::GATT_OP_WRITE_REQ, connHandle, valueHandle, length, value);
+}
+
+ble_error_t
DiscoveredCharacteristic::writeWoResponse(uint16_t length, const uint8_t *value) const
{
if (!props.writeWoResp()) {
@@ -44,5 +59,5 @@
return BLE_ERROR_INVALID_STATE;
}
- return gattc->write(GattClient::GATT_OP_WRITE_CMD, connHandle, length, value);
+ return gattc->write(GattClient::GATT_OP_WRITE_CMD, connHandle, valueHandle, length, value);
}
\ No newline at end of file
