@@ -188,6 +188,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
188
188
advertising_params.getMaxPrimaryInterval ().valueInMs ()
189
189
);
190
190
191
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
191
192
/* if we support extended advertising we'll also additionally advertise another set at the same time */
192
193
if (_gap.isFeatureSupported (ble::controller_supported_features_t ::LE_EXTENDED_ADVERTISING)) {
193
194
/* With Bluetooth 5; it is possible to advertise concurrently multiple
@@ -229,6 +230,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
229
230
extended_advertising_params.getMaxPrimaryInterval ().valueInMs ()
230
231
);
231
232
}
233
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
232
234
233
235
_demo_duration.reset ();
234
236
_demo_duration.start ();
@@ -350,6 +352,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
350
352
_is_connecting = false ;
351
353
_demo_duration.stop ();
352
354
355
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
353
356
if (!_is_in_scanning_phase) {
354
357
/* if we have more than one advertising sets one of them might still be active */
355
358
if (_extended_adv_handle != ble::INVALID_ADVERTISING_HANDLE) {
@@ -361,6 +364,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
361
364
}
362
365
}
363
366
}
367
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
364
368
365
369
if (event.getStatus () != BLE_ERROR_NONE) {
366
370
print_error (event.getStatus (), " Connection failed" );
@@ -485,6 +489,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
485
489
486
490
_gap.stopAdvertising (ble::LEGACY_ADVERTISING_HANDLE);
487
491
492
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
488
493
if (_extended_adv_handle != ble::INVALID_ADVERTISING_HANDLE) {
489
494
/* if it's still active, stop it */
490
495
if (_gap.isAdvertisingActive (_extended_adv_handle)) {
@@ -501,6 +506,7 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
501
506
502
507
_extended_adv_handle = ble::INVALID_ADVERTISING_HANDLE;
503
508
}
509
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
504
510
505
511
_is_in_scanning_phase = true ;
506
512
@@ -546,12 +552,14 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
546
552
uint16_t events = (duration_ts / interval_ts);
547
553
uint16_t extended_events = 0 ;
548
554
555
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
549
556
if (_extended_adv_handle != ble::INVALID_ADVERTISING_HANDLE) {
550
557
duration_ts = ble::adv_interval_t (ble::millisecond_t (duration_ms)).value ();
551
558
interval_ts = extended_advertising_params.getMaxPrimaryInterval ().value ();
552
559
/* this is how many times we advertised */
553
560
extended_events = (duration_ts / interval_ts);
554
561
}
562
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
555
563
556
564
printf (" We have advertised for %dms\r\n " , duration_ms);
557
565
@@ -562,13 +570,17 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
562
570
} else {
563
571
printf (" We created at least %d tx and rx events\r\n " , events);
564
572
}
573
+
574
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
565
575
if (extended_events) {
566
576
if (extended_advertising_params.getType () == ble::advertising_type_t ::NON_CONNECTABLE_UNDIRECTED) {
567
577
printf (" We created at least %d tx events with extended advertising\r\n " , extended_events);
568
578
} else {
569
579
printf (" We created at least %d tx and rx events with extended advertising\r\n " , extended_events);
570
580
}
571
581
}
582
+
583
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
572
584
}
573
585
574
586
private:
@@ -588,7 +600,9 @@ class GapDemo : private mbed::NonCopyable<GapDemo>, public ble::Gap::EventHandle
588
600
Timer _demo_duration;
589
601
size_t _scan_count = 0 ;
590
602
603
+ #if BLE_FEATURE_EXTENDED_ADVERTISING
591
604
ble::advertising_handle_t _extended_adv_handle = ble::INVALID_ADVERTISING_HANDLE;
605
+ #endif // BLE_FEATURE_EXTENDED_ADVERTISING
592
606
};
593
607
594
608
/* * Schedule processing of events from the BLE middleware in the event queue. */
0 commit comments