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. * @return The current value.
*/ */
Rep value() const { Rep value() const
{
return _value; return _value;
} }

View File

@ -98,14 +98,18 @@ struct Duration {
* *
* It is initialized with the minimum value acceptable. * It is initialized with the minimum value acceptable.
*/ */
Duration() : duration(Range::MIN) { } Duration() : duration(Range::MIN)
{
}
/** /**
* Construct a Duration from an integer value. * Construct a Duration from an integer value.
* *
* @param v The value of the duration in TN units. * @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. * Construct a Duration from another Duration.
@ -140,14 +144,16 @@ struct Duration {
template<typename OtherRep, typename OtherRange, typename OtherF> template<typename OtherRep, typename OtherRange, typename OtherF>
explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) : explicit Duration(Duration<OtherRep, 1000, OtherRange, OtherF> other_ms, void* = NULL) :
duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB)) duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
{ } {
}
/** /**
* Return the duration in TB units. * Return the duration in TB units.
* *
* @return The duration in TB units. * @return The duration in TB units.
*/ */
Rep value() const { Rep value() const
{
return duration; return duration;
} }
@ -156,7 +162,8 @@ struct Duration {
* *
* @return The duration in milliseconds. * @return The duration in milliseconds.
*/ */
uint32_t valueInMs() const { uint32_t valueInMs() const
{
return ((uint32_t)duration * TB) / 1000; return ((uint32_t)duration * TB) / 1000;
} }
@ -215,7 +222,8 @@ struct Duration {
} }
private: private:
static Rep clamp(Rep in) { static Rep clamp(Rep in)
{
if (in < MIN) { if (in < MIN) {
return MIN; return MIN;
} else if (in > MAX) { } 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. * @return The converted duration. It is rounded up if precision is loss.
*/ */
template<typename DurationOut, typename RepIn, uint32_t TBIn, typename RangeIn, typename FIn> 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); 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> operator+(
Duration<Rep, TB, Range, F> lhs, Duration<Rep, TB, Range, F> lhs,
Duration<Rep, TB, Range, F> rhs Duration<Rep, TB, Range, F> rhs
) { )
{
return Duration<Rep, TB, Range, F>(lhs.value() + rhs.value()); 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. * @return A duration that represents the multiplication of lhs with rhs.
*/ */
template<typename Rep, uint32_t TB, typename Range, typename F> 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); 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. * @return A duration that represents the multiplication of lhs with rhs.
*/ */
template<typename Rep, uint32_t TB, typename Range, typename F> 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()); return Duration<Rep, TB, Range, F>(lhs * rhs.value());
} }
@ -326,7 +338,8 @@ template<
typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS, typename RepLHS, uint32_t TBLHS, typename RangeLHS, typename FLHS,
typename RepRHS, uint32_t TBRHS, typename RangeRHS, typename FRHS 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; 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. * @return true if lhs is less than rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range, typename F> 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(); return lhs.value() < rhs.value();
} }
@ -354,7 +368,8 @@ template<
bool operator<=( bool operator<=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) { )
{
return lhs.value() * lhs.TIME_BASE <= rhs.value() * rhs.TIME_BASE; 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. * @return true if lhs is less than or equal to rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range> 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(); return lhs.value() <= rhs.value();
} }
@ -382,7 +398,8 @@ template<
bool operator==( bool operator==(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) { )
{
return lhs.value() * lhs.TIME_BASE == rhs.value() * rhs.TIME_BASE; 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. * @return true if lhs is equal to rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range, typename F> 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(); return lhs.value() == rhs.value();
} }
@ -410,7 +428,8 @@ template<
bool operator!=( bool operator!=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) { )
{
return !(lhs == rhs); return !(lhs == rhs);
} }
@ -421,7 +440,8 @@ bool operator!=(
* @return true if lhs is not equal to rhs and false otherwise. * @return true if lhs is not equal to rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range, typename F> 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); return !(lhs == rhs);
} }
@ -438,7 +458,8 @@ template<
bool operator>=( bool operator>=(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) { )
{
return rhs <= lhs; return rhs <= lhs;
} }
@ -449,7 +470,8 @@ bool operator>=(
* @return true if lhs is greater or equal to rhs and false otherwise. * @return true if lhs is greater or equal to rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range, typename F> 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; return rhs <= lhs;
} }
@ -466,7 +488,8 @@ template<
bool operator>( bool operator>(
Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs, Duration<RepLHS, TBLHS, RangeLHS, FLHS> lhs,
Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs Duration<RepRHS, TBRHS, RangeRHS, FRHS> rhs
) { )
{
return rhs < lhs; return rhs < lhs;
} }
@ -477,7 +500,8 @@ bool operator>(
* @return true if lhs is greater than rhs and false otherwise. * @return true if lhs is greater than rhs and false otherwise.
*/ */
template<typename Rep, uint32_t Us, typename Range, typename F> 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; 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. * Construct a new instance of adv_data_type_t.
*/ */
adv_data_type_t(type value) : adv_data_type_t(type value) : SafeEnum(value)
SafeEnum<adv_data_type_t, uint8_t>(value) { } {
}
}; };
@ -181,9 +182,12 @@ struct adv_data_flags_t {
static const uint8_t default_flags = BREDR_NOT_SUPPORTED | LE_GENERAL_DISCOVERABLE; static const uint8_t default_flags = BREDR_NOT_SUPPORTED | LE_GENERAL_DISCOVERABLE;
/** Create from raw value */ /** 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; _value &= ~0x03;
if (enable) { if (enable) {
_value |= LE_GENERAL_DISCOVERABLE; _value |= LE_GENERAL_DISCOVERABLE;
@ -191,7 +195,8 @@ struct adv_data_flags_t {
return *this; return *this;
} }
adv_data_flags_t& setLimitedDiscoverable(bool enable = true) { adv_data_flags_t& setLimitedDiscoverable(bool enable = true)
{
_value &= ~0x03; _value &= ~0x03;
if (enable) { if (enable) {
_value |= LE_LIMITED_DISCOVERABLE; _value |= LE_LIMITED_DISCOVERABLE;
@ -199,7 +204,8 @@ struct adv_data_flags_t {
return *this; return *this;
} }
adv_data_flags_t& setBredrNotSupported(bool enable = true) { adv_data_flags_t& setBredrNotSupported(bool enable = true)
{
_value &= ~BREDR_NOT_SUPPORTED; _value &= ~BREDR_NOT_SUPPORTED;
if (enable) { if (enable) {
_value |= BREDR_NOT_SUPPORTED; _value |= BREDR_NOT_SUPPORTED;
@ -207,7 +213,8 @@ struct adv_data_flags_t {
return *this; return *this;
} }
adv_data_flags_t& setSimultaneousLeBredrC(bool enable = true) { adv_data_flags_t& setSimultaneousLeBredrC(bool enable = true)
{
_value &= ~SIMULTANEOUS_LE_BREDR_C; _value &= ~SIMULTANEOUS_LE_BREDR_C;
if (enable) { if (enable) {
_value |= SIMULTANEOUS_LE_BREDR_C; _value |= SIMULTANEOUS_LE_BREDR_C;
@ -215,7 +222,8 @@ struct adv_data_flags_t {
return *this; return *this;
} }
adv_data_flags_t& setSimultaneousLeBredrH(bool enable = true) { adv_data_flags_t& setSimultaneousLeBredrH(bool enable = true)
{
_value &= ~SIMULTANEOUS_LE_BREDR_H; _value &= ~SIMULTANEOUS_LE_BREDR_H;
if (enable) { if (enable) {
_value |= SIMULTANEOUS_LE_BREDR_H; _value |= SIMULTANEOUS_LE_BREDR_H;
@ -223,31 +231,38 @@ struct adv_data_flags_t {
return *this; return *this;
} }
bool getGeneralDiscoverable() { bool getGeneralDiscoverable()
{
return _value& LE_GENERAL_DISCOVERABLE; return _value& LE_GENERAL_DISCOVERABLE;
} }
bool getlimitedDiscoverable() { bool getlimitedDiscoverable()
{
return _value& LE_LIMITED_DISCOVERABLE; return _value& LE_LIMITED_DISCOVERABLE;
} }
bool getBrEdrNotSupported() { bool getBrEdrNotSupported()
{
return _value& BREDR_NOT_SUPPORTED; return _value& BREDR_NOT_SUPPORTED;
} }
bool getSimultaneousLeBredrC() { bool getSimultaneousLeBredrC()
{
return _value& SIMULTANEOUS_LE_BREDR_C; return _value& SIMULTANEOUS_LE_BREDR_C;
} }
bool getSimultaneousLeBredrH() { bool getSimultaneousLeBredrH()
{
return _value& SIMULTANEOUS_LE_BREDR_H; return _value& SIMULTANEOUS_LE_BREDR_H;
} }
void clear() { void clear()
{
_value = 0; _value = 0;
} }
uint8_t value() { uint8_t value()
{
return _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. * Construct a new instance of adv_data_appearance_t.
*/ */
adv_data_appearance_t(type value) : adv_data_appearance_t(type value) : SafeEnum(value) { }
SafeEnum<adv_data_appearance_t, uint16_t>(value) { }
}; };

