Merge branch 'iriark01-master' into develop

master
Rohit Grover 2015-11-16 14:38:46 +00:00
commit e2555c7dd5
20 changed files with 544 additions and 544 deletions

View File

@ -21,7 +21,7 @@
#include "ble/SecurityManager.h"
#include "ble/BLE.h"
/* forward declarations */
/* Forward declarations. */
class GattServer;
class GattClient;

View File

@ -61,9 +61,9 @@ public:
typedef FunctionPointerWithContext<ContextType> *pFunctionPointerWithContext_t;
public:
/** Create an empty chain
/** Create an empty chain.
*
* @param size (optional) Initial size of the chain
* @param size (optional) Initial size of the chain.
*/
CallChainOfFunctionPointersWithContext() : chainHead(NULL) {
/* empty */
@ -73,24 +73,24 @@ public:
clear();
}
/** Add a function at the front of the chain
/** Add a function at the front of the chain.
*
* @param function A pointer to a void function
* @param function A pointer to a void function.
*
* @returns
* The function object created for 'function'
* The function object created for 'function'.
*/
pFunctionPointerWithContext_t add(void (*function)(ContextType context)) {
return common_add(new FunctionPointerWithContext<ContextType>(function));
}
/** Add a function at the front of the chain
/** Add a function at the front of the chain.
*
* @param tptr pointer to the object to call the member function on
* @param mptr pointer to the member function to be called
* @param tptr Pointer to the object to call the member function on.
* @param mptr Pointer to the member function to be called.
*
* @returns
* The function object created for 'tptr' and 'mptr'
* The function object created for 'tptr' and 'mptr'.
*/
template<typename T>
pFunctionPointerWithContext_t add(T *tptr, void (T::*mptr)(ContextType context)) {
@ -115,7 +115,7 @@ public:
}
/** Call all the functions in the chain in sequence
* @Note: the stack frames of all the callbacks within the chained
* @Note: The stack frames of all the callbacks within the chained
* FunctionPointers will stack up. Hopefully there won't be too many
* chained FunctionPointers.
*/
@ -140,7 +140,7 @@ private:
private:
pFunctionPointerWithContext_t chainHead;
/* disallow copy constructor and assignment operators */
/* Disallow copy constructor and assignment operators. */
private:
CallChainOfFunctionPointersWithContext(const CallChainOfFunctionPointersWithContext &);
CallChainOfFunctionPointersWithContext & operator = (const CallChainOfFunctionPointersWithContext &);

View File

@ -29,7 +29,7 @@
class DiscoveredCharacteristic {
public:
struct Properties_t {
uint8_t _broadcast :1; /**< Broadcasting of the value permitted. */
uint8_t _broadcast :1; /**< Broadcasting the value permitted. */
uint8_t _read :1; /**< Reading the value permitted. */
uint8_t _writeWoResp :1; /**< Writing the value with Write Command permitted. */
uint8_t _write :1; /**< Writing the value with Write Request permitted. */
@ -47,8 +47,8 @@ public:
bool authSignedWrite(void) const {return _authSignedWrite;}
private:
operator uint8_t() const; /* disallow implicit conversion into an integer */
operator unsigned() const; /* disallow implicit conversion into an integer */
operator uint8_t() const; /* Disallow implicit conversion into an integer. */
operator unsigned() const; /* Disallow implicit conversion into an integer. */
};
/**
@ -72,13 +72,13 @@ public:
/**
* Initiate (or continue) a read for the value attribute, optionally at a
* given offset. If the Characteristic or Descriptor to be read is longer
* given offset. If the characteristic or descriptor to be read is longer
* than ATT_MTU - 1, this function must be called multiple times with
* appropriate offset to read the complete value.
*
* @return BLE_ERROR_NONE if a read has been initiated, else
* @return BLE_ERROR_NONE if a read has been initiated, or
* BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or
* BLE_STACK_BUSY if some client procedure already in progress, or
* BLE_STACK_BUSY if some client procedure is already in progress, or
* BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
*/
ble_error_t read(uint16_t offset = 0) const;
@ -97,9 +97,9 @@ public:
* writeWoResponse operations; the user may want to use the onDataSent()
* callback for flow-control.
*
* @retval BLE_ERROR_NONE Successfully started the Write procedure, else
* @retval BLE_ERROR_NONE Successfully started the Write procedure, or
* BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or
* BLE_STACK_BUSY if some client procedure already in progress, or
* BLE_STACK_BUSY if some client procedure is already in progress, or
* BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or
* BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
*/
@ -110,7 +110,7 @@ public:
*
* @param callback
* @param matchingUUID
* filter for descriptors. Defaults to wildcard which will discover all descriptors.
* Filter for descriptors. Defaults to wildcard which will discover all descriptors.
*
* @return BLE_ERROR_NONE if descriptor discovery is launched successfully; else an appropriate error.
*/
@ -127,9 +127,9 @@ public:
* @note It is important to note that a write will generate
* an onDataWritten() callback when the peer acknowledges the request.
*
* @retval BLE_ERROR_NONE Successfully started the Write procedure, else
* @retval BLE_ERROR_NONE Successfully started the Write procedure, or
* BLE_ERROR_INVALID_STATE if some internal state about the connection is invalid, or
* BLE_STACK_BUSY if some client procedure already in progress, or
* BLE_STACK_BUSY if some client procedure is already in progress, or
* BLE_ERROR_NO_MEM if there are no available buffers left to process the request, or
* BLE_ERROR_OPERATION_NOT_PERMITTED due to the characteristic's properties.
*/

View File

@ -20,7 +20,7 @@
#include <string.h>
/** A class for storing and calling a pointer to a static or member void function
* which takes a context.
* that takes a context.
*/
template <typename ContextType>
class FunctionPointerWithContext {
@ -28,19 +28,19 @@ public:
typedef FunctionPointerWithContext<ContextType> *pFunctionPointerWithContext_t;
typedef void (*pvoidfcontext_t)(ContextType context);
/** Create a FunctionPointerWithContext, attaching a static function
/** Create a FunctionPointerWithContext, attaching a static function.
*
* @param function The void static function to attach (default is none)
* @param function The void static function to attach (default is none).
*/
FunctionPointerWithContext(void (*function)(ContextType context) = NULL) :
_function(NULL), _caller(NULL), _next(NULL) {
attach(function);
}
/** Create a FunctionPointerWithContext, attaching a member function
/** Create a FunctionPointerWithContext, attaching a member function.
*
* @param object The object pointer to invoke the member function on (i.e. the this pointer)
* @param function The address of the void member function to attach
* @param object The object pointer to invoke the member function on (the "this" pointer).
* @param function The address of the void member function to attach.
*/
template<typename T>
FunctionPointerWithContext(T *object, void (T::*member)(ContextType context)) :
@ -48,19 +48,19 @@ public:
attach(object, member);
}
/** Attach a static function
/** Attach a static function.
*
* @param function The void static function to attach (default is none)
* @param function The void static function to attach (default is none).
*/
void attach(void (*function)(ContextType context) = NULL) {
_function = function;
_caller = functioncaller;
}
/** Attach a member function
/** Attach a member function.
*
* @param object The object pointer to invoke the member function on (i.e. the this pointer)
* @param function The address of the void member function to attach
* @param object The object pointer to invoke the member function on (the "this" pointer).
* @param function The address of the void member function to attach.
*/
template<typename T>
void attach(T *object, void (T::*member)(ContextType context)) {
@ -69,9 +69,9 @@ public:
_caller = &FunctionPointerWithContext::membercaller<T>;
}
/** Call the attached static or member function; and if there are chained
/** Call the attached static or member function; if there are chained
* FunctionPointers their callbacks are invoked as well.
* @Note: all chained callbacks stack up; so hopefully there won't be too
* @Note: All chained callbacks stack up, so hopefully there won't be too
* many FunctionPointers in a chain. */
void call(ContextType context) {
_caller(this, context);
@ -83,7 +83,7 @@ public:
}
/**
* Setup an external FunctionPointer as a next in the chain of related
* Set up an external FunctionPointer as a next in the chain of related
* callbacks. Invoking call() on the head FunctionPointer will invoke all
* chained callbacks.
*
@ -120,7 +120,7 @@ private:
struct MemberFunctionAndPtr {
/*
* forward declaration of a class and a member function to this class.
* Forward declaration of a class and a member function to this class.
* Because the compiler doesn't know anything about the forwarded member
* function, it will always use the biggest size and the biggest alignment
* that a member function can take for objects of type UndefinedMemberFunction.
@ -136,7 +136,7 @@ private:
};
union {
pvoidfcontext_t _function; /**< static function pointer - NULL if none attached */
pvoidfcontext_t _function; /**< Static function pointer - NULL if none attached */
/**
* object this pointer and pointer to member -
* _memberFunctionAndPointer._object will be NULL if none attached
@ -146,9 +146,9 @@ private:
void (*_caller)(FunctionPointerWithContext*, ContextType);
pFunctionPointerWithContext_t _next; /**< Optional link to make a chain out of functionPointers; this
pFunctionPointerWithContext_t _next; /**< Optional link to make a chain out of functionPointers. This
* allows chaining function pointers without requiring
* external memory to manage the chain. Also refer to
* external memory to manage the chain. Refer to
* 'CallChain' as an alternative. */
};

