Nordic stack and drivers for the mbed BLE API

Dependents:   idd_hw5_bleFanProto

Fork of nRF51822 by Nordic Semiconductor

Revision:
69:61da91a52bd6
Parent:
56:a1071b629aa3
--- a/nRF51Gap.cpp	Fri Sep 26 14:46:19 2014 +0100
+++ b/nRF51Gap.cpp	Tue Nov 04 10:42:27 2014 +0000
@@ -304,7 +304,7 @@
     @endcode
 */
 /**************************************************************************/
-ble_error_t nRF51Gap::setAddress(addr_type_t type, const uint8_t address[6])
+ble_error_t nRF51Gap::setAddress(addr_type_t type, const uint8_t address[ADDR_LEN])
 {
     if (type > ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) {
         return BLE_ERROR_PARAM_OUT_OF_RANGE;
@@ -312,13 +312,26 @@
 
     ble_gap_addr_t dev_addr;
     dev_addr.addr_type = type;
-    memcpy(dev_addr.addr, address, 6);
+    memcpy(dev_addr.addr, address, ADDR_LEN);
+
+    ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
+
+    return BLE_ERROR_NONE;
+}
 
-    ASSERT_INT(ERROR_NONE,
-               sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &dev_addr),
-               BLE_ERROR_PARAM_OUT_OF_RANGE);
+ble_error_t nRF51Gap::getAddress(addr_type_t *typeP, uint8_t addressP[ADDR_LEN])
+{
+    ble_gap_addr_t dev_addr;
+    if (sd_ble_gap_address_get(&dev_addr) != NRF_SUCCESS) {
+        return BLE_ERROR_PARAM_OUT_OF_RANGE;
+    }
 
-
+    if (typeP != NULL) {
+        *typeP = static_cast<addr_type_t>(dev_addr.addr_type);
+    }
+    if (addressP != NULL) {
+        memcpy(addressP, dev_addr.addr, ADDR_LEN);
+    }
     return BLE_ERROR_NONE;
 }