Remove redundant structures from nRF5xGap

Remove the following structures/arrays from the nRF5xGap class:

* ble_gap_whitelist_t whitelist
* ble_gap_addr_t *whitelistAddressePtrs[]
* ble_gap_irk_t  *whitelistIrkPtrs[]

These are made redundant because the SoftDevice does not require the user to
keep a copy of the whitelist itself.
This commit is contained in:
Andres Amaya Garcia 2016-01-08 15:19:18 +00:00
parent 12e6c9ec09
commit bdf392d471
2 changed files with 38 additions and 31 deletions

View file

@ -168,16 +168,22 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams &params)
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
/* Allocate the stack's whitelist statically */
ble_gap_whitelist_t whitelist;
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
/* Initialize the whitelist */
whitelist.pp_addrs = whitelistAddressPtrs;
whitelist.pp_irks = whitelistIrkPtrs;
whitelist.addr_count = 0;
whitelist.irk_count = 0;
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
if (advertisingPolicyMode != Gap::ADV_POLICY_IGNORE_WHITELIST) {
ble_error_t error = generateStackWhitelist();
ble_error_t error = generateStackWhitelist(whitelist);
if (error != BLE_ERROR_NONE) {
return error;
}
} else {
/* Reset the whitelist table to avoid any errors */
whitelist.addr_count = 0;
whitelist.irk_count = 0;
}
/* Start Advertising */
@ -199,18 +205,24 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams &params)
/* Observer role is not supported by S110, return BLE_ERROR_NOT_IMPLEMENTED */
#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110)
ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams) {
ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams)
{
/* Allocate the stack's whitelist statically */
ble_gap_whitelist_t whitelist;
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
/* Initialize the whitelist */
whitelist.pp_addrs = whitelistAddressPtrs;
whitelist.pp_irks = whitelistIrkPtrs;
whitelist.addr_count = 0;
whitelist.irk_count = 0;
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
if (scanningPolicyMode != Gap::SCAN_POLICY_IGNORE_WHITELIST) {
ble_error_t error = generateStackWhitelist();
ble_error_t error = generateStackWhitelist(whitelist);
if (error != BLE_ERROR_NONE) {
return error;
}
} else {
/* Reset the whitelist table to avoid any errors */
whitelist.addr_count = 0;
whitelist.irk_count = 0;
}
ble_gap_scan_params_t scanParams = {
@ -286,16 +298,22 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
connParams.conn_sup_timeout = 600;
}
/* Allocate the stack's whitelist statically */
ble_gap_whitelist_t whitelist;
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
/* Initialize the whitelist */
whitelist.pp_addrs = whitelistAddressPtrs;
whitelist.pp_irks = whitelistIrkPtrs;
whitelist.addr_count = 0;
whitelist.irk_count = 0;
/* Add missing IRKs to whitelist from the bond table held by the SoftDevice */
if (scanningPolicyMode != Gap::SCAN_POLICY_IGNORE_WHITELIST) {
ble_error_t error = generateStackWhitelist();
ble_error_t error = generateStackWhitelist(whitelist);
if (error != BLE_ERROR_NONE) {
return error;
}
} else {
/* Reset the whitelist table to avoid any errors */
whitelist.addr_count = 0;
whitelist.irk_count = 0;
}
ble_gap_scan_params_t scanParams;
@ -839,7 +857,7 @@ Gap::InitiatorPolicyMode_t nRF5xGap::getInitiatorPolicyMode(void) const
@endcode
*/
/**************************************************************************/
ble_error_t nRF5xGap::generateStackWhitelist(void)
ble_error_t nRF5xGap::generateStackWhitelist(ble_gap_whitelist_t &whitelist)
{
ble_gap_whitelist_t whitelistFromBondTable;
ble_gap_addr_t *addressPtr[1];

View file

@ -133,11 +133,6 @@ private:
/* Internal representation of a whitelist */
uint8_t whitelistAddressesSize;
ble_gap_addr_t whitelistAddresses[YOTTA_CFG_WHITELIST_MAX_SIZE];
ble_gap_addr_t *whitelistAddressPtrs[YOTTA_CFG_WHITELIST_MAX_SIZE];
ble_gap_irk_t *whitelistIrkPtrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
/* Structure used by the SoftDevice to represent a whitelist together with IRK table */
ble_gap_whitelist_t whitelist;
/*
* An internal function used to populate the ble_gap_whitelist_t that will be used by
@ -145,7 +140,7 @@ private:
* API the whitelist is just a collection of keys, but for the stack it also includes
* the IRK table.
*/
ble_error_t generateStackWhitelist(void);
ble_error_t generateStackWhitelist(ble_gap_whitelist_t &whitelist);
private:
bool radioNotificationCallbackParam; /* parameter to be passed into the Timeout-generated radio notification callback. */
@ -239,15 +234,9 @@ private:
nRF5xGap() :
advertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST),
scanningPolicyMode(Gap::SCAN_POLICY_IGNORE_WHITELIST) {
scanningPolicyMode(Gap::SCAN_POLICY_IGNORE_WHITELIST),
whitelistAddressesSize(0) {
m_connectionHandle = BLE_CONN_HANDLE_INVALID;
/* Reset the whitelist */
whitelist.addr_count = 0;
whitelist.irk_count = 0;
whitelist.pp_irks = whitelistIrkPtrs;
whitelist.pp_addrs = whitelistAddressPtrs;
whitelistAddressesSize = 0;
}
nRF5xGap(nRF5xGap const &);