@@ -314,7 +314,9 @@ static bool is_whitelist_valid(const Gap::Whitelist_t& whitelist)
314
314
315
315
for (size_t i = 0 ; i < whitelist.size ; ++i) {
316
316
const BLEProtocol::Address_t& address = whitelist.addresses [i];
317
- if (address.type > BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE) {
317
+ if (address.type != BLEProtocol::AddressType::PUBLIC &&
318
+ address.type != BLEProtocol::AddressType::RANDOM
319
+ ) {
318
320
return false ;
319
321
}
320
322
@@ -354,8 +356,8 @@ static pal::whitelist_address_type_t to_device_address_type(
354
356
BLEProtocol::AddressType_t address_type
355
357
) {
356
358
return (address_type == BLEProtocol::AddressType::PUBLIC) ?
357
- pal::whitelist_address_type_t ::PUBLIC_DEVICE_ADDRESS :
358
- pal::whitelist_address_type_t ::RANDOM_DEVICE_ADDRESS;
359
+ pal::whitelist_address_type_t ::PUBLIC_DEVICE_ADDRESS :
360
+ pal::whitelist_address_type_t ::RANDOM_DEVICE_ADDRESS;
359
361
}
360
362
361
363
/*
@@ -411,6 +413,7 @@ ble_error_t GenericGap::setAddress(
411
413
_address_type = type;
412
414
return BLE_ERROR_NONE;
413
415
416
+ case BLEProtocol::AddressType::RANDOM:
414
417
case BLEProtocol::AddressType::RANDOM_STATIC: {
415
418
if (is_random_static_address (address) == false ) {
416
419
return BLE_ERROR_INVALID_PARAM;
@@ -423,22 +426,13 @@ ble_error_t GenericGap::setAddress(
423
426
return err;
424
427
}
425
428
426
- _address_type = type ;
429
+ _address_type = BLEProtocol::AddressType::RANDOM ;
427
430
_address = ble::address_t (address);
428
431
return BLE_ERROR_NONE;
429
432
}
430
433
431
- case BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE:
432
- // TODO: Fix with the privacy/security rework
433
- return BLE_ERROR_NOT_IMPLEMENTED;
434
-
435
- case BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE:
436
- // TODO: add process to set the random private non resolvable
437
- // address (privacy/security work)
438
- return BLE_ERROR_NOT_IMPLEMENTED;
439
-
440
434
default :
441
- return BLE_ERROR_PARAM_OUT_OF_RANGE ;
435
+ return BLE_ERROR_INVALID_PARAM ;
442
436
}
443
437
}
444
438
@@ -448,10 +442,18 @@ ble_error_t GenericGap::getAddress(
448
442
) {
449
443
*type = _address_type;
450
444
ble::address_t address_value;
451
- if (_address_type == BLEProtocol::AddressType::PUBLIC) {
452
- address_value = _pal_gap.get_device_address ();
453
- } else {
454
- address_value = _pal_gap.get_random_address ();
445
+
446
+ switch (_address_type) {
447
+ case BLEProtocol::AddressType::PUBLIC:
448
+ address_value = _pal_gap.get_device_address ();
449
+ break ;
450
+
451
+ case BLEProtocol::AddressType::RANDOM:
452
+ address_value = _pal_gap.get_random_address ();
453
+ break ;
454
+
455
+ default :
456
+ return BLE_ERROR_INVALID_PARAM;
455
457
}
456
458
457
459
memcpy (address, address_value.data (), address_value.size ());
@@ -528,7 +530,7 @@ ble_error_t GenericGap::connect(
528
530
_initiator_policy_mode,
529
531
(pal::connection_peer_address_type_t ::type) peerAddrType,
530
532
ble::address_t (peerAddr),
531
- (pal:: own_address_type_t ::type) _address_type ,
533
+ get_own_address_type () ,
532
534
connectionParams->minConnectionInterval ,
533
535
connectionParams->maxConnectionInterval ,
534
536
connectionParams->slaveLatency ,
@@ -1135,14 +1137,9 @@ pal::own_address_type_t GenericGap::get_own_address_type()
1135
1137
switch (_address_type) {
1136
1138
case BLEProtocol::AddressType::PUBLIC:
1137
1139
return pal::own_address_type_t ::PUBLIC_ADDRESS;
1138
- case BLEProtocol::AddressType::RANDOM_STATIC:
1139
- case BLEProtocol::AddressType::RANDOM_PRIVATE_NON_RESOLVABLE:
1140
- return pal::own_address_type_t ::RANDOM_ADDRESS;
1141
- case BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE:
1142
- return pal::own_address_type_t ::RESOLVABLE_PRIVATE_ADDRESS_PUBLIC_FALLBACK;
1143
1140
default :
1144
- // not reachable
1145
- return pal:: own_address_type_t ::PUBLIC_ADDRESS;
1141
+ return pal:: own_address_type_t ::RANDOM_ADDRESS;
1142
+ // FIXME: Handle case when privacy is used.
1146
1143
}
1147
1144
}
1148
1145
0 commit comments