32
32
*
33
33
* Two devices will be operating using random resolvable addresses. The
34
34
* 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 .
37
37
*/
38
38
39
39
static const uint8_t DEVICE_NAME[] = " Privacy" ;
@@ -60,7 +60,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
60
60
_event_queue (event_queue),
61
61
_handle (0 ),
62
62
_bonded (false ),
63
- _whitelist_generated (false ),
64
63
_led1 (LED1, 0 ) { };
65
64
66
65
virtual ~PrivacyDevice ()
@@ -108,36 +107,14 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
108
107
109
108
/* event handler functions */
110
109
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 */
113
111
virtual void pairingResult (
114
112
ble::connection_handle_t connectionHandle,
115
113
SecurityManager::SecurityCompletionStatus_t result
116
114
) {
117
115
if (result == SecurityManager::SEC_STATUS_SUCCESS) {
118
116
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 ;
141
118
} else {
142
119
printf (" Pairing failed\r\n " );
143
120
}
@@ -149,28 +126,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
149
126
);
150
127
}
151
128
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
-
174
129
/* callbacks */
175
130
176
131
/* * This is called when BLE interface is initialised and starts the demonstration */
@@ -299,7 +254,6 @@ class PrivacyDevice : private mbed::NonCopyable<PrivacyDevice>,
299
254
events::EventQueue &_event_queue;
300
255
ble::connection_handle_t _handle;
301
256
bool _bonded;
302
- bool _whitelist_generated;
303
257
304
258
private:
305
259
DigitalOut _led1;
@@ -324,7 +278,6 @@ class PrivacyPeripheral : public PrivacyDevice {
324
278
};
325
279
326
280
_ble.gap ().setPeripheralPrivacyConfiguration (&privacy_configuration);
327
- _ble.gap ().setAdvertisingPolicyMode (Gap::ADV_POLICY_IGNORE_WHITELIST);
328
281
329
282
start_advertising ();
330
283
};
@@ -339,14 +292,6 @@ class PrivacyPeripheral : public PrivacyDevice {
339
292
340
293
_ble.gap ().setPeripheralPrivacyConfiguration (&privacy_configuration);
341
294
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
-
350
295
start_advertising ();
351
296
}
352
297
@@ -426,7 +371,6 @@ class PrivacyCentral : public PrivacyDevice {
426
371
};
427
372
428
373
_ble.gap ().setCentralPrivacyConfiguration (&privacy_configuration);
429
- _ble.gap ().setScanningPolicyMode (Gap::SCAN_POLICY_IGNORE_WHITELIST);
430
374
431
375
start_scanning ();
432
376
}
@@ -440,13 +384,6 @@ class PrivacyCentral : public PrivacyDevice {
440
384
441
385
_ble.gap ().setCentralPrivacyConfiguration (&privacy_configuration);
442
386
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
- }
450
387
451
388
start_scanning ();
452
389
}
0 commit comments