Skip to content

Commit c9d719a

Browse files
committed
BLE - Cleanup conditional directives in Gap.
- Remove conditional directives for member variables. - Remove conditional directive for processXXX functions that are exclusively used by implementation. - Remove conditional directives on types exported by the class.
1 parent 126a7a9 commit c9d719a

File tree

2 files changed

+15
-58
lines changed

2 files changed

+15
-58
lines changed

features/FEATURE_BLE/ble/Gap.h

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ class LegacyGap :
409409
CENTRAL = 0x2,
410410
};
411411

412-
#if BLE_ROLE_OBSERVER
413412
/**
414413
* Representation of a scanned advertising packet.
415414
*
@@ -484,9 +483,7 @@ class LegacyGap :
484483
*/
485484
typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *>
486485
AdvertisementReportCallback_t;
487-
#endif // BLE_ROLE_OBSERVER
488486

489-
#if BLE_FEATURE_CONNECTABLE
490487
/**
491488
* Connection events.
492489
*
@@ -678,21 +675,15 @@ class LegacyGap :
678675
}
679676
};
680677

681-
#endif // BLE_FEATURE_CONNECTABLE
682-
#if BLE_FEATURE_PRIVACY
683-
#if BLE_ROLE_PERIPHERAL
684678
/**
685679
* @copydoc ble::peripheral_privacy_configuration_t
686680
*/
687681
typedef ble::peripheral_privacy_configuration_t PeripheralPrivacyConfiguration_t;
688-
#endif // BLE_ROLE_PERIPHERAL
689-
#if BLE_ROLE_CENTRAL
682+
690683
/**
691684
* @copydoc ble::central_privay_configuration_t
692685
*/
693686
typedef ble::central_privay_configuration_t CentralPrivacyConfiguration_t;
694-
#endif // BLE_ROLE_CENTRAL
695-
#endif // BLE_FEATURE_PRIVACY
696687

697688
/**
698689
* Number of microseconds in 1.25 milliseconds.
@@ -728,7 +719,7 @@ class LegacyGap :
728719
*/
729720
typedef CallChainOfFunctionPointersWithContext<TimeoutSource_t>
730721
TimeoutEventCallbackChain_t;
731-
#if BLE_FEATURE_CONNECTABLE
722+
732723
/**
733724
* Connection event handler.
734725
*
@@ -760,7 +751,7 @@ class LegacyGap :
760751
*/
761752
typedef CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t *>
762753
DisconnectionEventCallbackChain_t;
763-
#endif // BLE_FEATURE_CONNECTABLE
754+
764755
/**
765756
* Radio notification event handler.
766757
*
@@ -2267,7 +2258,6 @@ class LegacyGap :
22672258

22682259
/* Entry points for the underlying stack to report events back to the user. */
22692260
public:
2270-
#if BLE_FEATURE_CONNECTABLE
22712261
/**
22722262
* Notify all registered connection event handlers of a connection event.
22732263
*
@@ -2362,8 +2352,7 @@ class LegacyGap :
23622352
"Use EventHandler::onDisconnectionComplete() instead"
23632353
)
23642354
void processDisconnectionEvent(Handle_t handle, DisconnectionReason_t reason);
2365-
#endif // BLE_FEATURE_CONNECTABLE
2366-
#if BLE_ROLE_OBSERVER
2355+
23672356
/**
23682357
* Forward a received advertising packet to all registered event handlers
23692358
* listening for scanned packet events.
@@ -2433,7 +2422,7 @@ class LegacyGap :
24332422
const uint8_t *advertisingData,
24342423
BLEProtocol::AddressType_t addressType = BLEProtocol::AddressType::RANDOM_STATIC
24352424
);
2436-
#endif // BLE_ROLE_OBSERVER
2425+
24372426
/**
24382427
* Notify the occurrence of a timeout event to all registered timeout events
24392428
* handler.
@@ -2454,7 +2443,6 @@ class LegacyGap :
24542443
void processTimeoutEvent(TimeoutSource_t source);
24552444

24562445
protected:
2457-
#if BLE_ROLE_BROADCASTER
24582446
/**
24592447
* Current advertising parameters.
24602448
*/
@@ -2464,36 +2452,31 @@ class LegacyGap :
24642452
* Current advertising data.
24652453
*/
24662454
GapAdvertisingData _advPayload;
2467-
#endif // BLE_ROLE_BROADCASTER
2468-
#if BLE_ROLE_OBSERVER
2455+
24692456
/**
24702457
* Current scanning parameters.
24712458
*/
24722459
GapScanningParams _scanningParams;
2473-
#endif // BLE_ROLE_OBSERVER
2474-
#if BLE_ROLE_BROADCASTER
2460+
24752461
/**
24762462
* Current scan response.
24772463
*/
24782464
GapAdvertisingData _scanResponse;
2479-
#endif // BLE_ROLE_BROADCASTER
2480-
#if BLE_FEATURE_CONNECTABLE
2465+
24812466
/**
24822467
* Number of open connections.
24832468
*/
24842469
uint8_t connectionCount;
2485-
#endif // BLE_FEATURE_CONNECTABLE
24862470

24872471
/**
24882472
* Current GAP state.
24892473
*/
24902474
GapState_t state;
2491-
#if BLE_ROLE_OBSERVER
2475+
24922476
/**
24932477
* Active scanning flag.
24942478
*/
24952479
bool scanningActive;
2496-
#endif // BLE_ROLE_OBSERVER
24972480

24982481
protected:
24992482
/**
@@ -2507,14 +2490,12 @@ class LegacyGap :
25072490
*/
25082491
RadioNotificationEventCallback_t radioNotificationCallback;
25092492

2510-
#if BLE_ROLE_OBSERVER
25112493
/**
25122494
* The registered callback handler for scanned advertisement packet
25132495
* notifications.
25142496
*/
25152497
AdvertisementReportCallback_t onAdvertisementReport;
2516-
#endif // BLE_ROLE_OBSERVER
2517-
#if BLE_FEATURE_CONNECTABLE
2498+
25182499
/**
25192500
* Callchain containing all registered callback handlers for connection
25202501
* events.
@@ -2526,7 +2507,7 @@ class LegacyGap :
25262507
* events.
25272508
*/
25282509
DisconnectionEventCallbackChain_t disconnectionCallChain;
2529-
#endif // BLE_FEATURE_CONNECTABLE
2510+
25302511
private:
25312512
/**
25322513
* Callchain containing all registered callback handlers for shutdown

features/FEATURE_BLE/source/LegacyGap.tpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ ble_error_t LegacyGap<Impl>::setWhitelist(const Whitelist_t &whitelist) {
9191
}
9292
#endif // BLE_FEATURE_WHITELIST
9393

94-
#if BLE_FEATURE_CONNECTABLE
9594
template<class Impl>
9695
void LegacyGap<Impl>::processConnectionEvent(
9796
Handle_t handle,
@@ -123,7 +122,6 @@ void LegacyGap<Impl>::processConnectionEvent(
123122

124123
connectionCallChain.call(&callbackParams);
125124
}
126-
#endif // BLE_FEATURE_CONNECTABLE
127125

128126
template<class Impl>
129127
ble_error_t LegacyGap<Impl>::setAddress(
@@ -626,7 +624,6 @@ typename LegacyGap<Impl>::GapShutdownCallbackChain_t& LegacyGap<Impl>::onShutdow
626624
return shutdownCallChain;
627625
}
628626

629-
#if BLE_ROLE_OBSERVER
630627
template<class Impl>
631628
LegacyGap<Impl>::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t() :
632629
peerAddr(),
@@ -639,7 +636,6 @@ LegacyGap<Impl>::AdvertisementCallbackParams_t::AdvertisementCallbackParams_t()
639636
peerAddrType(PeerAddressType_t::PUBLIC)
640637
{
641638
}
642-
#endif // BLE_ROLE_OBSERVER
643639

644640
template<class Impl>
645641
ble_error_t LegacyGap<Impl>::getRandomAddressType(
@@ -663,7 +659,6 @@ ble_error_t LegacyGap<Impl>::getRandomAddressType(
663659
}
664660
}
665661

666-
#if BLE_FEATURE_CONNECTABLE
667662
template<class Impl>
668663
LegacyGap<Impl>::ConnectionCallbackParams_t::ConnectionCallbackParams_t(
669664
Handle_t handleIn,
@@ -753,7 +748,6 @@ void LegacyGap<Impl>::ConnectionCallbackParams_t::constructor_helper(
753748
memset(ownAddr, 0, ADDR_LEN);
754749
}
755750
}
756-
#endif // BLE_FEATURE_CONNECTABLE
757751

758752
#if BLE_ROLE_CENTRAL
759753
template<class Impl>
@@ -772,7 +766,6 @@ ble_error_t LegacyGap<Impl>::connect(
772766
}
773767
#endif // BLE_ROLE_CENTRAL
774768

775-
#if BLE_FEATURE_CONNECTABLE
776769
template<class Impl>
777770
void LegacyGap<Impl>::processConnectionEvent(
778771
Handle_t handle,
@@ -804,9 +797,7 @@ void LegacyGap<Impl>::processConnectionEvent(
804797

805798
connectionCallChain.call(&callbackParams);
806799
}
807-
#endif // BLE_FEATURE_CONNECTABLE
808800

809-
#if BLE_ROLE_OBSERVER
810801
template<class Impl>
811802
void LegacyGap<Impl>::processAdvertisementReport(
812803
const BLEProtocol::AddressBytes_t peerAddr,
@@ -858,7 +849,6 @@ void LegacyGap<Impl>::processAdvertisementReport(
858849

859850
onAdvertisementReport.call(&params);
860851
}
861-
#endif // BLE_ROLE_OBSERVER
862852

863853
#if defined(__GNUC__) && !defined(__CC_ARM)
864854
#pragma GCC diagnostic pop
@@ -943,32 +933,18 @@ ble_error_t LegacyGap<Impl>::reset(void)
943933

944934
template<class Impl>
945935
LegacyGap<Impl>::LegacyGap() :
946-
#if BLE_ROLE_BROADCASTER
947936
_advParams(),
948937
_advPayload(),
949-
#endif // BLE_ROLE_BROADCASTER
950-
#if BLE_ROLE_OBSERVER
951938
_scanningParams(),
952-
#endif
953-
#if BLE_ROLE_BROADCASTER
954939
_scanResponse(),
955-
#endif
956-
#if BLE_FEATURE_CONNECTABLE
957940
connectionCount(0),
958-
#endif
959941
state(),
960-
#if BLE_ROLE_OBSERVER
961942
scanningActive(false),
962-
#endif
963943
timeoutCallbackChain(),
964-
radioNotificationCallback()
965-
#if BLE_ROLE_OBSERVER
966-
, onAdvertisementReport()
967-
#endif
968-
#if BLE_FEATURE_CONNECTABLE
969-
, connectionCallChain()
970-
, disconnectionCallChain()
971-
#endif // BLE_FEATURE_CONNECTABLE
944+
radioNotificationCallback(),
945+
onAdvertisementReport(),
946+
connectionCallChain(),
947+
disconnectionCallChain()
972948
{
973949
#if BLE_ROLE_BROADCASTER
974950
_advPayload.clear();

0 commit comments

Comments
 (0)