Skip to content

Commit d041131

Browse files
remove whitelist from example
1 parent e5c9080 commit d041131

File tree

1 file changed

+4
-67
lines changed

1 file changed

+4
-67
lines changed

BLE_Privacy/source/main.cpp

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
*
3333
* Two devices will be operating using random resolvable addresses. The
3434
* applications will connect to the peer and pair. It will attempt bonding
35-
* and if possible create a whitelist based on the bond. Subsequent connections
36-
* will turn on filtering if the whitelist has been successfully created.
35+
* to store the IRK that resolve the peer. Subsequent connections will
36+
* turn on filtering based on stored IRKs.
3737
*/
3838

3939
static const uint8_t DEVICE_NAME[] = "Privacy";
@@ -60,7 +60,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
6060
_event_queue(event_queue),
6161
_handle(0),
6262
_bonded(false),
63-
_whitelist_generated(false),
6463
_led1(LED1, 0) { };
6564

6665
virtual ~PrivacyDevice()
@@ -108,36 +107,14 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
108107

109108
/* event handler functions */
110109

111-
/** Inform the application of pairing. When succesful we will attempt
112-
* to create a whitelist based on the newly created bond */
110+
/** Inform the application of pairing */
113111
virtual void pairingResult(
114112
ble::connection_handle_t connectionHandle,
115113
SecurityManager::SecurityCompletionStatus_t result
116114
) {
117115
if (result == SecurityManager::SEC_STATUS_SUCCESS) {
118116
printf("Pairing successful\r\n");
119-
120-
if (!_bonded) {
121-
/* generate whitelist only the first time we bond */
122-
_bonded = true;
123-
124-
/* provide memory for the generated whitelist */
125-
Gap::Whitelist_t* whitelist = new Gap::Whitelist_t;
126-
whitelist->size = 0;
127-
/* we only need space for one address in our demonstration
128-
* but this can return all the bonded addresses */
129-
whitelist->capacity = 1;
130-
whitelist->addresses = new BLEProtocol::Address_t();
131-
132-
/* this will only fill the whitelist up to the provided capacity,
133-
* we hand over the memory ownership to the function */
134-
ble_error_t error = _ble.securityManager().generateWhitelistFromBondTable(whitelist);
135-
136-
if (error != BLE_ERROR_NONE) {
137-
delete whitelist->addresses;
138-
delete whitelist;
139-
}
140-
}
117+
_bonded = true;
141118
} else {
142119
printf("Pairing failed\r\n");
143120
}
@@ -149,28 +126,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
149126
);
150127
}
151128

152-
153-
virtual void whitelistFromBondTable(Gap::Whitelist_t* whitelist)
154-
{
155-
if (whitelist->size) {
156-
/* set the newly created whitelist at the link layer,
157-
* see BLUETOOTH SPECIFICATION Version 5.0 | Vol 6, Part B - 4.3 */
158-
ble_error_t error = _ble.gap().setWhitelist(*whitelist);
159-
if (error == BLE_ERROR_NONE) {
160-
printf("Whitelist generated.\r\n");
161-
_whitelist_generated = true;
162-
} else {
163-
printf("Whitelist generated but applying it failed.\r\n");
164-
}
165-
} else {
166-
printf("Whitelist failed to generate.\r\n");
167-
}
168-
169-
/* this callback transfer memory ownership to us so we have to dispose of it */
170-
delete whitelist->addresses;
171-
delete whitelist;
172-
}
173-
174129
/* callbacks */
175130

176131
/** This is called when BLE interface is initialised and starts the demonstration */
@@ -299,7 +254,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
299254
events::EventQueue &_event_queue;
300255
ble::connection_handle_t _handle;
301256
bool _bonded;
302-
bool _whitelist_generated;
303257

304258
private:
305259
DigitalOut _led1;
@@ -324,7 +278,6 @@ class PrivacyPeripheral : public PrivacyDevice {
324278
};
325279

326280
_ble.gap().setPeripheralPrivacyConfiguration(&privacy_configuration);
327-
_ble.gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST);
328281

329282
start_advertising();
330283
};
@@ -339,14 +292,6 @@ class PrivacyPeripheral : public PrivacyDevice {
339292

340293
_ble.gap().setPeripheralPrivacyConfiguration(&privacy_configuration);
341294

342-
/* enable filtering only if a whitelist has been created and set */
343-
if (_whitelist_generated) {
344-
_ble.gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_FILTER_ALL_REQS);
345-
} else {
346-
/* it's illegal to apply a whitelist if there are no entries present */
347-
_ble.gap().setAdvertisingPolicyMode(Gap::ADV_POLICY_IGNORE_WHITELIST);
348-
}
349-
350295
start_advertising();
351296
}
352297

@@ -426,7 +371,6 @@ class PrivacyCentral : public PrivacyDevice {
426371
};
427372

428373
_ble.gap().setCentralPrivacyConfiguration(&privacy_configuration);
429-
_ble.gap().setScanningPolicyMode(Gap::SCAN_POLICY_IGNORE_WHITELIST);
430374

431375
start_scanning();
432376
}
@@ -440,13 +384,6 @@ class PrivacyCentral : public PrivacyDevice {
440384

441385
_ble.gap().setCentralPrivacyConfiguration(&privacy_configuration);
442386

443-
/* enable filtering only if a whitelist has been created and set */
444-
if (_whitelist_generated) {
445-
_ble.gap().setScanningPolicyMode(Gap::SCAN_POLICY_FILTER_ALL_ADV);
446-
} else {
447-
/* it's illegal to apply a whitelist if there are no entries present */
448-
_ble.gap().setScanningPolicyMode(Gap::SCAN_POLICY_IGNORE_WHITELIST);
449-
}
450387

451388
start_scanning();
452389
}

0 commit comments

Comments
 (0)