Skip to content

Commit 1fdb57e

Browse files
author
Donatien Garnier
committed
Removed set_privacy() API and added is_privacy_supported() check to PAL + Generic GAP
1 parent 288c395 commit 1fdb57e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

features/FEATURE_BLE/ble/pal/PalGap.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,13 @@ struct Gap {
649649
disconnection_reason_t disconnection_reason
650650
) = 0;
651651

652-
/** Enable or disable privacy feature
653-
* @param enable whether to enable privacy feature
652+
/** Check if privacy feature is supported by implementation
654653
*
655-
* @return BLE_ERROR_NONE if the request has been successfully sent or the
656-
* appropriate error otherwise.
654+
* @return true if privacy is supported, false otherwise.
657655
*
658656
* @note: See Bluetooth 5 Vol 3 Part C: 10.7 Privacy feature.
659657
*/
660-
virtual ble_error_t set_privacy(
661-
bool enable
662-
) = 0;
658+
virtual bool is_privacy_supported() = 0;
663659

664660
/** Enable or disable private addresses resolution
665661
*

features/FEATURE_BLE/source/generic/GenericGap.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,18 @@ ble_error_t GenericGap::initRadioNotification(void)
881881

882882
ble_error_t GenericGap::enablePrivacy(bool enable)
883883
{
884-
_privacy_enabled = enable;
884+
if(enable == _privacy_enabled) {
885+
// No change
886+
return BLE_ERROR_NONE;
887+
}
888+
889+
if(enable && !_pal_gap.is_privacy_supported())
890+
{
891+
// Privacy is not supported by the implementation
892+
return BLE_ERROR_NOT_IMPLEMENTED;
893+
}
885894

886-
_pal_gap.set_privacy(enable);
895+
_privacy_enabled = enable;
887896

888897
update_address_resolution_setting();
889898

features/FEATURE_BLE/targets/TARGET_CORDIO/CordioPalGap.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,9 @@ class Gap : public ::ble::pal::Gap {
308308
return BLE_ERROR_NONE;
309309
}
310310

311-
virtual ble_error_t set_privacy(
312-
bool enable
313-
) {
314-
//
315-
316-
317-
return BLE_ERROR_NONE;
311+
virtual bool is_privacy_supported() {
312+
// We only support controller-based privacy, so return whether the controller supports it
313+
return HciLlPrivacySupported();
318314
}
319315

320316
virtual ble_error_t set_address_resolution(
@@ -481,7 +477,6 @@ class Gap : public ::ble::pal::Gap {
481477
};
482478

483479
private:
484-
address_t device_random_static_identity_address;
485480
address_t device_random_address;
486481
bool use_active_scanning;
487482
};

0 commit comments

Comments
 (0)