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.
Dependencies: BLE_API nRF51822
Fork of Puck by
Diff: Puck.h
- Revision:
- 8:49ffd38fb401
- Parent:
- 7:c07c01c2a741
- Child:
- 10:67e4694f2d74
--- a/Puck.h Thu Jul 24 09:25:42 2014 +0000
+++ b/Puck.h Thu Jul 24 14:27:55 2014 +0000
@@ -52,6 +52,7 @@
void onDataWritten(uint16_t handle);
void addCharacteristic(const UUID serviceUuid, const UUID characteristicUuid, int bytes, int properties = 0xA);
void onCharacteristicWrite(const UUID uuid, CharacteristicWriteCallback callback);
+ void updateCharacteristicValue(const UUID uuid, uint8_t* value, int length);
uint8_t* getCharacteristicValue(const UUID uuid);
};
@@ -210,6 +211,23 @@
services.push_back(service);
}
+
+void Puck::updateCharacteristicValue(const UUID uuid, uint8_t* value, int length) {
+ GattCharacteristic* characteristic = NULL;
+ for( int i = 0; i < characteristics.size(); i++) {
+ if(isEqualUUID(&characteristics[i]->getUUID(), uuid)) {
+ characteristic = characteristics[i];
+ break;
+ }
+ }
+ if(characteristic != NULL) {
+ ble.updateCharacteristicValue(characteristic->getHandle(), value, length);
+ LOG_VERBOSE("Updated characteristic value.\n");
+ } else {
+ LOG_WARN("Tried to update an unkown characteristic!\n");
+ }
+}
+
bool Puck::drive() {
ble.waitForEvent();
if(state == DISCONNECTED) {
