Skip to content

Commit

Permalink
minor cleanup of public API classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Grover committed Nov 21, 2014
1 parent d0dbe29 commit 3d8441e
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 345 deletions.
27 changes: 4 additions & 23 deletions common/UUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* limitations under the License.
*/


#include <stdio.h>
#include <string.h>

#include "UUID.h"

UUID::UUID(ShortUUIDBytes_t shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(shortUUID) {
/* empty */
}

/**************************************************************************/
/*!
@brief Creates a new 128-bit UUID
Expand Down Expand Up @@ -90,24 +92,3 @@ UUID::UUID(const LongUUIDBytes_t longUUID) : type(UUID_TYPE_SHORT), baseUUID(),
}
}

/**************************************************************************/
/*!
@brief Creates a short (16-bit) UUID
@param[in] ble_uuid
The 16-bit BLE UUID value.
*/
/**************************************************************************/
UUID::UUID(ShortUUIDBytes_t shortUUID) : type(UUID_TYPE_SHORT), baseUUID(), shortUUID(shortUUID)
{
/* empty */
}

/**************************************************************************/
/*!
@brief UUID destructor
*/
/**************************************************************************/
UUID::~UUID(void)
{
}
5 changes: 3 additions & 2 deletions public/CallChainOfFunctionPointersWithContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace mbed {
template <typename ContextType>
class CallChainOfFunctionPointersWithContext {
public:
typedef FunctionPointerWithContext<ContextType>* pFunctionPointerWithContext_t;
typedef FunctionPointerWithContext<ContextType> *pFunctionPointerWithContext_t;

public:
/** Create an empty chain
Expand Down Expand Up @@ -122,8 +122,9 @@ class CallChainOfFunctionPointersWithContext {
* chained FunctionPointers.
*/
void call(ContextType context) {
if (chainHead)
if (chainHead) {
chainHead->call(context);
}
}

private:
Expand Down
78 changes: 11 additions & 67 deletions public/GapAdvertisingParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef __GAP_ADVERTISING_PARAMS_H__
#define __GAP_ADVERTISING_PARAMS_H__

#include "blecommon.h"

/**************************************************************************/
/*!
\brief
Expand All @@ -32,18 +30,9 @@
\li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1
\li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3
\par EXAMPLE
\code
// ToDo
\endcode
*/
/**************************************************************************/
class GapAdvertisingParams
{
class GapAdvertisingParams {
public:
static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN = 0x0020;
static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN_NONCON = 0x00A0;
Expand Down Expand Up @@ -76,67 +65,22 @@ class GapAdvertisingParams
uint16_t timeout = 0);
virtual ~GapAdvertisingParams(void);

void setAdvertisingType(AdvertisingType newAdvType);
void setInterval(uint16_t newInterval);
void setTimeout(uint16_t newTimeout);
AdvertisingType getAdvertisingType(void) const {return _advType; }
uint16_t getInterval(void) const {return _interval;}
uint16_t getTimeout(void) const {return _timeout; }

virtual AdvertisingType getAdvertisingType(void) const;
virtual uint16_t getInterval(void) const;
virtual uint16_t getTimeout(void) const;
void setAdvertisingType(AdvertisingType newAdvType) {_advType = newAdvType; }
void setInterval(uint16_t newInterval) {_interval = newInterval;}
void setTimeout(uint16_t newTimeout) {_timeout = newTimeout; }

private:
AdvertisingType _advType;
uint16_t _interval;
uint16_t _timeout;
};

inline void
GapAdvertisingParams::setAdvertisingType(AdvertisingType newAdvType) {
_advType = newAdvType;
}

inline void
GapAdvertisingParams::setInterval(uint16_t newInterval) {
_interval = newInterval;
}

inline void
GapAdvertisingParams::setTimeout(uint16_t newTimeout) {
_timeout = newTimeout;
}


/**************************************************************************/
/*!
\brief returns the current Advertising Type value
*/
/**************************************************************************/
inline GapAdvertisingParams::AdvertisingType
GapAdvertisingParams::getAdvertisingType(void) const
{
return _advType;
}

/**************************************************************************/
/*!
\brief returns the current Advertising Delay (in units of 0.625ms)
*/
/**************************************************************************/
inline uint16_t
GapAdvertisingParams::getInterval(void) const
{
return _interval;
}

/**************************************************************************/
/*!
\brief returns the current Advertising Timeout (in seconds)
*/
/**************************************************************************/
inline uint16_t
GapAdvertisingParams::getTimeout(void) const
{
return _timeout;
}
private:
/* disallow copy constructor */
GapAdvertisingParams(const GapAdvertisingParams &);
};

#endif // ifndef __GAP_ADVERTISING_PARAMS_H__
52 changes: 14 additions & 38 deletions public/GattAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@
* limitations under the License.
*/


#ifndef __GATT_ATTRIBUTE_H__
#define __GATT_ATTRIBUTE_H__

#include <stddef.h>

#include "blecommon.h"
#include "UUID.h"

/**************************************************************************/
/*!
\brief GATT attribute
*/
/**************************************************************************/
class GattAttribute
{
class GattAttribute {
public:
typedef uint16_t Handle_t;

Expand Down Expand Up @@ -58,41 +46,29 @@ class GattAttribute
*/
/**************************************************************************/
GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) :
_uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _handle(){
_uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _handle() {
/* empty */
}

public:
Handle_t getHandle(void) const {
return _handle;
}

void setHandle(Handle_t id) {
_handle = id;
}

const UUID &getUUID(void) const {
return _uuid;
}
Handle_t getHandle(void) const {return _handle; }
const UUID &getUUID(void) const {return _uuid; }
uint16_t getInitialLength(void) const {return _initialLen;}
uint16_t getMaxLength(void) const {return _lenMax; }
void setHandle(Handle_t id) {_handle = id; }
uint8_t *getValuePtr(void) {return _valuePtr; }

uint16_t getInitialLength(void) const {
return _initialLen;
}

uint16_t getMaxLength(void) const {
return _lenMax;
}

uint8_t *getValuePtr(void) {
return _valuePtr;
}

protected:
private:
UUID _uuid; /* Characteristic UUID */
uint8_t *_valuePtr;
uint16_t _initialLen; /* Initial length of the value */
uint16_t _lenMax; /* Maximum length of the value */
Handle_t _handle;

private:
/* disallow copy and assignment */
GattAttribute(const GattAttribute &);
GattAttribute& operator=(const GattAttribute &);
};

#endif // ifndef __GATT_ATTRIBUTE_H__
Loading

0 comments on commit 3d8441e

Please sign in to comment.