@@ -1218,8 +1218,6 @@ ble_error_t Gap::reset()
1218
1218
1219
1219
_event_handler = nullptr ;
1220
1220
_initiating = false ;
1221
- set_scan_state (ScanState::idle);
1222
- _scan_requested = false ;
1223
1221
1224
1222
#if BLE_FEATURE_PRIVACY
1225
1223
_privacy_initialization_pending = false ;
@@ -1231,6 +1229,8 @@ ble_error_t Gap::reset()
1231
1229
#endif // BLE_FEATURE_PRIVACY
1232
1230
1233
1231
#if BLE_ROLE_OBSERVER
1232
+ set_scan_state (ScanState::idle);
1233
+ _scan_requested = false ;
1234
1234
_scan_parameters_set = false ;
1235
1235
_scan_timeout.detach ();
1236
1236
#endif
@@ -2415,12 +2415,14 @@ ble_error_t Gap::startAdvertising(
2415
2415
return BLE_ERROR_INVALID_PARAM;
2416
2416
}
2417
2417
2418
+ #if BLE_ROLE_OBSERVER
2418
2419
// Address can be updated if the device is not scanning or advertising
2419
2420
if ((_scan_state == ScanState::idle) && !_active_sets.get (LEGACY_ADVERTISING_HANDLE)) {
2420
2421
_pal_gap.set_random_address (*random_address);
2421
2422
} else {
2422
2423
tr_error (" could not update address, device scanning/advertising" );
2423
2424
}
2425
+ #endif // BLE_ROLE_OBSERVER
2424
2426
2425
2427
error = _pal_gap.advertising_enable (true );
2426
2428
if (error) {
@@ -3433,7 +3435,11 @@ void Gap::on_legacy_advertising_stopped()
3433
3435
_pending_sets.clear (LEGACY_ADVERTISING_HANDLE);
3434
3436
3435
3437
// 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
+ ) {
3437
3443
_address_refresh_sets.clear (LEGACY_ADVERTISING_HANDLE);
3438
3444
startAdvertising (LEGACY_ADVERTISING_HANDLE);
3439
3445
_adv_started_from_refresh.set (LEGACY_ADVERTISING_HANDLE);
@@ -4238,7 +4244,11 @@ bool Gap::is_advertising() const
4238
4244
}
4239
4245
4240
4246
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 ();
4242
4252
}
4243
4253
4244
4254
void Gap::update_advertising_set_connectable_attribute (
@@ -4303,12 +4313,14 @@ const address_t *Gap::get_random_address(controller_operation_t operation, size_
4303
4313
// it to the address to use to determine if the address is correct or not.
4304
4314
if (_initiating) {
4305
4315
address_in_use = &resolvable_address;
4316
+ #if BLE_ROLE_OBSERVER
4306
4317
} else if (_scan_state != ScanState::idle) {
4307
4318
if (central_non_resolvable) {
4308
4319
address_in_use = &non_resolvable_address;
4309
4320
} else {
4310
4321
address_in_use = &resolvable_address;
4311
4322
}
4323
+ #endif // BLE_ROLE_OBSERVER
4312
4324
} else if (advertising_use_main_address && (_active_sets.get (set_id) || _pending_sets.get (set_id))) {
4313
4325
if (!_set_is_connectable.get (set_id) && peripheral_non_resolvable) {
4314
4326
address_in_use = &non_resolvable_address;
0 commit comments