Skip to content

Commit 04891b2

Browse files
committed
BLE - Conditionally handle gap events.
1 parent ea9554d commit 04891b2

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioPalGap.tpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ namespace pal {
2323
namespace vendor {
2424
namespace cordio {
2525

26+
namespace {
27+
bool dummy_gap_event_handler(const wsfMsgHdr_t *msg)
28+
{
29+
return false;
30+
}
31+
}
32+
2633
template<class EventHandler>
2734
bool Gap<EventHandler>::is_feature_supported_(
2835
ble::controller_supported_features_t feature
@@ -467,6 +474,7 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
467474

468475

469476
switch (msg->event) {
477+
#if BLE_FEATURE_PHY_MANAGEMENT
470478
case DM_PHY_READ_IND: {
471479
if (!handler) {
472480
break;
@@ -497,7 +505,8 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
497505
);
498506
}
499507
break;
500-
508+
#endif // BLE_FEATURE_PHY_MANAGEMENT
509+
#if BLE_FEATURE_PERIODIC_ADVERTISING
501510
case DM_PER_ADV_SYNC_EST_IND: {
502511
if (!handler) {
503512
break;
@@ -545,7 +554,9 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
545554
handler->on_periodic_advertising_sync_loss(evt->syncHandle);
546555
}
547556
break;
548-
557+
#endif BLE_FEATURE_PERIODIC_ADVERTISING
558+
559+
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
549560
case DM_SCAN_REQ_RCVD_IND: {
550561
if (!handler) {
551562
break;
@@ -573,8 +584,10 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
573584
evt->numComplEvts
574585
);
575586
}
576-
break;
587+
break;
588+
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
577589

590+
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
578591
case DM_EXT_SCAN_STOP_IND: {
579592
if (!handler) {
580593
break;
@@ -611,7 +624,9 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
611624
);
612625
}
613626
break;
627+
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
614628

629+
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
615630
case DM_CONN_UPDATE_IND: {
616631
if (!handler) {
617632
break;
@@ -644,14 +659,20 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
644659
}
645660
break;
646661
}
662+
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
647663

648664
// all handlers are stored in a static array
649665
static const event_handler_t handlers[] = {
650-
&event_handler<ConnectionCompleteMessageConverter>,
666+
#if BLE_ROLE_OBSERVER
651667
&event_handler<GapAdvertisingReportMessageConverter>,
668+
#endif // BLE_ROLE_OBSERVER
669+
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
670+
&event_handler<ConnectionCompleteMessageConverter>,
652671
&event_handler<DisconnectionMessageConverter>,
653672
&event_handler<ConnectionUpdateMessageConverter>,
654-
&event_handler<RemoteConnectionParameterRequestMessageConverter>
673+
&event_handler<RemoteConnectionParameterRequestMessageConverter>,
674+
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
675+
&dummy_gap_event_handler
655676
};
656677

657678
// event->hdr.param: connection handle

0 commit comments

Comments
 (0)