140
ble/Gap.h
View File

@ -24,7 +24,7 @@
#include "CallChainOfFunctionPointersWithContext.h"
#include "FunctionPointerWithContext.h"
/* Forward declarations for classes which will only be used for pointers or references in the following. */
/* Forward declarations for classes that will only be used for pointers or references in the following. */
class GapAdvertisingParams;
class GapScanningParams;
class GapAdvertisingData;
@ -37,11 +37,11 @@ public:
ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,
ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE
};
typedef enum AddressType_t addr_type_t; /* @Note: deprecated. Use AddressType_t instead. */
typedef enum AddressType_t addr_type_t; /* @Note: Deprecated. Use AddressType_t instead. */
static const unsigned ADDR_LEN = 6;
typedef uint8_t Address_t[ADDR_LEN]; /* 48-bit address, LSB format. */
typedef Address_t address_t; /* @Note: deprecated. Use Address_t instead. */
typedef Address_t address_t; /* @Note: Deprecated. Use Address_t instead. */
enum TimeoutSource_t {
TIMEOUT_SRC_ADVERTISING = 0x00, /**< Advertising timeout. */
@ -52,24 +52,24 @@ public:
/**
* Enumeration for disconnection reasons. The values for these reasons are
* derived from Nordic's implementation; but the reasons are meant to be
* independent of the transport. If you are returned a reason which is not
* covered by this enumeration, then please refer to the underlying
* derived from Nordic's implementation, but the reasons are meant to be
* independent of the transport. If you are returned a reason that is not
* covered by this enumeration, please refer to the underlying
* transport library.
*/
enum DisconnectionReason_t {
CONNECTION_TIMEOUT = 0x08,
REMOTE_USER_TERMINATED_CONNECTION = 0x13,
REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14, /**< Remote Device Terminated Connection due to low resources.*/
REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15, /**< Remote Device Terminated Connection due to power off. */
REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES = 0x14, /**< Remote device terminated connection due to low resources.*/
REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF = 0x15, /**< Remote device terminated connection due to power off. */
LOCAL_HOST_TERMINATED_CONNECTION = 0x16,
CONN_INTERVAL_UNACCEPTABLE = 0x3B,
};
/* Describes the current state of the device (more than one bit can be set) */
/* Describes the current state of the device (more than one bit can be set). */
struct GapState_t {
unsigned advertising : 1; /**< peripheral is currently advertising */
unsigned connected : 1; /**< peripheral is connected to a central */
unsigned advertising : 1; /**< Peripheral is currently advertising. */
unsigned connected : 1; /**< Peripheral is connected to a central. */
};
typedef uint16_t Handle_t; /* Type for connection handle. */
@ -152,7 +152,7 @@ public:
public:
/**
* Set the BTLE MAC address and type. Please note that the address format is
* LSB (least significant byte first). Please refer to Address_t.
* least significant byte first (LSB). Please refer to Address_t.
*
* @return BLE_ERROR_NONE on success.
*/
@ -170,7 +170,7 @@ public:
* @return BLE_ERROR_NONE on success.
*/
virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)typeP;
(void)address;
@ -230,7 +230,7 @@ public:
Gap::AddressType_t peerAddrType,
const ConnectionParams_t *connectionParams,
const GapScanningParams *scanParams) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)peerAddr;
(void)peerAddrType;
(void)connectionParams;
@ -245,7 +245,7 @@ public:
* disconnectionCallback.
*
* @param reason
* The reason for disconnection to be sent back to the peer.
* The reason for disconnection; to be sent back to the peer.
*/
virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason) {
/* avoid compiler warnings about unused variables */
@ -261,15 +261,15 @@ public:
* disconnectionCallback.
*
* @param reason
* The reason for disconnection to be sent back to the peer.
* The reason for disconnection; to be sent back to the peer.
*
* @note: this version of disconnect() doesn't take a connection handle. It
* will work reliably only for stacks which are limited to a single
* @note: This version of disconnect() doesn't take a connection handle. It
* works reliably only for stacks that are limited to a single
* connection. This API should be considered *deprecated* in favour of the
* altertive which takes a connection handle. It will be dropped in the future.
* alternative, which takes a connection handle. It will be dropped in the future.
*/
virtual ble_error_t disconnect(DisconnectionReason_t reason) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)reason;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -288,7 +288,7 @@ public:
* the given structure pointed to by params.
*/
virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)params;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -303,7 +303,7 @@ public:
* The structure containing the desired parameters.
*/
virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)params;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -311,12 +311,12 @@ public:
/**
* Update connection parameters.
* In the central role this will initiate a Link Layer connection parameter update procedure,
* otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
* In the central role this will initiate a Link Layer connection parameter update procedure.
* In the peripheral role, this will send the corresponding L2CAP request and wait for
* the central to perform the procedure.
*
* @param[in] handle
* Connection Handle
* Connection Handle.
* @param[in] params
* Pointer to desired connection parameters. If NULL is provided on a peripheral role,
* the parameters in the PPCP characteristic of the GAP service will be used instead.
@ -335,7 +335,7 @@ public:
* The new value for the device-name. This is a UTF-8 encoded, <b>NULL-terminated</b> string.
*/
virtual ble_error_t setDeviceName(const uint8_t *deviceName) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)deviceName;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -373,7 +373,7 @@ public:
* The new value for the device-appearance.
*/
virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)appearance;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -385,7 +385,7 @@ public:
* The new value for the device-appearance.
*/
virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)appearanceP;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -396,7 +396,7 @@ public:
* @param[in] txPower Radio transmit power in dBm.
*/
virtual ble_error_t setTxPower(int8_t txPower) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)txPower;
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */
@ -411,7 +411,7 @@ public:
* Out parameter to receive the array's size.
*/
virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP) {
/* avoid compiler warnings about unused variables */
/* Avoid compiler warnings about unused variables. */
(void)valueArrayPP;
(void)countP;
@ -430,8 +430,8 @@ protected:
*/
public:
/**
* Returns the current GAP state of the device using a bitmask which
* describes whether the device is advertising and/or connected.
* Returns the current GAP state of the device using a bitmask that
* describes whether the device is advertising or connected.
*/
GapState_t getState(void) const {
return state;
@ -456,7 +456,7 @@ public:
* to ADV_CONNECTABLE_DIRECTED.
*
* @note: Decreasing this value will allow central devices to detect a
* peripheral faster at the expense of more power being used by the radio
* peripheral faster, at the expense of more power being used by the radio
* due to the higher data transmit rate.
*
* @note: This API is now *deprecated* and will be dropped in the future.
@ -468,7 +468,7 @@ public:
* 'interval' argument. That required an explicit conversion from
* milliseconds using Gap::MSEC_TO_GAP_DURATION_UNITS(). This conversion is
* no longer required as the new units are milliseconds. Any application
* code depending on the old semantics would need to be updated accordingly.
* code depending on the old semantics needs to be updated accordingly.
*/
void setAdvertisingInterval(uint16_t interval) {
if (interval == 0) {
@ -492,14 +492,14 @@ public:
* Start advertising.
*/
ble_error_t startAdvertising(void) {
setAdvertisingData(); /* update the underlying stack */
setAdvertisingData(); /* Update the underlying stack. */
return startAdvertising(_advParams);
}
/**
* Reset any advertising payload prepared from prior calls to
* accumulateAdvertisingPayload(). This automatically propagates the re-
* initialized adv payload to the underlying stack.
* initialized advertising payload to the underlying stack.
*/
void clearAdvertisingPayload(void) {
_advPayload.clear();
@ -509,7 +509,7 @@ public:
/**
* Accumulate an AD structure in the advertising payload. Please note that
* the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
* as an additional 31 bytes if the advertising payload proves to be too
* as an additional 31 bytes if the advertising payload is too
* small.
*
* @param[in] flags
@ -529,7 +529,7 @@ public:
/**
* Accumulate an AD structure in the advertising payload. Please note that
* the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
* as an additional 31 bytes if the advertising payload proves to be too
* as an additional 31 bytes if the advertising payload is too
* small.
*
* @param app
@ -549,7 +549,7 @@ public:
/**
* Accumulate an AD structure in the advertising payload. Please note that
* the payload is limited to 31 bytes. The SCAN_RESPONSE message may be used
* as an additional 31 bytes if the advertising payload proves to be too
* as an additional 31 bytes if the advertising payload is too
* small.
*
* @param power
@ -568,11 +568,11 @@ public:
* Accumulate a variable length byte-stream as an AD structure in the
* advertising payload. Please note that the payload is limited to 31 bytes.
* The SCAN_RESPONSE message may be used as an additional 31 bytes if the
* advertising payload proves to be too small.
* advertising payload is too small.
*
* @param type The type which describes the variable length data.
* @param data data bytes.
* @param len length of data.
* @param type The type describing the variable length data.
* @param data Data bytes.
* @param len Length of data.
*/
ble_error_t accumulateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
@ -592,14 +592,14 @@ public:
* matching type and length). Note: the length of the new data must be the
* same as the old one.
*
* @param[in] type The ADV type field which describes the variable length data.
* @param[in] data data bytes.
* @param[in] len length of data.
* @param[in] type The ADV type field describing the variable length data.
* @param[in] data Data bytes.
* @param[in] len Length of data.
*
* @note: If advertisements are enabled, then the update will take effect immediately.
*
* @return BLE_ERROR_NONE if the advertisement payload was updated based on
* a <type, len> match; else an appropriate error.
* a <type, len> match; otherwise, an appropriate error.
*/
ble_error_t updateAdvertisingPayload(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
if (type == GapAdvertisingData::COMPLETE_LOCAL_NAME) {
@ -615,7 +615,7 @@ public:
}
/**
* Setup a particular, user-constructed advertisement payload for the
* Set up a particular, user-constructed advertisement payload for the
* underlying stack. It would be uncommon for this API to be used directly;
* there are other APIs to build an advertisement payload (see above).
*/
@ -636,9 +636,9 @@ public:
* Accumulate a variable length byte-stream as an AD structure in the
* scanResponse payload.
*
* @param[in] type The type which describes the variable length data.
* @param[in] data data bytes.
* @param[in] len length of data.
* @param[in] type The type describing the variable length data.
* @param[in] data Data bytes.
* @param[in] len Length of data.
*/
ble_error_t accumulateScanResponse(GapAdvertisingData::DataType type, const uint8_t *data, uint8_t len) {
ble_error_t rc;
@ -662,13 +662,13 @@ public:
}
/**
* Setup parameters for GAP scanning--i.e. observer mode.
* Set up parameters for GAP scanning (observer mode).
* @param[in] interval
* Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
* @param[in] window
* Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
* @param[in] timeout
* Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout.
* Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout.
* @param[in] activeScanning
* Set to True if active-scanning is required. This is used to fetch the
* scan response from a peer if possible.
@ -701,7 +701,7 @@ public:
}
/**
* Setup the scanInterval parameter for GAP scanning--i.e. observer mode.
* Set up the scanInterval parameter for GAP scanning (observer mode).
* @param[in] interval
* Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s].
*
@ -720,7 +720,7 @@ public:
}
/**
* Setup the scanWindow parameter for GAP scanning--i.e. observer mode.
* Set up the scanWindow parameter for GAP scanning (observer mode).
* @param[in] window
* Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s].
*
@ -752,9 +752,9 @@ public:
}
/**
* Setup parameters for GAP scanning--i.e. observer mode.
* Set up parameters for GAP scanning (observer mode).
* @param[in] timeout
* Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout.
* Scan timeout (in seconds) between 0x0001 and 0xFFFF; 0x0000 disables the timeout.
*
* Once the scanning parameters have been configured, scanning can be
* enabled by using startScan().
@ -777,7 +777,7 @@ public:
}
/**
* Setup parameters for GAP scanning--i.e. observer mode.
* Set up parameters for GAP scanning (observer mode).
* @param[in] activeScanning
* Set to True if active-scanning is required. This is used to fetch the
* scan response from a peer if possible.
@ -804,7 +804,7 @@ public:
* effect.
*
* @param[in] callback
* The application specific callback to be invoked upon
* The application-specific callback to be invoked upon
* receiving every advertisement report. This can be passed in
* as NULL, in which case scanning may not be enabled at all.
*/
@ -838,17 +838,17 @@ public:
/**
* Initialize radio-notification events to be generated from the stack.
* This API doesn't need to be called directly;
* This API doesn't need to be called directly.
*
* Radio Notification is a feature that enables ACTIVE and INACTIVE
* (nACTIVE) signals from the stack that notify the application when the
* radio is in use.
*
* The ACTIVE signal is sent before the Radio Event starts. The nACTIVE
* signal is sent at the end of the Radio Event. These signals can be used
* The ACTIVE signal is sent before the radio event starts. The nACTIVE
* signal is sent at the end of the radio event. These signals can be used
* by the application programmer to synchronize application logic with radio
* activity. For example, the ACTIVE signal can be used to shut off external
* devices to manage peak current drawn during periods when the radio is on,
* devices, to manage peak current drawn during periods when the radio is on,
* or to trigger sensor data collection for transmission in the Radio Event.
*
* @return BLE_ERROR_NONE on successful initialization, otherwise an error code.
@ -878,7 +878,7 @@ public:
}
/**
* Setup a particular, user-constructed set of advertisement parameters for
* Set up a particular, user-constructed set of advertisement parameters for
* the underlying stack. It would be uncommon for this API to be used
* directly; there are other APIs to tweak advertisement parameters
* individually.
@ -890,7 +890,7 @@ public:
/* Event callback handlers. */
public:
/**
* Setup a callback for timeout events. Refer to TimeoutSource_t for
* Set up a callback for timeout events. Refer to TimeoutSource_t for
* possible event types.
*/
void onTimeout(TimeoutEventCallback_t callback) {timeoutCallback = callback;}
@ -918,18 +918,18 @@ public:
* (nACTIVE) signals from the stack that notify the application when the
* radio is in use.
*
* The ACTIVE signal is sent before the Radio Event starts. The nACTIVE
* signal is sent at the end of the Radio Event. These signals can be used
* The ACTIVE signal is sent before the radio event starts. The nACTIVE
* signal is sent at the end of the radio event. These signals can be used
* by the application programmer to synchronize application logic with radio
* activity. For example, the ACTIVE signal can be used to shut off external
* devices to manage peak current drawn during periods when the radio is on,
* devices, to manage peak current drawn during periods when the radio is on,
* or to trigger sensor data collection for transmission in the Radio Event.
*
* @param callback
* The application handler to be invoked in response to a radio
* ACTIVE/INACTIVE event.
*
* or in the other version:
* Or in the other version:
*
* @param tptr
* Pointer to the object of a class defining the member callback
@ -1024,7 +1024,7 @@ protected:
CallChainOfFunctionPointersWithContext<const DisconnectionCallbackParams_t*> disconnectionCallChain;
private:
/* disallow copy and assignment */
/* Disallow copy and assignment. */
Gap(const Gap &);
Gap& operator=(const Gap &);
};

View File

@ -28,10 +28,10 @@
/*!
\brief
This class provides several helper functions to generate properly
formatted GAP Advertising and Scan Response data payloads
formatted GAP Advertising and Scan Response data payloads.
\note
See Bluetooth Specification 4.0 (Vol. 3), Part C, Section 11 and 18
See Bluetooth Specification 4.0 (Vol. 3), Part C, Sections 11 and 18
for further information on Advertising and Scan Response data.
\par Advertising and Scan Response Payloads
@ -40,22 +40,22 @@
Specification v4.0, Vol. 3, Part C, Sections 11 and 18).
\par
Each AD type has it's own standardized 'assigned number', as defined
Each AD type has its own standardized assigned number, as defined
by the Bluetooth SIG:
https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile
\par
For convenience sake, all appropriate AD types have been encapsulated
into GapAdvertisingData::DataType.
For convenience, all appropriate AD types are encapsulated
in GapAdvertisingData::DataType.
\par
Before the AD Types and their payload (if any) can be inserted into
the Advertising or Scan Response frames, they need to be formatted as
follows:
\li \c Record length (1 byte)
\li \c AD Type (1 byte)
\li \c AD payload (optional, only present if record length > 1)
\li \c Record length (1 byte).
\li \c AD Type (1 byte).
\li \c AD payload (optional; only present if record length > 1).
\par
This class takes care of properly formatting the payload, performs
@ -80,7 +80,7 @@ public:
\brief
A list of Advertising Data types commonly used by peripherals.
These AD types are used to describe the capabilities of the
peripheral, and get inserted inside the advertising or scan
peripheral, and are inserted inside the advertising or scan
response payloads.
\par Source
@ -89,29 +89,29 @@ public:
*/
/**********************************************************************/
enum DataType_t {
FLAGS = 0x01, /**< \ref *Flags */
INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit Service IDs */
COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit Service IDs */
INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit Service IDs (not relevant for Bluetooth 4.0) */
INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit Service IDs */
COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit Service IDs */
SHORTENED_LOCAL_NAME = 0x08, /**< Shortened Local Name */
COMPLETE_LOCAL_NAME = 0x09, /**< Complete Local Name */
TX_POWER_LEVEL = 0x0A, /**< TX Power Level (in dBm) */
DEVICE_ID = 0x10, /**< Device ID */
SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave Connection Interval Range */
SERVICE_DATA = 0x16, /**< Service Data */
APPEARANCE = 0x19, /**< \ref Appearance */
ADVERTISING_INTERVAL = 0x1A, /**< Advertising Interval */
MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer Specific Data */
FLAGS = 0x01, /**< \ref *Flags. */
INCOMPLETE_LIST_16BIT_SERVICE_IDS = 0x02, /**< Incomplete list of 16-bit service IDs. */
COMPLETE_LIST_16BIT_SERVICE_IDS = 0x03, /**< Complete list of 16-bit service IDs. */
INCOMPLETE_LIST_32BIT_SERVICE_IDS = 0x04, /**< Incomplete list of 32-bit service IDs (not relevant for Bluetooth 4.0). */
COMPLETE_LIST_32BIT_SERVICE_IDS = 0x05, /**< Complete list of 32-bit service IDs (not relevant for Bluetooth 4.0). */
INCOMPLETE_LIST_128BIT_SERVICE_IDS = 0x06, /**< Incomplete list of 128-bit service IDs. */
COMPLETE_LIST_128BIT_SERVICE_IDS = 0x07, /**< Complete list of 128-bit service IDs. */
SHORTENED_LOCAL_NAME = 0x08, /**< Shortened local name. */
COMPLETE_LOCAL_NAME = 0x09, /**< Complete local name. */
TX_POWER_LEVEL = 0x0A, /**< TX power level (in dBm). */
DEVICE_ID = 0x10, /**< Device ID. */
SLAVE_CONNECTION_INTERVAL_RANGE = 0x12, /**< Slave connection interval range. */
SERVICE_DATA = 0x16, /**< Service data. */
APPEARANCE = 0x19, /**< \ref Appearance. */
ADVERTISING_INTERVAL = 0x1A, /**< Advertising interval. */
MANUFACTURER_SPECIFIC_DATA = 0xFF /**< Manufacturer specific data. */
};
typedef enum DataType_t DataType; /* Deprecated type alias. This may be dropped in a future release. */
/**********************************************************************/
/*!
\brief
A list of values for the FLAGS AD Type
A list of values for the FLAGS AD Type.
\note
You can use more than one value in the FLAGS AD Type (ex.
@ -122,11 +122,11 @@ public:
*/
/**********************************************************************/
enum Flags_t {
LE_LIMITED_DISCOVERABLE = 0x01, /**< *Peripheral device is discoverable for a limited period of time */
LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment */
BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only */
SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only */
SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only */
LE_LIMITED_DISCOVERABLE = 0x01, /**< *Peripheral device is discoverable for a limited period of time. */
LE_GENERAL_DISCOVERABLE = 0x02, /**< Peripheral device is discoverable at any moment. */
BREDR_NOT_SUPPORTED = 0x04, /**< Peripheral device is LE only. */
SIMULTANEOUS_LE_BREDR_C = 0x08, /**< Not relevant - central mode only. */
SIMULTANEOUS_LE_BREDR_H = 0x10 /**< Not relevant - central mode only. */
};
typedef enum Flags_t Flags; /* Deprecated type alias. This may be dropped in a future release. */
@ -134,7 +134,7 @@ public:
/*!
\brief
A list of values for the APPEARANCE AD Type, which describes the
physical shape or appearance of the device
physical shape or appearance of the device.
\par Source
\li \c Bluetooth Core Specification Supplement, Part A, Section 1.12
@ -143,54 +143,54 @@ public:
*/
/**********************************************************************/
enum Appearance_t {
UNKNOWN = 0, /**< Unknown of unspecified appearance type */
GENERIC_PHONE = 64, /**< Generic Phone */
GENERIC_COMPUTER = 128, /**< Generic Computer */
GENERIC_WATCH = 192, /**< Generic Watch */
WATCH_SPORTS_WATCH = 193, /**< Sports Watch */
GENERIC_CLOCK = 256, /**< Generic Clock */
GENERIC_DISPLAY = 320, /**< Generic Display */
GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control */
GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses */
GENERIC_TAG = 512, /**< Generic Tag */
GENERIC_KEYRING = 576, /**< Generic Keyring */
GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player */
GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner */
GENERIC_THERMOMETER = 768, /**< Generic Thermometer */
THERMOMETER_EAR = 769, /**< Ear Thermometer */
GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor */
HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor */
GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure */
BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure */
BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure */
HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID) */
KEYBOARD = 961, /**< Keyboard */
MOUSE = 962, /**< Mouse */
JOYSTICK = 963, /**< Joystick */
GAMEPAD = 964, /**< Gamepad */
DIGITIZER_TABLET = 965, /**< Digitizer Tablet */
CARD_READER = 966, /**< Card Read */
DIGITAL_PEN = 967, /**< Digital Pen */
BARCODE_SCANNER = 968, /**< Barcode Scanner */
GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter */
GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor */
RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor */
RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor */
RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor */
GENERIC_CYCLING = 1152, /**< Generic Cycling */
CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer */
CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Senspr */
CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor */
CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor */
CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor */
PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter */
PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter */
PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter */
OUTDOOR_GENERIC = 5184, /**< Generic Outdoor */
OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device */
OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device */
OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod */
OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod */
UNKNOWN = 0, /**< Unknown or unspecified appearance type. */
GENERIC_PHONE = 64, /**< Generic Phone. */
GENERIC_COMPUTER = 128, /**< Generic Computer. */
GENERIC_WATCH = 192, /**< Generic Watch. */
WATCH_SPORTS_WATCH = 193, /**< Sports Watch. */
GENERIC_CLOCK = 256, /**< Generic Clock. */
GENERIC_DISPLAY = 320, /**< Generic Display. */
GENERIC_REMOTE_CONTROL = 384, /**< Generic Remote Control. */
GENERIC_EYE_GLASSES = 448, /**< Generic Eye Glasses. */
GENERIC_TAG = 512, /**< Generic Tag. */
GENERIC_KEYRING = 576, /**< Generic Keyring. */
GENERIC_MEDIA_PLAYER = 640, /**< Generic Media Player. */
GENERIC_BARCODE_SCANNER = 704, /**< Generic Barcode Scanner. */
GENERIC_THERMOMETER = 768, /**< Generic Thermometer. */
THERMOMETER_EAR = 769, /**< Ear Thermometer. */
GENERIC_HEART_RATE_SENSOR = 832, /**< Generic Heart Rate Sensor. */
HEART_RATE_SENSOR_HEART_RATE_BELT = 833, /**< Belt Heart Rate Sensor. */
GENERIC_BLOOD_PRESSURE = 896, /**< Generic Blood Pressure. */
BLOOD_PRESSURE_ARM = 897, /**< Arm Blood Pressure. */
BLOOD_PRESSURE_WRIST = 898, /**< Wrist Blood Pressure. */
HUMAN_INTERFACE_DEVICE_HID = 960, /**< Human Interface Device (HID). */
KEYBOARD = 961, /**< Keyboard. */
MOUSE = 962, /**< Mouse. */
JOYSTICK = 963, /**< Joystick. */
GAMEPAD = 964, /**< Gamepad. */
DIGITIZER_TABLET = 965, /**< Digitizer Tablet. */
CARD_READER = 966, /**< Card Reader. */
DIGITAL_PEN = 967, /**< Digital Pen. */
BARCODE_SCANNER = 968, /**< Barcode Scanner. */
GENERIC_GLUCOSE_METER = 1024, /**< Generic Glucose Meter. */
GENERIC_RUNNING_WALKING_SENSOR = 1088, /**< Generic Running/Walking Sensor. */
RUNNING_WALKING_SENSOR_IN_SHOE = 1089, /**< In Shoe Running/Walking Sensor. */
RUNNING_WALKING_SENSOR_ON_SHOE = 1090, /**< On Shoe Running/Walking Sensor. */
RUNNING_WALKING_SENSOR_ON_HIP = 1091, /**< On Hip Running/Walking Sensor. */
GENERIC_CYCLING = 1152, /**< Generic Cycling. */
CYCLING_CYCLING_COMPUTER = 1153, /**< Cycling Computer. */
CYCLING_SPEED_SENSOR = 1154, /**< Cycling Speed Sensor. */
CYCLING_CADENCE_SENSOR = 1155, /**< Cycling Cadence Sensor. */
CYCLING_POWER_SENSOR = 1156, /**< Cycling Power Sensor. */
CYCLING_SPEED_AND_CADENCE_SENSOR = 1157, /**< Cycling Speed and Cadence Sensor. */
PULSE_OXIMETER_GENERIC = 3136, /**< Generic Pulse Oximeter. */
PULSE_OXIMETER_FINGERTIP = 3137, /**< Fingertip Pulse Oximeter. */
PULSE_OXIMETER_WRIST_WORN = 3138, /**< Wrist Worn Pulse Oximeter. */
OUTDOOR_GENERIC = 5184, /**< Generic Outdoor. */
OUTDOOR_LOCATION_DISPLAY_DEVICE = 5185, /**< Outdoor Location Display Device. */
OUTDOOR_LOCATION_AND_NAVIGATION_DISPLAY_DEVICE = 5186, /**< Outdoor Location and Navigation Display Device. */
OUTDOOR_LOCATION_POD = 5187, /**< Outdoor Location Pod. */
OUTDOOR_LOCATION_AND_NAVIGATION_POD = 5188 /**< Outdoor Location and Navigation Pod. */
};
typedef enum Appearance_t Appearance; /* Deprecated type alias. This may be dropped in a future release. */
@ -199,34 +199,34 @@ public:
}
/**
* Adds advertising data based on the specified AD type (see DataType)
* Adds advertising data based on the specified AD type (see DataType).
*
* @param advDataType The Advertising 'DataType' to add
* @param payload Pointer to the payload contents
* @param len Size of the payload in bytes
* @param advDataType The Advertising 'DataType' to add.
* @param payload Pointer to the payload contents.
* @param len Size of the payload in bytes.
*
* @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
* advertising buffer to overflow, else BLE_ERROR_NONE.
*/
ble_error_t addData(DataType advDataType, const uint8_t *payload, uint8_t len)
{
/* ToDo: Check if an AD type already exists and if the existing */
/* value is exclusive or not (flags, etc.) */
/* To Do: Check if an AD type already exists and if the existing */
/* value is exclusive or not (flags and so on). */
/* Make sure we don't exceed the 31 byte payload limit */
/* Make sure we don't exceed the 31 byte payload limit. */
if (_payloadLen + len + 2 > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
return BLE_ERROR_BUFFER_OVERFLOW;
}
/* Field length */
/* Field length. */
memset(&_payload[_payloadLen], len + 1, 1);
_payloadLen++;
/* Field ID */
/* Field ID. */
memset(&_payload[_payloadLen], (uint8_t)advDataType, 1);
_payloadLen++;
/* Payload */
/* Payload. */
memcpy(&_payload[_payloadLen], payload, len);
_payloadLen += len;
@ -253,7 +253,7 @@ public:
/* A local struct to describe an ADV field. This definition comes from the Bluetooth Core Spec. (v4.2) Part C, Section 11. */
struct ADVField_t {
uint8_t len; /* Describes the length (in bytes) of the following 'type' and 'bytes'. */
uint8_t len; /* Describes the length (in bytes) of the following type and bytes. */
uint8_t type; /* Should have the same representation of DataType_t (above). */
uint8_t bytes[0]; /* A placeholder for variable length data. */
};
@ -262,23 +262,23 @@ public:
uint8_t byteIndex = 0;
while (byteIndex < _payloadLen) {
ADVField_t *currentADV = (ADVField_t *)&_payload[byteIndex];
if ((currentADV->len == (len + 1)) && /* incoming 'len' only describes the payload, whereas ADV->len describes 'type + payload' */
if ((currentADV->len == (len + 1)) && /* Incoming len only describes the payload, whereas ADV->len describes [type + payload]. */
(currentADV->type == advDataType)) {
memcpy(currentADV->bytes, payload, len);
return BLE_ERROR_NONE;
}
byteIndex += (currentADV->len + 1); /* advance by len+1; '+1' is needed to span the len field itself. */
byteIndex += (currentADV->len + 1); /* Advance by len+1; '+1' is needed to span the len field itself. */
}
return BLE_ERROR_UNSPECIFIED;
}
/**
* Helper function to add APPEARANCE data to the advertising payload
* Helper function to add APPEARANCE data to the advertising payload.
*
* @param appearance
* The APPEARANCE value to add
* The APPEARANCE value to add.
*
* @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
* advertising buffer to overflow, else BLE_ERROR_NONE.
@ -306,18 +306,18 @@ public:
}
/**
* Helper function to add TX_POWER_LEVEL data to the advertising payload
* Helper function to add TX_POWER_LEVEL data to the advertising payload.
*
* @return BLE_ERROR_BUFFER_OVERFLOW if the specified data would cause the
* advertising buffer to overflow, else BLE_ERROR_NONE.
*/
ble_error_t addTxPower(int8_t txPower) {
/* ToDo: Basic error checking to make sure txPower is in range */
/* To Do: Basic error checking to make sure txPower is in range. */
return addData(GapAdvertisingData::TX_POWER_LEVEL, (uint8_t *)&txPower, 1);
}
/**
* Clears the payload and resets the payload length counter
* Clears the payload and resets the payload length counter.
*/
void clear(void) {
memset(&_payload, 0, GAP_ADVERTISING_DATA_MAX_PAYLOAD);
@ -325,21 +325,21 @@ public:
}
/**
* Returns a pointer to the the current payload
* Returns a pointer to the current payload.
*/
const uint8_t *getPayload(void) const {
return _payload;
}
/**
* Returns the current payload length (0..31 bytes)
* Returns the current payload length (0..31 bytes).
*/
uint8_t getPayloadLen(void) const {
return _payloadLen;
}
/**
* Returns the 16-bit appearance value for this device
* Returns the 16-bit appearance value for this device.
*/
uint16_t getAppearance(void) const {
return (uint16_t)_appearance;

View File

@ -20,7 +20,7 @@
/**
* This class provides a wrapper for the core advertising parameters,
* including the advertising type (Connectable Undirected,
* Non Connectable Undirected, etc.), as well as the advertising and
* Non Connectable Undirected and so on), as well as the advertising and
* timeout intervals.
*/
class GapAdvertisingParams {
@ -32,7 +32,7 @@ public:
/*!
* Encapsulates the peripheral advertising modes, which determine how
* the device appears to other central devices in hearing range
* the device appears to other central devices in hearing range.
*/
enum AdvertisingType_t {
ADV_CONNECTABLE_UNDIRECTED, /**< Vol 3, Part C, Section 9.3.4 and Vol 6, Part B, Section 2.3.1.1 */
@ -40,18 +40,18 @@ public:
ADV_SCANNABLE_UNDIRECTED, /**< Include support for Scan Response payloads, see Vol 6, Part B, Section 2.3.1.4 */
ADV_NON_CONNECTABLE_UNDIRECTED /**< Vol 3, Part C, Section 9.3.2 and Vol 6, Part B, Section 2.3.1.3 */
};
typedef enum AdvertisingType_t AdvertisingType; /* deprecated type alias. */
typedef enum AdvertisingType_t AdvertisingType; /* Deprecated type alias. */
public:
GapAdvertisingParams(AdvertisingType_t advType = ADV_CONNECTABLE_UNDIRECTED,
uint16_t interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON,
uint16_t timeout = 0) : _advType(advType), _interval(interval), _timeout(timeout) {
/* Interval checks */
/* Interval checks. */
if (_advType == ADV_CONNECTABLE_DIRECTED) {
/* Interval must be 0 in directed connectable mode */
/* Interval must be 0 in directed connectable mode. */
_interval = 0;
} else if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) {
/* Min interval is slightly larger than in other modes */
/* Min interval is slightly larger than in other modes. */
if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) {
_interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON;
}
@ -59,7 +59,7 @@ public:
_interval = GAP_ADV_PARAMS_INTERVAL_MAX;
}
} else {
/* Stay within interval limits */
/* Stay within interval limits. */
if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN) {
_interval = GAP_ADV_PARAMS_INTERVAL_MIN;
}
@ -68,9 +68,9 @@ public:
}
}
/* Timeout checks */
/* Timeout checks. */
if (timeout) {
/* Stay within timeout limits */
/* Stay within timeout limits. */
if (_timeout > GAP_ADV_PARAMS_TIMEOUT_MAX) {
_timeout = GAP_ADV_PARAMS_TIMEOUT_MAX;
}
@ -90,14 +90,14 @@ public:
}
/**
* @return the advertisement interval (in milliseconds)
* @return the advertisement interval (in milliseconds).
*/
uint16_t getInterval(void) const {
return ADVERTISEMENT_DURATION_UNITS_TO_MS(_interval);
}
/**
* @return the advertisement interval in units advertisement duration units--i.e. 0.625ms units.
* @return the advertisement interval in advertisement duration units (0.625ms units).
*/
uint16_t getIntervalInADVUnits(void) const {
return _interval;
@ -113,8 +113,8 @@ public:
private:
AdvertisingType_t _advType;
uint16_t _interval; /* in ADV duration units (i.e. 0.625ms) */
uint16_t _timeout; /* in seconds */
uint16_t _interval; /* In ADV duration units (i.e. 0.625ms). */
uint16_t _timeout; /* In seconds. */
};
#endif // ifndef __GAP_ADVERTISING_PARAMS_H__

View File

@ -33,13 +33,13 @@ public:
/*!
\brief
Identifies GAP events generated by the radio HW when an event
callback occurs
callback occurs.
*/
/******************************************************************/
typedef enum gapEvent_e {
GAP_EVENT_TIMEOUT = 1, /**< Advertising timed out before a connection was established */
GAP_EVENT_CONNECTED = 2, /**< A connection was established with a central device */
GAP_EVENT_DISCONNECTED = 3 /**< A connection was closed or lost with a central device */
GAP_EVENT_TIMEOUT = 1, /**< Advertising timed out before a connection could be established. */
GAP_EVENT_CONNECTED = 2, /**< A connection was established with a central device. */
GAP_EVENT_DISCONNECTED = 3 /**< A connection was closed or lost with a central device. */
} gapEvent_t;
};

