1

Fork of nRF51822 by Nordic Semiconductor

Revision:
266:372234aa31e9
Parent:
265:04673a322cf9
Child:
267:b310cade274e
--- a/nRF51Gap.cpp	Fri Jun 19 15:55:24 2015 +0100
+++ b/nRF51Gap.cpp	Fri Jun 19 15:55:24 2015 +0100
@@ -227,9 +227,27 @@
         .conn_sup_timeout  = 400,
     };
 
-    printf("connect returns with %u\r\n", sd_ble_gap_connect(&addr, &scanParams, &connParams));
-
-    return BLE_ERROR_NONE;
+    uint32_t rc = sd_ble_gap_connect(&addr, &scanParams, &connParams);
+    if (rc == NRF_SUCCESS) {
+        return BLE_ERROR_NONE;
+    }
+    switch (rc) {
+        case NRF_ERROR_INVALID_ADDR:
+            return BLE_ERROR_INVALID_PARAM;
+        case NRF_ERROR_INVALID_PARAM:
+            return BLE_ERROR_INVALID_PARAM;
+        case NRF_ERROR_INVALID_STATE:
+            return BLE_ERROR_INVALID_STATE;
+        case BLE_ERROR_GAP_INVALID_BLE_ADDR:
+            return BLE_ERROR_INVALID_PARAM;
+        case NRF_ERROR_NO_MEM:
+            return BLE_ERROR_NO_MEM;
+        case NRF_ERROR_BUSY:
+            return BLE_STACK_BUSY;
+        default:
+        case BLE_ERROR_GAP_WHITELIST_IN_USE:
+            return BLE_ERROR_UNSPECIFIED;
+    }
 }