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_Acceleration_Statejudging
Fork of nRF51822 by
Diff: source/nRF5xGap.cpp
- Revision:
- 524:502e53732c75
- Parent:
- 521:1db090c0e563
- Child:
- 528:7144407893f0
--- a/source/nRF5xGap.cpp Wed Dec 02 12:58:42 2015 +0000
+++ b/source/nRF5xGap.cpp Wed Dec 02 13:14:17 2015 +0000
@@ -374,30 +374,15 @@
/**************************************************************************/
ble_error_t nRF5xGap::setAddress(AddressType_t type, const Address_t address)
{
- uint8_t cycle_mode;
- ble_gap_addr_t dev_addr;
-
- /* When using Public or Static addresses, the cycle mode must be None.
- When using Random Private addresses, the cycle mode must be Auto.
- In auto mode, the given address is ignored.
- */
- if ((type == ADDR_TYPE_PUBLIC) || (type == ADDR_TYPE_RANDOM_STATIC))
- {
- cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_NONE;
- memcpy(dev_addr.addr, address, ADDR_LEN);
- }
- else if ((type == ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE) || (type == ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE))
- {
- cycle_mode = BLE_GAP_ADDR_CYCLE_MODE_AUTO;
- // address is ignored when in auto mode
- }
- else
- {
+ if (type > ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
+ ble_gap_addr_t dev_addr;
dev_addr.addr_type = type;
- ASSERT_INT(ERROR_NONE, sd_ble_gap_address_set(cycle_mode, &dev_addr), BLE_ERROR_PARAM_OUT_OF_RANGE);
+ 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;
}
