Skip to content

Commit 172673e

Browse files
committed
BLE: Add function to set the identity address used by the controller/platform.
The function to get it has been removed as this operation is driven by the security manager.
1 parent bfc4a02 commit 172673e

File tree

3 files changed

+30
-34
lines changed

3 files changed

+30
-34
lines changed

connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,6 @@ ble_error_t PalSecurityManager::set_private_address_timeout(
220220
return BLE_ERROR_NONE;
221221
}
222222

223-
/**
224-
* @see ::ble::PalSecurityManager::get_identity_address
225-
*/
226-
227-
ble_error_t PalSecurityManager::get_identity_address(
228-
address_t &address,
229-
bool &public_address
230-
)
231-
{
232-
// On cordio, the public address is hardcoded as the identity address.
233-
address = address_t(HciGetBdAddr());
234-
public_address = true;
235-
return BLE_ERROR_NONE;
236-
}
237-
238223
////////////////////////////////////////////////////////////////////////////
239224
// Keys
240225
//
@@ -288,6 +273,17 @@ ble_error_t PalSecurityManager::set_irk(const irk_t &irk)
288273
return BLE_ERROR_NONE;
289274
}
290275

276+
ble_error_t PalSecurityManager::set_identity_address(
277+
const address_t &address,
278+
bool public_address
279+
)
280+
{
281+
DmSecSetLocalIdentityAddr(
282+
address.data(),
283+
public_address ? DM_ADDR_PUBLIC : DM_ADDR_RANDOM
284+
);
285+
return BLE_ERROR_NONE;
286+
}
291287

292288
ble_error_t PalSecurityManager::set_csrk(
293289
const csrk_t &csrk,

connectivity/FEATURE_BLE/source/cordio/source/PalSecurityManagerImpl.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ class PalSecurityManager final : public ble::PalSecurityManager {
183183
*/
184184
ble_error_t set_private_address_timeout(uint16_t timeout_in_seconds) final;
185185

186-
/**
187-
* @see ::ble::PalSecurityManager::get_identity_address
188-
*/
189-
ble_error_t get_identity_address(address_t &address, bool &public_address) final;
190-
191186
////////////////////////////////////////////////////////////////////////////
192187
// Keys
193188
//
@@ -214,6 +209,13 @@ class PalSecurityManager final : public ble::PalSecurityManager {
214209
*/
215210
ble_error_t set_irk(const irk_t &irk) final;
216211

212+
/**
213+
* @see ::ble::PalSecurityManager::set_identity_address
214+
*/
215+
ble_error_t set_identity_address(
216+
const address_t &address, bool public_address
217+
) final;
218+
217219
/**
218220
* @see ::ble::PalSecurityManager::set_csrk
219221
*/

connectivity/FEATURE_BLE/source/pal/PalSecurityManager.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -761,20 +761,6 @@ class PalSecurityManager {
761761
uint16_t timeout_in_seconds
762762
) = 0;
763763

764-
/**
765-
* Retrieve the identity address used by the controller
766-
*
767-
* @param address Will contain the address retrieved.
768-
* @param public_address will be true if the address is public and false
769-
* otherwise.
770-
* @return BLE_ERROR_NONE On success, else an error code indicating the reason
771-
* of the failure
772-
*/
773-
virtual ble_error_t get_identity_address(
774-
address_t& address,
775-
bool& public_address
776-
) = 0;
777-
778764
////////////////////////////////////////////////////////////////////////////
779765
// Keys
780766
//
@@ -814,6 +800,18 @@ class PalSecurityManager {
814800
virtual ble_error_t set_irk(
815801
const irk_t &irk
816802
) = 0;
803+
804+
/**
805+
* Set the local identity address.
806+
*
807+
* @param[in] address identity address of the device
808+
* @param[in] public_address true if a public address is used and false otherwise.
809+
* @return BLE_ERROR_NONE On success, else an error code indicating reason for failure
810+
*/
811+
virtual ble_error_t set_identity_address(
812+
const address_t &address, bool public_address
813+
) = 0;
814+
817815
/**
818816
* Set the local CSRK.
819817
*

0 commit comments

Comments
 (0)