View File

@ -19,10 +19,10 @@
class GapScanningParams {
public:
static const unsigned SCAN_INTERVAL_MIN = 0x0004; /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */
static const unsigned SCAN_INTERVAL_MAX = 0x4000; /**< Maximum Scan interval in 625 us units, i.e. 10.24 s. */
static const unsigned SCAN_WINDOW_MIN = 0x0004; /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */
static const unsigned SCAN_WINDOW_MAX = 0x4000; /**< Maximum Scan window in 625 us units, i.e. 10.24 s. */
static const unsigned SCAN_INTERVAL_MIN = 0x0004; /**< Minimum Scan interval in 625us units - 2.5ms. */
static const unsigned SCAN_INTERVAL_MAX = 0x4000; /**< Maximum Scan interval in 625us units - 10.24s. */
static const unsigned SCAN_WINDOW_MIN = 0x0004; /**< Minimum Scan window in 625us units - 2.5ms. */
static const unsigned SCAN_WINDOW_MAX = 0x4000; /**< Maximum Scan window in 625us units - 10.24s. */
static const unsigned SCAN_TIMEOUT_MIN = 0x0001; /**< Minimum Scan timeout in seconds. */
static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF; /**< Maximum Scan timeout in seconds. */
@ -46,7 +46,7 @@ public:
void setActiveScanning(bool activeScanning);
public:
/* @Note: The following return durations in units of 0.625 ms */
/* @Note: The following return durations in units of 0.625ms */
uint16_t getInterval(void) const {return _interval;}
uint16_t getWindow(void) const {return _window; }
@ -54,13 +54,13 @@ public:
bool getActiveScanning(void) const {return _activeScanning;}
private:
uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms to 10.24s). */
uint16_t _window; /**< Scan window in units of 625us (between 2.5ms to 10.24s). */
uint16_t _timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
bool _activeScanning; /**< obtain not only the advertising data from the peer device, but also their scanResponse if possible. */
uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms and 10.24s). */
uint16_t _window; /**< Scan window in units of 625us (between 2.5ms and 10.24s). */
uint16_t _timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout. */
bool _activeScanning; /**< Obtain the peer device's advertising data and (if possible) scanResponse. */
private:
/* disallow copy constructor */
/* Disallow copy constructor. */
GapScanningParams(const GapScanningParams &);
GapScanningParams& operator =(const GapScanningParams &in);
};

View File

@ -27,16 +27,16 @@ public:
public:
/**
* @brief Creates a new GattAttribute using the specified
* UUID, value length, and inital value
* UUID, value length, and inital value.
*
* @param[in] uuid
* The UUID to use for this attribute
* The UUID to use for this attribute.
* @param[in] valuePtr
* The memory holding the initial value.
* @param[in] initialLen