BLE: Fix function braces opening in header files.

pull/8738/head
Vincent Coubard 2018-11-23 14:28:34 +00:00
parent 1b734a46d2
commit f64b37ba0d
10 changed files with 236 additions and 113 deletions

View File

@ -56,7 +56,8 @@ struct Bounded {
*
* @return The current value.
*/
Rep value() const {
Rep value() const
{
return _value;
}

View File

@ -98,14 +98,18 @@ struct Duration {
*
* It is initialized with the minimum value acceptable.
*/
Duration() : duration(Range::MIN) { }
Duration() : duration(Range::MIN)
{
}
/**
* Construct a Duration from an integer value.
*
* @param v The value of the duration in TN units.
*/
explicit Duration(Rep v) : duration(clamp(v)) { }
explicit Duration(Rep v) : duration(clamp(v))
{
}
/**
* Construct a Duration from another Duration.
@ -140,14 +144,16 @@ struct Duration {
template<typename OtherRep, typename OtherRange, typename OtherF>
explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) :
duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
{ }
{
}
/**
* Return the duration in TB units.
*
* @return The duration in TB units.
*/
Rep value() const {
Rep value() const
{
return duration;
}
@ -156,7 +162,8 @@ struct Duration {
*
* @return The duration in milliseconds.
*/
uint32_t valueInMs() const {
uint32_t valueInMs() const
{
return ((uint32_t)duration * TB) / 1000;
}
@ -215,7 +222,8 @@ struct Duration {
}
private:
static Rep clamp(Rep in) {
static Rep clamp(Rep in)
{
if (in < MIN) {
return MIN;
} else if (in > MAX) {
@ -255,7 +263,8 @@ typedef Duration<uint32_t, 1000 * millisecond_t::TIME_BASE> second_t;
* @return The converted duration. It is rounded up if precision is loss.
*/
template<typename DurationOut, typename RepIn, uint32_t TBIn, typename RangeIn, typename FIn>
DurationOut durationCast(Duration<RepIn, TBIn, RangeIn, FIn> duration) {
DurationOut durationCast(Duration<RepIn, TBIn, RangeIn, FIn> duration)
{
return DurationOut(((duration.value() * TBIn) + DurationOut::TIME_BASE - 1) / DurationOut::TIME_BASE);
}
@ -286,7 +295,8 @@ template<typename Rep, uint32_t TB, typename Range, typename F>
Duration<Rep, TB, Range, F> operator+(
Duration<Rep, TB, Range, F> lhs,
Duration<Rep, TB, Range, F> rhs
) {
)
{
return Duration<Rep, TB, Range, F>(lhs.value() + rhs.value());
}
@ -299,7 +309,8 @@ Duration<Rep, TB, Range, F> operator+(
* @return A duration that represents the multiplication of lhs with rhs.
*/
template<typename Rep, uint32_t TB, typename Range, typename F>
Duration<Rep, TB, Range, F> operator*(Duration<Rep, TB, Range, F> lhs, uint32_t rhs) {
Duration<Rep, TB, Range, F> operator*(Duration<Rep, TB, Range, F> lhs, uint32_t rhs)
{
return Duration<Rep, TB, Range, F>(lhs.value() * rhs);
}
@ -312,7 +323,8 @@ Duration<Rep, TB, Range, F> operator*(Duration<Rep, TB, Range, F> lhs, uint32_t
* @return A duration that represents the multiplication of lhs with rhs.
*/
template<typename Rep, uint32_t TB, typename Range, typename F>
Duration<Rep, TB, Range, F> operator*(uint32_t lhs, Duration<Rep, TB, Range, F> rhs) {
Duration<Rep, TB, Range, F> operator*(uint32_t lhs, Duration<Rep, TB, Range, F> rhs)
{
return Duration<Rep, TB, Range, F>(lhs * rhs.value());
}
@ -326,7 +338,8 @@ template<
typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS
>
bool operator<(Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs) {
bool operator<(Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs)
{
return lhs.value() * lhs.TIME_BASE < rhs.value() * rhs.TIME_BASE;
}
@ -337,7 +350,8 @@ bool operator<(Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepRHS, TBR
* @return true if lhs is less than rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range, typename F>
bool operator<(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs) {
bool operator<(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
{
return lhs.value() < rhs.value();
}
@ -354,7 +368,8 @@ template<
bool operator<=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) {
)
{
return lhs.value() * lhs.TIME_BASE <= rhs.value() * rhs.TIME_BASE;
}
@ -365,7 +380,8 @@ bool operator<=(
* @return true if lhs is less than or equal to rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range>
bool operator<=(Duration<Rep, Us, Range> lhs, Duration<Rep, Us, Range> rhs) {
bool operator<=(Duration<Rep, Us, Range> lhs, Duration<Rep, Us, Range> rhs)
{
return lhs.value() <= rhs.value();
}
@ -382,7 +398,8 @@ template<
bool operator==(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) {
)
{
return lhs.value() * lhs.TIME_BASE == rhs.value() * rhs.TIME_BASE;
}
@ -393,7 +410,8 @@ bool operator==(
* @return true if lhs is equal to rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range, typename F>
bool operator==(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs) {
bool operator==(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
{
return lhs.value() == rhs.value();
}
@ -410,7 +428,8 @@ template<
bool operator!=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) {
)
{
return !(lhs == rhs);
}
@ -421,7 +440,8 @@ bool operator!=(
* @return true if lhs is not equal to rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range, typename F>
bool operator!=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs) {
bool operator!=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
{
return !(lhs == rhs);
}
@ -438,7 +458,8 @@ template<
bool operator>=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) {
)
{
return rhs <= lhs;
}
@ -449,7 +470,8 @@ bool operator>=(
* @return true if lhs is greater or equal to rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range, typename F>
bool operator>=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs) {
bool operator>=(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
{
return rhs <= lhs;
}
@ -466,7 +488,8 @@ template<
bool operator>(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) {
)
{
return rhs < lhs;
}
@ -477,7 +500,8 @@ bool operator>(
* @return true if lhs is greater than rhs and false otherwise.
*/
template<typename Rep, uint32_t Us, typename Range, typename F>
bool operator>(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs) {
bool operator>(Duration<Rep, Us, Range, F> lhs, Duration<Rep, Us, Range, F> rhs)
{
return rhs < lhs;
}

View File

@ -156,8 +156,9 @@ struct adv_data_type_t : SafeEnum<adv_data_type_t, uint8_t> {
/**
* Construct a new instance of adv_data_type_t.
*/
adv_data_type_t(type value) :
SafeEnum<adv_data_type_t, uint8_t>(value) { }
adv_data_type_t(type value) : SafeEnum(value)
{
}
};
@ -181,9 +182,12 @@ struct adv_data_flags_t {
static const uint8_t default_flags = BREDR_NOT_SUPPORTED | LE_GENERAL_DISCOVERABLE;
/** Create from raw value */
adv_data_flags_t(uint8_t value = 0) : _value(value) {};
adv_data_flags_t(uint8_t value = 0) : _value(value)
{
}
adv_data_flags_t& setGeneralDiscoverable(bool enable = true) {
adv_data_flags_t& setGeneralDiscoverable(bool enable = true)
{
_value &= ~0x03;
if (enable) {
_value |= LE_GENERAL_DISCOVERABLE;
@ -191,7 +195,8 @@ struct adv_data_flags_t {
return *this;
}
adv_data_flags_t& setLimitedDiscoverable(bool enable = true) {
adv_data_flags_t& setLimitedDiscoverable(bool enable = true)
{
_value &= ~0x03;
if (enable) {
_value |= LE_LIMITED_DISCOVERABLE;
@ -199,7 +204,8 @@ struct adv_data_flags_t {
return *this;
}
adv_data_flags_t& setBredrNotSupported(bool enable = true) {
adv_data_flags_t& setBredrNotSupported(bool enable = true)
{
_value &= ~BREDR_NOT_SUPPORTED;
if (enable) {
_value |= BREDR_NOT_SUPPORTED;
@ -207,7 +213,8 @@ struct adv_data_flags_t {
return *this;
}
adv_data_flags_t& setSimultaneousLeBredrC(bool enable = true) {
adv_data_flags_t& setSimultaneousLeBredrC(bool enable = true)
{
_value &= ~SIMULTANEOUS_LE_BREDR_C;
if (enable) {
_value |= SIMULTANEOUS_LE_BREDR_C;
@ -215,7 +222,8 @@ struct adv_data_flags_t {
return *this;
}
adv_data_flags_t& setSimultaneousLeBredrH(bool enable = true) {
adv_data_flags_t& setSimultaneousLeBredrH(bool enable = true)
{
_value &= ~SIMULTANEOUS_LE_BREDR_H;
if (enable) {
_value |= SIMULTANEOUS_LE_BREDR_H;
@ -223,31 +231,38 @@ struct adv_data_flags_t {
return *this;
}
bool getGeneralDiscoverable() {
bool getGeneralDiscoverable()
{
return _value& LE_GENERAL_DISCOVERABLE;
}
bool getlimitedDiscoverable() {
bool getlimitedDiscoverable()
{
return _value& LE_LIMITED_DISCOVERABLE;
}
bool getBrEdrNotSupported() {
bool getBrEdrNotSupported()
{
return _value& BREDR_NOT_SUPPORTED;
}
bool getSimultaneousLeBredrC() {
bool getSimultaneousLeBredrC()
{
return _value& SIMULTANEOUS_LE_BREDR_C;
}
bool getSimultaneousLeBredrH() {
bool getSimultaneousLeBredrH()
{
return _value& SIMULTANEOUS_LE_BREDR_H;
}
void clear() {
void clear()
{
_value = 0;
}
uint8_t value() {
uint8_t value()
{
return _value;
}
@ -519,8 +534,7 @@ struct adv_data_appearance_t : SafeEnum<adv_data_appearance_t, uint16_t> {
/**
* Construct a new instance of adv_data_appearance_t.
*/
adv_data_appearance_t(type value) :
SafeEnum<adv_data_appearance_t, uint16_t>(value) { }
adv_data_appearance_t(type value) : SafeEnum(value) { }
};

View File

@ -297,7 +297,8 @@ public:
AdvertisingParameters &setPeer(
const address_t &address,
target_peer_address_type_t addressType
) {
)
{
_peerAddress = address;
_peerAddressType = addressType;
return *this;

View File

@ -148,7 +148,8 @@ public:
slave_latency_t slaveLatency = slave_latency_t::min(),
supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t::max(),
conn_event_length_t minEventLength = conn_event_length_t::min(),
conn_event_length_t maxEventLength = conn_event_length_t::max());
conn_event_length_t maxEventLength = conn_event_length_t::max()
);
/* setters */
@ -233,7 +234,6 @@ public:
handlePhyToggle(phy_t::LE_1M, phy1M);
handlePhyToggle(phy_t::LE_2M, phy2M);
handlePhyToggle(phy_t::LE_CODED, phyCoded);
return *this;
}
@ -247,7 +247,6 @@ public:
ConnectionParameters &disablePhy(phy_t phy = phy_t::LE_1M)
{
handlePhyToggle(phy, false);
return *this;
}
@ -261,7 +260,6 @@ public:
ConnectionParameters &enablePhy(phy_t phy = phy_t::LE_1M)
{
handlePhyToggle(phy, true);
return *this;
}

View File

@ -71,7 +71,9 @@ struct AdvertisingReportEvent {
periodicInterval(periodicInterval),
directAddressType(directAddressType),
directAddress(directAddress),
advertisingData(advertisingData) { }
advertisingData(advertisingData)
{
}
#endif
/** Get event type. */
@ -205,7 +207,9 @@ struct ConnectionCompleteEvent {
connectionInterval(connectionInterval),
connectionLatency(connectionLatency),
supervisionTimeout(supervisionTimeout),
masterClockAccuracy(masterClockAccuracy) { }
masterClockAccuracy(masterClockAccuracy)
{
}
#endif
/** Get connection complete event status. */
@ -323,7 +327,9 @@ struct PeriodicAdvertisingSyncEstablishedEvent {
peerAddress(peerAddress),
peerPhy(peerPhy),
advertisingInterval(advertisingInterval),
peerClockAccuracy(peerClockAccuracy) { }
peerClockAccuracy(peerClockAccuracy)
{
}
#endif
/** Get sync establishment status. */
@ -411,7 +417,9 @@ struct PeriodicAdvertisingReportEvent {
txPower(txPower),
rssi(rssi),
dataStatus(dataStatus),
payload(payload) { }
payload(payload)
{
}
#endif
/** Get periodic advertising sync handle. */
@ -466,7 +474,9 @@ struct PeriodicAdvertisingSyncLoss {
PeriodicAdvertisingSyncLoss(
periodic_sync_handle_t syncHandle
) :
syncHandle(syncHandle) { }
syncHandle(syncHandle)
{
}
#endif
/** Get periodic sync handle. */
@ -509,7 +519,9 @@ struct AdvertisingEndEvent {
advHandle(advHandle),
connection(connection),
completed_events(completed_events),
connected(connected) { }
connected(connected)
{
}
#endif
/** Get advertising handle. */
@ -563,7 +575,9 @@ struct ScanRequestEvent {
) :
advHandle(advHandle),
peerAddressType(peerAddressType),
peerAddress(peerAddress) { }
peerAddress(peerAddress)
{
}
#endif
/** Get advertising handle. */
@ -600,7 +614,10 @@ struct DisconnectionEvent {
DisconnectionEvent(
connection_handle_t connectionHandle,
const disconnection_reason_t &reason
) : connectionHandle(connectionHandle), reason(reason) { }
) :
connectionHandle(connectionHandle), reason(reason)
{
}
#endif
/**
@ -643,7 +660,8 @@ struct UpdateConnectionParametersRequestEvent {
maxConnectionInterval(maxConnectionInterval),
slaveLatency(slaveLatency),
supervisionTimeout(supervision_timeout)
{ }
{
}
#endif
/**
@ -713,7 +731,8 @@ struct ConnectionParametersUpdateCompleteEvent {
connectionInterval(connectionInterval),
slaveLatency(slaveLatency),
supervisionTimeout(supervisionTimeout)
{ }
{
}
#endif
/**

View File

@ -44,7 +44,9 @@ public:
*
* @see AdvertisingParameters::setScanRequestNotification().
*/
virtual void onScanRequestReceived(const ScanRequestEvent &event) { }
virtual void onScanRequestReceived(const ScanRequestEvent &event)
{
}
/**
* Called when advertising ends.
@ -58,7 +60,9 @@ public:
* @see stopAdvertising()
* @see onConnectionComplete()
*/
virtual void onAdvertisingEnd(const AdvertisingEndEvent &event) { }
virtual void onAdvertisingEnd(const AdvertisingEndEvent &event)
{
}
/**
* Called when a scanner receives an advertising or a scan response packet.
@ -67,7 +71,9 @@ public:
*
* @see startScan()
*/
virtual void onAdvertisingReport(const AdvertisingReportEvent &event) { }
virtual void onAdvertisingReport(const AdvertisingReportEvent &event)
{
}
/**
* Called when scan times out.
@ -76,7 +82,9 @@ public:
*
* @see startScan()
*/
virtual void onScanTimeout(const ScanTimeoutEvent & event) { }
virtual void onScanTimeout(const ScanTimeoutEvent & event)
{
}
/**
* Called when first advertising packet in periodic advertising is received.
@ -89,7 +97,9 @@ public:
*/
virtual void onPeriodicAdvertisingSyncEstablished(
const PeriodicAdvertisingSyncEstablishedEvent &event
) { }
)
{
}
/**
* Called when a periodic advertising packet is received.
@ -102,7 +112,9 @@ public:
*/
virtual void onPeriodicAdvertisingReport(
const PeriodicAdvertisingReportEvent &event
) { }
)
{
}
/**
* Called when a periodic advertising sync has been lost.
@ -115,7 +127,9 @@ public:
*/
virtual void onPeriodicAdvertisingSyncLoss(
const PeriodicAdvertisingSyncLoss &event
) { }
)
{
}
/**
* Called when connection attempt ends or an advertising device has been
@ -126,7 +140,9 @@ public:
*
* @param event Connection event.
*/
virtual void onConnectionComplete(const ConnectionCompleteEvent &event) { }
virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
{
}
/**
* Called when the peer request connection parameters updates.
@ -147,7 +163,9 @@ public:
*/
virtual void onUpdateConnectionParametersRequest(
const UpdateConnectionParametersRequestEvent &event
) { }
)
{
}
/**
* Called when connection parameters have been updated.
@ -159,7 +177,9 @@ public:
*/
virtual void onConnectionParametersUpdateComplete(
const ConnectionParametersUpdateCompleteEvent &event
) { }
)
{
}
/**
* Called when a connection has been disconnected.
@ -168,7 +188,9 @@ public:
*
* @see disconnect()
*/
virtual void onDisconnectionComplete(const DisconnectionEvent &event) { }
virtual void onDisconnectionComplete(const DisconnectionEvent &event)
{
}
/**
* Function invoked when the current transmitter and receiver PHY have
@ -193,7 +215,9 @@ public:
connection_handle_t connectionHandle,
phy_t txPhy,
phy_t rxPhy
) { }
)
{
}
/**
* Function invoked when the update process of the PHY has been completed.
@ -225,14 +249,18 @@ public:
connection_handle_t connectionHandle,
phy_t txPhy,
phy_t rxPhy
) { }
)
{
}
protected:
/**
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the Gap class will never delete the instance it contains.
*/
~EventHandler() { }
~EventHandler()
{
}
};
/**
@ -714,10 +742,10 @@ protected:
public:
/**
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
struct PeripheralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
@ -736,26 +764,26 @@ public:
* Do not resolve the address of the initiator and accept the
* connection request.
*/
DO_NOT_RESOLVE,
DO_NOT_RESOLVE,
/**
* If a bond is present in the secure database and the address
* resolution fail then reject the connection request with the error
* code AUTHENTICATION_FAILLURE.
*/
REJECT_NON_RESOLVED_ADDRESS,
REJECT_NON_RESOLVED_ADDRESS,
/**
* Perform the pairing procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_PAIRING_PROCEDURE,
PERFORM_PAIRING_PROCEDURE,
/**
* Perform the authentication procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_AUTHENTICATION_PROCEDURE
PERFORM_AUTHENTICATION_PROCEDURE
};
/**
@ -789,14 +817,14 @@ public:
/**
* Do not resolve the address received in advertising packets.
*/
DO_NOT_RESOLVE,
DO_NOT_RESOLVE,
/**
* Resolve the resolvable addresses in the advertising packet and
* forward advertising packet to the application independently of
* the address resolution procedure result.
*/
RESOLVE_AND_FORWARD,
RESOLVE_AND_FORWARD,
/**
* Filter out packets containing a resolvable that cannot be resolved
@ -805,7 +833,7 @@ public:
* @note Filtering is applied if the local device contains at least
* one bond.
*/
RESOLVE_AND_FILTER
RESOLVE_AND_FILTER
};
/**
@ -906,7 +934,9 @@ protected:
/**
* Construct a Gap instance.
*/
Gap() : _eventHandler(NULL) { }
Gap() : _eventHandler(NULL)
{
}
/**
* Event handler provided by the application.

View File

@ -64,7 +64,8 @@ public:
phys(phy_set_t::PHY_SET_1M),
phy_1m_configuration(scan_interval, scan_window, active_scanning),
phy_coded_configuration()
{ }
{
}
ScanParameters(
phy_configuration_t phy_1m_configuration,
@ -76,7 +77,8 @@ public:
phys(phy_set_t::PHY_SET_1M),
phy_1m_configuration(phy_1m_configuration),
phy_coded_configuration()
{ }
{
}
ScanParameters(
phy_configuration_t phy_1m_configuration,
@ -89,7 +91,8 @@ public:
phys(true, false, true),
phy_1m_configuration(phy_1m_configuration),
phy_coded_configuration(phy_coded_configuration)
{ }
{
}
ScanParameters& set_own_address_type(own_address_type_t address)
{

View File

@ -103,8 +103,9 @@ struct advertising_type_t : SafeEnum<advertising_type_t, uint8_t> {
/**
* Construct a new advertising_type_t value.
*/
advertising_type_t(type value) :
SafeEnum<advertising_type_t, uint8_t>(value) { }
advertising_type_t(type value) : SafeEnum(value)
{
}
};
@ -120,17 +121,17 @@ struct advertising_data_status_t : SafeEnum<advertising_data_status_t, uint8_t
/**
* Construct a new advertising_data_status_t value.
*/
advertising_data_status_t(type value) :
SafeEnum<advertising_data_status_t, uint8_t>(value) { }
advertising_data_status_t(type value) : SafeEnum(value)
{
}
/**
* Explicit constructor from a raw value.
*/
explicit advertising_data_status_t(uint8_t raw_value) :
SafeEnum<advertising_data_status_t, uint8_t>(
static_cast<advertising_data_status_t>(raw_value)
)
{ }
SafeEnum(static_cast<advertising_data_status_t>(raw_value))
{
}
};
/** Properties of an advertising event.
@ -140,7 +141,9 @@ struct advertising_event_t {
*
* @param value
*/
explicit advertising_event_t(uint8_t value) : value(value) { }
explicit advertising_event_t(uint8_t value) : value(value)
{
}
/** Is advertising connectable.
*
@ -277,7 +280,9 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
};
advertising_filter_policy_t(type value) : SafeEnum(value) { }
advertising_filter_policy_t(type value) : SafeEnum(value)
{
}
};
/**
@ -336,15 +341,17 @@ struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t>
/**
* The whitelist is not used to determine which advertiser to connect to.
*/
NO_FILTER,
NO_FILTER,
/**
* Whitelist is used to determine which advertiser to connect to.
*/
USE_WHITE_LIST
USE_WHITE_LIST
};
initiator_filter_policy_t(type value) : SafeEnum(value) { }
initiator_filter_policy_t(type value) : SafeEnum(value)
{
}
};
/**
@ -373,7 +380,9 @@ struct duplicates_filter_t : SafeEnum<duplicates_filter_t, uint8_t >{
/**
* Construct a new duplicates_filter_t value.
*/
duplicates_filter_t(type value) : SafeEnum(value) { }
duplicates_filter_t(type value) : SafeEnum(value)
{
}
};
/**
@ -412,7 +421,9 @@ struct own_address_type_t : SafeEnum<own_address_type_t, uint8_t> {
/**
* Construct a new instance of own_address_type_t.
*/
own_address_type_t(type value) : SafeEnum(value) { }
own_address_type_t(type value) : SafeEnum(value)
{
}
};
struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t> {
@ -423,13 +434,15 @@ struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t
RANDOM = 0x01, /**< Random Device Address or Random (static) Identity Address. */
RANDOM_ADDRESS = 0x01
};
target_peer_address_type_t(type value) : SafeEnum(value) { }
target_peer_address_type_t(type value) : SafeEnum(value)
{
}
};
/**
* Accuracy of the master clock.
*/
struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t > {
enum type {
/**
* 500 PPM
@ -476,7 +489,8 @@ struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
*
* @return Parts per million as a number.
*/
uint16_t get_ppm() {
uint16_t get_ppm()
{
switch(value()) {
case PPM_500: return 500;
case PPM_250: return 250;
@ -493,13 +507,17 @@ struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
/**
* Construct a new clock_accuracy_t value.
*/
clock_accuracy_t(type value) : SafeEnum(value) { }
clock_accuracy_t(type value) : SafeEnum(value)
{
}
/**
* Construct a new clock_accuracy_t value from a raw value.
* @param raw_value The value of the clock accuracy.
*/
explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value) { }
explicit clock_accuracy_t(uint8_t raw_value) : SafeEnum(raw_value)
{
}
};
/**
@ -546,13 +564,18 @@ struct connection_role_t :SafeEnum<connection_role_t, uint8_t> {
/**
* Construct a new instance of role_t.
*/
connection_role_t(type value) : SafeEnum(value) { }
connection_role_t(type value) : SafeEnum(value)
{
}
/**
* Explicit constructor from a raw value.
* @param raw_value The role.
*/
explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value) { }
explicit connection_role_t(uint8_t raw_value) : SafeEnum(raw_value)
{
}
};
/**
@ -604,7 +627,9 @@ struct local_disconnection_reason_t : SafeEnum<local_disconnection_reason_t, uin
/**
* Construct a new instance of disconnection_reason_t.
*/
local_disconnection_reason_t(type value) : SafeEnum(value) { }
local_disconnection_reason_t(type value) : SafeEnum(value)
{
}
};
@ -653,7 +678,9 @@ struct disconnection_reason_t : SafeEnum<disconnection_reason_t, uint8_t> {
/**
* Construct a new instance of disconnection_reason_t.
*/
disconnection_reason_t(type value) : SafeEnum(value) { }
disconnection_reason_t(type value) : SafeEnum(value)
{
}
};

View File

@ -732,19 +732,24 @@ private:
template<size_t bit_size>
struct BitArray {
BitArray() : data() { }
BitArray() : data()
{
}
bool get(size_t index) const {
bool get(size_t index) const
{
position p(index);
return (data[p.byte_index] >> p.bit_index) & 0x01;
}
void set(size_t index) {
void set(size_t index)
{
position p(index);
data[p.byte_index] |= (0x01 << p.bit_index);
}
void clear(size_t index) {
void clear(size_t index)
{
position p(index);
data[p.byte_index] &= ~(0x01 << p.bit_index);
}
@ -754,7 +759,8 @@ private:
position(size_t bit_number) :
byte_index(bit_number / 8),
bit_index(bit_number % 8)
{ }
{
}
size_t byte_index;
uint8_t bit_index;