mirror of https://github.com/ARMmbed/mbed-os.git
BLE: retrieve and fill resolving list at GenericSecurityManager startup.
parent
ede3d43743
commit
951a6be4c8
|
|
@ -25,6 +25,7 @@
|
|||
#include "ble/pal/SigningEventMonitor.h"
|
||||
#include "ble/generic/GenericGap.h"
|
||||
#include "ble/pal/PalSecurityManager.h"
|
||||
#include "ble/ArrayView.h"
|
||||
|
||||
namespace ble {
|
||||
namespace generic {
|
||||
|
|
@ -402,13 +403,24 @@ private:
|
|||
/**
|
||||
* Callback invoked by the secure DB when an identity entry has been
|
||||
* retrieved.
|
||||
* @param identity
|
||||
* @param entry Handle of the entry.
|
||||
* @param identity The identity associated with the entry; may be NULL.
|
||||
*/
|
||||
void on_security_entry_retrieved(
|
||||
pal::SecurityDb::entry_handle_t entry,
|
||||
const pal::SecurityEntryIdentity_t* identity
|
||||
);
|
||||
|
||||
/**
|
||||
* Callback invoked by the secure DB when the identity list has been
|
||||
* retrieved.
|
||||
* @param identity
|
||||
*/
|
||||
void on_identity_list_retrieved(
|
||||
ble::ArrayView<pal::SecurityEntryIdentity_t*>&,
|
||||
size_t count
|
||||
);
|
||||
|
||||
private:
|
||||
struct ControlBlock_t : public pal::SecurityDistributionFlags_t {
|
||||
ControlBlock_t();
|
||||
|
|
|
|||
|
|
@ -74,6 +74,22 @@ ble_error_t GenericSecurityManager::init(
|
|||
_signing_monitor.set_signing_event_handler(this);
|
||||
_pal.set_event_handler(this);
|
||||
|
||||
uint8_t resolving_list_capacity = _pal.read_resolving_list_capacity();
|
||||
pal::SecurityEntryIdentity_t** identity_list_p =
|
||||
new (std::nothrow) pal::SecurityEntryIdentity_t*[resolving_list_capacity];
|
||||
|
||||
if (identity_list_p) {
|
||||
ArrayView<pal::SecurityEntryIdentity_t*> identity_list(
|
||||
identity_list_p,
|
||||
resolving_list_capacity
|
||||
);
|
||||
|
||||
_db.get_identity_list(
|
||||
mbed::callback(this, &GenericSecurityManager::on_identity_list_retrieved),
|
||||
identity_list
|
||||
);
|
||||
}
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
@ -883,6 +899,26 @@ void GenericSecurityManager::on_security_entry_retrieved(
|
|||
);
|
||||
}
|
||||
|
||||
void GenericSecurityManager::on_identity_list_retrieved(
|
||||
ble::ArrayView<pal::SecurityEntryIdentity_t*>& identity_list,
|
||||
size_t count
|
||||
) {
|
||||
typedef advertising_peer_address_type_t address_type_t;
|
||||
|
||||
_pal.clear_resolving_list();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
_pal.add_device_to_resolving_list(
|
||||
identity_list[i]->identity_address_is_public ?
|
||||
address_type_t::PUBLIC_ADDRESS :
|
||||
address_type_t::RANDOM_ADDRESS,
|
||||
identity_list[i]->identity_address,
|
||||
identity_list[i]->irk
|
||||
);
|
||||
}
|
||||
|
||||
delete [] identity_list.data();
|
||||
}
|
||||
|
||||
|
||||
/* Implements ble::pal::SecurityManagerEventHandler */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue