Skip to content

Commit 4767b7e

Browse files
fix missing observer ifdefs
1 parent 910b7a6 commit 4767b7e

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

connectivity/FEATURE_BLE/source/generic/GapImpl.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,6 @@ ble_error_t Gap::reset()
12181218

12191219
_event_handler = nullptr;
12201220
_initiating = false;
1221-
set_scan_state(ScanState::idle);
1222-
_scan_requested = false;
12231221

12241222
#if BLE_FEATURE_PRIVACY
12251223
_privacy_initialization_pending = false;
@@ -1231,6 +1229,8 @@ ble_error_t Gap::reset()
12311229
#endif // BLE_FEATURE_PRIVACY
12321230

12331231
#if BLE_ROLE_OBSERVER
1232+
set_scan_state(ScanState::idle);
1233+
_scan_requested = false;
12341234
_scan_parameters_set = false;
12351235
_scan_timeout.detach();
12361236
#endif
@@ -2415,12 +2415,14 @@ ble_error_t Gap::startAdvertising(
24152415
return BLE_ERROR_INVALID_PARAM;
24162416
}
24172417

2418+
#if BLE_ROLE_OBSERVER
24182419
// Address can be updated if the device is not scanning or advertising
24192420
if ((_scan_state == ScanState::idle) && !_active_sets.get(LEGACY_ADVERTISING_HANDLE)) {
24202421
_pal_gap.set_random_address(*random_address);
24212422
} else {
24222423
tr_error("could not update address, device scanning/advertising");
24232424
}
2425+
#endif // BLE_ROLE_OBSERVER
24242426

24252427
error = _pal_gap.advertising_enable(true);
24262428
if (error) {
@@ -3433,7 +3435,11 @@ void Gap::on_legacy_advertising_stopped()
34333435
_pending_sets.clear(LEGACY_ADVERTISING_HANDLE);
34343436

34353437
// restart advertising if it was stopped to refresh the address
3436-
if (_address_refresh_sets.get(LEGACY_ADVERTISING_HANDLE) && (_scan_state == ScanState::idle)) {
3438+
if (_address_refresh_sets.get(LEGACY_ADVERTISING_HANDLE)
3439+
#if BLE_ROLE_OBSERVER
3440+
&& (_scan_state == ScanState::idle)
3441+
#endif //BLE_ROLE_OBSERVER
3442+
) {
34373443
_address_refresh_sets.clear(LEGACY_ADVERTISING_HANDLE);
34383444
startAdvertising(LEGACY_ADVERTISING_HANDLE);
34393445
_adv_started_from_refresh.set(LEGACY_ADVERTISING_HANDLE);
@@ -4238,7 +4244,11 @@ bool Gap::is_advertising() const
42384244
}
42394245

42404246
bool Gap::is_radio_active() const {
4241-
return _initiating || (_scan_state != ScanState::idle) || is_advertising();
4247+
return _initiating ||
4248+
#if BLE_ROLE_OBSERVER
4249+
(_scan_state != ScanState::idle) ||
4250+
#endif // BLE_ROLE_OBSERVER
4251+
is_advertising();
42424252
}
42434253

42444254
void Gap::update_advertising_set_connectable_attribute(
@@ -4303,12 +4313,14 @@ const address_t *Gap::get_random_address(controller_operation_t operation, size_
43034313
// it to the address to use to determine if the address is correct or not.
43044314
if (_initiating) {
43054315
address_in_use = &resolvable_address;
4316+
#if BLE_ROLE_OBSERVER
43064317
} else if (_scan_state != ScanState::idle) {
43074318
if (central_non_resolvable) {
43084319
address_in_use = &non_resolvable_address;
43094320
} else {
43104321
address_in_use = &resolvable_address;
43114322
}
4323+
#endif //BLE_ROLE_OBSERVER
43124324
} else if (advertising_use_main_address && (_active_sets.get(set_id) || _pending_sets.get(set_id))) {
43134325
if (!_set_is_connectable.get(set_id) && peripheral_non_resolvable) {
43144326
address_in_use = &non_resolvable_address;

connectivity/FEATURE_BLE/source/generic/GapImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ class Gap :
909909
#endif // BLE_FEATURE_PRIVACY
910910
ble::address_t _random_static_identity_address;
911911

912+
#if BLE_ROLE_OBSERVER
912913
enum class ScanState : uint8_t {
913914
idle,
914915
scan,
@@ -925,6 +926,7 @@ class Gap :
925926
scan_period_t _scan_requested_period = scan_period_t(0);
926927

927928
bool _scan_requested = false;
929+
#endif // BLE_ROLE_OBSERVER
928930

929931
#if BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
930932
enum class ConnectionToHostResolvedAddressState : uint8_t {

0 commit comments

Comments
 (0)