View File

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

View File

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

View File

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

View File

@ -44,7 +44,9 @@ public:
* *
* @see AdvertisingParameters::setScanRequestNotification(). * @see AdvertisingParameters::setScanRequestNotification().
*/ */
virtual void onScanRequestReceived(const ScanRequestEvent &event) { } virtual void onScanRequestReceived(const ScanRequestEvent &event)
{
}
/** /**
* Called when advertising ends. * Called when advertising ends.
@ -58,7 +60,9 @@ public:
* @see stopAdvertising() * @see stopAdvertising()
* @see onConnectionComplete() * @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. * Called when a scanner receives an advertising or a scan response packet.
@ -67,7 +71,9 @@ public:
* *
* @see startScan() * @see startScan()
*/ */
virtual void onAdvertisingReport(const AdvertisingReportEvent &event) { } virtual void onAdvertisingReport(const AdvertisingReportEvent &event)
{
}
/** /**
* Called when scan times out. * Called when scan times out.
@ -76,7 +82,9 @@ public:
* *
* @see startScan() * @see startScan()
*/ */
virtual void onScanTimeout(const ScanTimeoutEvent & event) { } virtual void onScanTimeout(const ScanTimeoutEvent & event)
{
}
/** /**
* Called when first advertising packet in periodic advertising is received. * Called when first advertising packet in periodic advertising is received.
@ -89,7 +97,9 @@ public:
*/ */
virtual void onPeriodicAdvertisingSyncEstablished( virtual void onPeriodicAdvertisingSyncEstablished(
const PeriodicAdvertisingSyncEstablishedEvent &event const PeriodicAdvertisingSyncEstablishedEvent &event
) { } )
{
}
/** /**
* Called when a periodic advertising packet is received. * Called when a periodic advertising packet is received.
@ -102,7 +112,9 @@ public:
*/ */
virtual void onPeriodicAdvertisingReport( virtual void onPeriodicAdvertisingReport(
const PeriodicAdvertisingReportEvent &event const PeriodicAdvertisingReportEvent &event
) { } )
{
}
/** /**
* Called when a periodic advertising sync has been lost. * Called when a periodic advertising sync has been lost.
@ -115,7 +127,9 @@ public:
*/ */
virtual void onPeriodicAdvertisingSyncLoss( virtual void onPeriodicAdvertisingSyncLoss(
const PeriodicAdvertisingSyncLoss &event const PeriodicAdvertisingSyncLoss &event
) { } )
{
}
/** /**
* Called when connection attempt ends or an advertising device has been * Called when connection attempt ends or an advertising device has been
@ -126,7 +140,9 @@ public:
* *
* @param event Connection event. * @param event Connection event.
*/ */
virtual void onConnectionComplete(const ConnectionCompleteEvent &event) { } virtual void onConnectionComplete(const ConnectionCompleteEvent &event)
{
}
/** /**
* Called when the peer request connection parameters updates. * Called when the peer request connection parameters updates.
@ -147,7 +163,9 @@ public:
*/ */
virtual void onUpdateConnectionParametersRequest( virtual void onUpdateConnectionParametersRequest(
const UpdateConnectionParametersRequestEvent &event const UpdateConnectionParametersRequestEvent &event
) { } )
{
}
/** /**
* Called when connection parameters have been updated. * Called when connection parameters have been updated.
@ -159,7 +177,9 @@ public:
*/ */
virtual void onConnectionParametersUpdateComplete( virtual void onConnectionParametersUpdateComplete(
const ConnectionParametersUpdateCompleteEvent &event const ConnectionParametersUpdateCompleteEvent &event
) { } )
{
}
/** /**
* Called when a connection has been disconnected. * Called when a connection has been disconnected.
@ -168,7 +188,9 @@ public:
* *
* @see disconnect() * @see disconnect()
*/ */
virtual void onDisconnectionComplete(const DisconnectionEvent &event) { } virtual void onDisconnectionComplete(const DisconnectionEvent &event)
{
}
/** /**
* Function invoked when the current transmitter and receiver PHY have * Function invoked when the current transmitter and receiver PHY have
@ -193,7 +215,9 @@ public:
connection_handle_t connectionHandle, connection_handle_t connectionHandle,
phy_t txPhy, phy_t txPhy,
phy_t rxPhy phy_t rxPhy
) { } )
{
}
/** /**
* Function invoked when the update process of the PHY has been completed. * Function invoked when the update process of the PHY has been completed.
@ -225,14 +249,18 @@ public:
connection_handle_t connectionHandle, connection_handle_t connectionHandle,
phy_t txPhy, phy_t txPhy,
phy_t rxPhy phy_t rxPhy
) { } )
{
}
protected: protected:
/** /**
* Prevent polymorphic deletion and avoid unnecessary virtual destructor * Prevent polymorphic deletion and avoid unnecessary virtual destructor
* as the Gap class will never delete the instance it contains. * as the Gap class will never delete the instance it contains.
*/ */
~EventHandler() { } ~EventHandler()
{
}
}; };
/** /**
@ -906,7 +934,9 @@ protected:
/** /**
* Construct a Gap instance. * Construct a Gap instance.
*/ */
Gap() : _eventHandler(NULL) { } Gap() : _eventHandler(NULL)
{
}
/** /**
* Event handler provided by the application. * Event handler provided by the application.

View File

@ -64,7 +64,8 @@ public:
phys(phy_set_t::PHY_SET_1M), phys(phy_set_t::PHY_SET_1M),
phy_1m_configuration(scan_interval, scan_window, active_scanning), phy_1m_configuration(scan_interval, scan_window, active_scanning),
phy_coded_configuration() phy_coded_configuration()
{ } {
}
ScanParameters( ScanParameters(
phy_configuration_t phy_1m_configuration, phy_configuration_t phy_1m_configuration,
@ -76,7 +77,8 @@ public:
phys(phy_set_t::PHY_SET_1M), phys(phy_set_t::PHY_SET_1M),
phy_1m_configuration(phy_1m_configuration), phy_1m_configuration(phy_1m_configuration),
phy_coded_configuration() phy_coded_configuration()
{ } {
}
ScanParameters( ScanParameters(
phy_configuration_t phy_1m_configuration, phy_configuration_t phy_1m_configuration,
@ -89,7 +91,8 @@ public:
phys(true, false, true), phys(true, false, true),
phy_1m_configuration(phy_1m_configuration), phy_1m_configuration(phy_1m_configuration),
phy_coded_configuration(phy_coded_configuration) phy_coded_configuration(phy_coded_configuration)
{ } {
}
ScanParameters& set_own_address_type(own_address_type_t address) 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. * Construct a new advertising_type_t value.
*/ */
advertising_type_t(type value) : advertising_type_t(type value) : SafeEnum(value)
SafeEnum<advertising_type_t, uint8_t>(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. * Construct a new advertising_data_status_t value.
*/ */
advertising_data_status_t(type value) : advertising_data_status_t(type value) : SafeEnum(value)
SafeEnum<advertising_data_status_t, uint8_t>(value) { } {
}
/** /**
* Explicit constructor from a raw value. * Explicit constructor from a raw value.
*/ */
explicit advertising_data_status_t(uint8_t raw_value) : explicit advertising_data_status_t(uint8_t raw_value) :
SafeEnum<advertising_data_status_t, uint8_t>( SafeEnum(static_cast<advertising_data_status_t>(raw_value))
static_cast<advertising_data_status_t>(raw_value) {
) }
{ }
}; };
/** Properties of an advertising event. /** Properties of an advertising event.
@ -140,7 +141,9 @@ struct advertising_event_t {
* *
* @param value * @param value
*/ */
explicit advertising_event_t(uint8_t value) : value(value) { } explicit advertising_event_t(uint8_t value) : value(value)
{
}
/** Is advertising connectable. /** Is advertising connectable.
* *
@ -277,7 +280,9 @@ struct advertising_filter_policy_t : SafeEnum<advertising_filter_policy_t, uint8
FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03 FILTER_SCAN_AND_CONNECTION_REQUESTS = 0x03
}; };
advertising_filter_policy_t(type value) : SafeEnum(value) { } advertising_filter_policy_t(type value) : SafeEnum(value)
{
}
}; };
/** /**
@ -344,7 +349,9 @@ struct initiator_filter_policy_t : SafeEnum<initiator_filter_policy_t, uint8_t>
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. * 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. * 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> { struct target_peer_address_type_t : SafeEnum<target_peer_address_type_t, uint8_t> {
@ -423,7 +434,9 @@ 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 = 0x01, /**< Random Device Address or Random (static) Identity Address. */
RANDOM_ADDRESS = 0x01 RANDOM_ADDRESS = 0x01
}; };
target_peer_address_type_t(type value) : SafeEnum(value) { } target_peer_address_type_t(type value) : SafeEnum(value)
{
}
}; };
/** /**
@ -476,7 +489,8 @@ struct clock_accuracy_t : SafeEnum<clock_accuracy_t, uint8_t >{
* *
* @return Parts per million as a number. * @return Parts per million as a number.
*/ */
uint16_t get_ppm() { uint16_t get_ppm()
{
switch(value()) { switch(value()) {
case PPM_500: return 500; case PPM_500: return 500;
case PPM_250: return 250; 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. * 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. * Construct a new clock_accuracy_t value from a raw value.
* @param raw_value The value of the clock accuracy. * @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. * 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. * Explicit constructor from a raw value.
* @param raw_value The role. * @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. * 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. * 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> template<size_t bit_size>
struct BitArray { struct BitArray {
BitArray() : data() { } BitArray() : data()
{
}
bool get(size_t index) const { bool get(size_t index) const
{
position p(index); position p(index);
return (data[p.byte_index] >> p.bit_index) & 0x01; return (data[p.byte_index] >> p.bit_index) & 0x01;
} }
void set(size_t index) { void set(size_t index)
{
position p(index); position p(index);
data[p.byte_index] |= (0x01 << p.bit_index); data[p.byte_index] |= (0x01 << p.bit_index);
} }
void clear(size_t index) { void clear(size_t index)
{
position p(index); position p(index);
data[p.byte_index] &= ~(0x01 << p.bit_index); data[p.byte_index] &= ~(0x01 << p.bit_index);
} }
@ -754,7 +759,8 @@ private:
position(size_t bit_number) : position(size_t bit_number) :
byte_index(bit_number / 8), byte_index(bit_number / 8),
bit_index(bit_number % 8) bit_index(bit_number % 8)
{ } {
}
size_t byte_index; size_t byte_index;
uint8_t bit_index; uint8_t bit_index;