test

Dependencies:   nrf51-sdk

Dependents:   microbit-dal

Fork of nRF51822 by Lancaster University

Revision:
312:d55797e0d632
Parent:
311:5d5abc30e3a8
Child:
315:044071756a8d
diff -r 5d5abc30e3a8 -r d55797e0d632 btle/btle_discovery.h
--- a/btle/btle_discovery.h	Fri Jun 19 15:55:30 2015 +0100
+++ b/btle/btle_discovery.h	Fri Jun 19 15:55:30 2015 +0100
@@ -58,9 +58,19 @@
      *         BLE_STACK_BUSY if some client procedure already in progress.
      */
     virtual ble_error_t read(uint16_t offset = 0) {
-        // sd_ble_gattc_read()
-        // SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
-        return BLE_ERROR_NONE;
+        uint32_t rc = sd_ble_gattc_read(connHandle, valueHandle, offset);
+        if (rc == NRF_SUCCESS) {
+            return BLE_ERROR_NONE;
+        }
+        switch (rc) {
+            case NRF_ERROR_BUSY:
+                return BLE_STACK_BUSY;
+            case BLE_ERROR_INVALID_CONN_HANDLE:
+            case NRF_ERROR_INVALID_STATE:
+            case NRF_ERROR_INVALID_ADDR:
+            default:
+                return BLE_ERROR_INVALID_STATE;
+        }
     }
 };