Martin Hudik / X_NUCLEO_IDB0XA1

Fork of X_NUCLEO_IDB0XA1 by ST

Files at this revision

API Documentation at this revision

Comitter:
Andrea Palmieri
Date:
Mon Dec 07 15:47:02 2015 +0100
Parent:
203:5b9c78101d45
Parent:
204:6a6d2f041905
Child:
209:d7cb3b3d0295
Commit message:
Merge branch 'master' of https://github.com/ARMmbed/ble-x-nucleo-idb0xa1 into mbed_classic

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 11:37:55 2015 +0100
+++ b/source/BlueNRGGattServer.cpp	Mon Dec 07 15:47:02 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 11:37:55 2015 +0100
+++ b/x-nucleo-idb0xa1/BlueNRGGattServer.h	Mon Dec 07 15:47:02 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);