BLE - Conditionally handle gap events.

pull/9790/head
Vincent Coubard 2019-02-28 14:13:45 +00:00
parent ea9554dfbc
commit 04891b205c
1 changed files with 26 additions and 5 deletions

View File

@ -23,6 +23,13 @@ namespace pal {
namespace vendor { namespace vendor {
namespace cordio { namespace cordio {
namespace {
bool dummy_gap_event_handler(const wsfMsgHdr_t *msg)
{
return false;
}
}
template<class EventHandler> template<class EventHandler>
bool Gap<EventHandler>::is_feature_supported_( bool Gap<EventHandler>::is_feature_supported_(
ble::controller_supported_features_t feature ble::controller_supported_features_t feature
@ -467,6 +474,7 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
switch (msg->event) { switch (msg->event) {
#if BLE_FEATURE_PHY_MANAGEMENT
case DM_PHY_READ_IND: { case DM_PHY_READ_IND: {
if (!handler) { if (!handler) {
break; break;
@ -497,7 +505,8 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
); );
} }
break; break;
#endif // BLE_FEATURE_PHY_MANAGEMENT
#if BLE_FEATURE_PERIODIC_ADVERTISING
case DM_PER_ADV_SYNC_EST_IND: { case DM_PER_ADV_SYNC_EST_IND: {
if (!handler) { if (!handler) {
break; break;
@ -545,7 +554,9 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
handler->on_periodic_advertising_sync_loss(evt->syncHandle); handler->on_periodic_advertising_sync_loss(evt->syncHandle);
} }
break; break;
#endif BLE_FEATURE_PERIODIC_ADVERTISING
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
case DM_SCAN_REQ_RCVD_IND: { case DM_SCAN_REQ_RCVD_IND: {
if (!handler) { if (!handler) {
break; break;
@ -574,7 +585,9 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
); );
} }
break; break;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_BROADCASTER
#if BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
case DM_EXT_SCAN_STOP_IND: { case DM_EXT_SCAN_STOP_IND: {
if (!handler) { if (!handler) {
break; break;
@ -611,7 +624,9 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
); );
} }
break; break;
#endif // BLE_FEATURE_EXTENDED_ADVERTISING && BLE_ROLE_OBSERVER
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
case DM_CONN_UPDATE_IND: { case DM_CONN_UPDATE_IND: {
if (!handler) { if (!handler) {
break; break;
@ -644,14 +659,20 @@ void Gap<EventHandler>::gap_handler(const wsfMsgHdr_t *msg)
} }
break; break;
} }
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
// all handlers are stored in a static array // all handlers are stored in a static array
static const event_handler_t handlers[] = { static const event_handler_t handlers[] = {
&event_handler<ConnectionCompleteMessageConverter>, #if BLE_ROLE_OBSERVER
&event_handler<GapAdvertisingReportMessageConverter>, &event_handler<GapAdvertisingReportMessageConverter>,
#endif // BLE_ROLE_OBSERVER
#if BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
&event_handler<ConnectionCompleteMessageConverter>,
&event_handler<DisconnectionMessageConverter>, &event_handler<DisconnectionMessageConverter>,
&event_handler<ConnectionUpdateMessageConverter>, &event_handler<ConnectionUpdateMessageConverter>,
&event_handler<RemoteConnectionParameterRequestMessageConverter> &event_handler<RemoteConnectionParameterRequestMessageConverter>,
#endif // BLE_ROLE_CENTRAL || BLE_ROLE_PERIPHERAL
&dummy_gap_event_handler
}; };
// event->hdr.param: connection handle // event->hdr.param: connection handle