Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more
Diff: nRF51Gap.cpp
- Revision:
- 69:61da91a52bd6
- Parent:
- 56:a1071b629aa3
- Child:
- 70:d57285f18f65
--- 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;
}

