From 1e6c5beed3d84a00ed1425da92baea13833d2bf5 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 3 Apr 2019 12:21:01 -0500 Subject: [PATCH 1/2] feat: Expose length of data buffer Added public member variable getLength to expose the length of the underlying data buffer. This allows for better error checking when reading the raw buffer. --- src/BLECharacteristic.cpp | 8 ++++++++ src/BLECharacteristic.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/BLECharacteristic.cpp b/src/BLECharacteristic.cpp index e340287..8184eca 100644 --- a/src/BLECharacteristic.cpp +++ b/src/BLECharacteristic.cpp @@ -192,6 +192,14 @@ uint8_t* BLECharacteristic::getData() { return m_value.getData(); } // getData +/** + * @brief Retrieve the current length of the raw data of the characteristic. + * @return The length of the current characteristic data in bytes. + */ +uint8_t* BLECharacteristic::getLength() { + return m_value.getLength(); +} // getLength + /** * Handle a GATT server event. diff --git a/src/BLECharacteristic.h b/src/BLECharacteristic.h index 5eb1e8d..f22db65 100644 --- a/src/BLECharacteristic.h +++ b/src/BLECharacteristic.h @@ -62,6 +62,7 @@ class BLECharacteristic { BLEUUID getUUID(); std::string getValue(); uint8_t* getData(); + size_t getLength(); void indicate(); void notify(bool is_notification = true); From 70cf6a5417d04cbd62cd42178a94b9e8c296d02d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 3 Apr 2019 12:22:36 -0500 Subject: [PATCH 2/2] chore: Correct spacing --- src/BLECharacteristic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BLECharacteristic.h b/src/BLECharacteristic.h index f22db65..2328aea 100644 --- a/src/BLECharacteristic.h +++ b/src/BLECharacteristic.h @@ -62,7 +62,7 @@ class BLECharacteristic { BLEUUID getUUID(); std::string getValue(); uint8_t* getData(); - size_t getLength(); + size_t getLength(); void indicate(); void notify(bool is_notification = true);