Andrea Sortino / X_NUCLEO_IDB0XA1

Dependents:   BLE_GENERALE

Fork of X_NUCLEO_IDB0XA1 by ST

Files at this revision

API Documentation at this revision

Comitter:
Andrea Palmieri
Date:
Mon Dec 07 15:44:42 2015 +0100
Parent:
202:caf4864292c1
Child:
205:2b4afe8ce1a0
Child:
206:7f9c3057adf0
Commit message:
Enable read of a characteristic value from the local GATT server

Signed-off-by: Andrea Palmieri <andrea.palmieri@st.com>

Changed in this revision

source/BlueNRGGattServer.cpp Show annotated file Show diff for this revision Revisions of this file
x-nucleo-idb0xa1/BlueNRGGattServer.h Show annotated file Show diff for this revision Revisions of this file
--- a/source/BlueNRGGattServer.cpp	Thu Dec 03 10:25:12 2015 +0100
+++ b/source/BlueNRGGattServer.cpp	Mon Dec 07 15:44:42 2015 +0100
@@ -254,16 +254,21 @@
     @endcode
 */
 /**************************************************************************/
-ble_error_t BlueNRGGattServer::readValue(uint16_t charHandle, uint8_t buffer[], uint16_t *const lengthP)
+ble_error_t BlueNRGGattServer::read(GattAttribute::Handle_t charHandle, uint8_t buffer[], uint16_t *lengthP)
 {
-  PRINTF("ReadValue() Not Supported\n\r");
+  tBleStatus ret;
+
+  ret = aci_gatt_read_handle_value(charHandle+CHAR_VALUE_OFFSET, *lengthP, lengthP, buffer);
 
-  /* avoid compiler warnings about unused variables */
-  (void)charHandle;
-  (void)buffer;
-  (void)lengthP;
-
-  return BLE_ERROR_NONE;
+  if(ret == BLE_STATUS_SUCCESS) {
+    return BLE_ERROR_NONE;
+  }
+  switch (ret) {
+  case ERR_INVALID_HCI_CMD_PARAMS:
+    return BLE_ERROR_INVALID_PARAM;
+  default:
+    return BLE_ERROR_UNSPECIFIED;
+  }
 }
 
 /**************************************************************************/
@@ -292,7 +297,7 @@
 */
 /**************************************************************************/
 // <<<ANDREA>>>
-ble_error_t BlueNRGGattServer::readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) {
+ble_error_t BlueNRGGattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) {
 
   /* avoid compiler warnings about unused variables */
   (void)connectionHandle;
--- a/x-nucleo-idb0xa1/BlueNRGGattServer.h	Thu Dec 03 10:25:12 2015 +0100
+++ b/x-nucleo-idb0xa1/BlueNRGGattServer.h	Mon Dec 07 15:44:42 2015 +0100
@@ -70,8 +70,8 @@
     /* Functions that must be implemented from GattServer */
     // <<<ANDREA>>>
     virtual ble_error_t addService(GattService &);
-    virtual ble_error_t readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
-    virtual ble_error_t readValue(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
+    virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
+    virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
     virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
     virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
     virtual ble_error_t initializeGATTDatabase(void);