Fix comments and add Address_t empty constructor

Add an empty constructor to BLEProtocol::Address_t and fixed comments with
regards to BLEProtocol::Address_t.
master
Andres Amaya Garcia 7 years ago
parent 42a202e047
commit 819a0ca799

@ -752,10 +752,10 @@ public:
* ble.connect(...) should be replaced with
* ble.gap().connect(...).
*/
ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr,
BLEProtocol::AddressType_t peerAddrType = BLEProtocol::AddressType::RANDOM_STATIC,
const Gap::ConnectionParams_t *connectionParams = NULL,
const GapScanningParams *scanParams = NULL) {
ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr,
BLEProtocol::AddressType_t peerAddrType = BLEProtocol::AddressType::RANDOM_STATIC,
const Gap::ConnectionParams_t *connectionParams = NULL,
const GapScanningParams *scanParams = NULL) {
return gap().connect(peerAddr, peerAddrType, connectionParams, scanParams);
}

@ -26,15 +26,19 @@
* A common namespace for types and constants used everywhere in BLE API.
*/
namespace BLEProtocol {
/**< Address-type for Protocol addresses. */
struct AddressType { /* Adding a struct to encapsulate the contained enumeration
* prevents polluting the BLEProtocol namespace with the
* enumerated values. It also allows type-aliases for the
* enumeration while retaining the enumerated values. i.e.
*
* doing:
* typedef AddressType_t AliasedType_t;
* would allow the use of AliasedType_t::PUBLIC in code. */
/**<
* A simple container for the enumeration of address-types for Protocol addresses.
*
* Adding a struct to encapsulate the contained enumeration prevents
* polluting the BLEProtocol namespace with the enumerated values. It also
* allows type-aliases for the enumeration while retaining the enumerated
* values. i.e. doing:
* typedef AddressType AliasedType;
*
* would allow the use of AliasedType::PUBLIC in code.
*/
struct AddressType {
/**< Address-types for Protocol addresses. */
enum Type {
PUBLIC = 0,
RANDOM_STATIC,
@ -42,10 +46,10 @@ namespace BLEProtocol {
RANDOM_PRIVATE_NON_RESOLVABLE
};
};
typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */
typedef AddressType::Type AddressType_t; /**< Alias for AddressType::Type */
static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */
typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */
static const size_t ADDR_LEN = 6; /**< Length (in octets) of the BLE MAC address. */
typedef uint8_t AddressBytes_t[ADDR_LEN]; /**< 48-bit address, in LSB format. */
/**
* BLE address. It contains an address-type (@ref AddressType_t) and bytes (@ref AddressBytes_t).
@ -58,16 +62,7 @@ namespace BLEProtocol {
std::copy(addressIn, addressIn + ADDR_LEN, address);
}
Address_t(void) : type(AddressType::PUBLIC), address() {
}
bool operator<(const Address_t &rhs) const {
if (type < rhs.type) {
return true;
} else if (type > rhs.type) {
return false;
}
return (memcmp(address, rhs.address, sizeof(AddressBytes_t)) < 0) ? true : false;
Address_t() : type(), address() {
}
};
};

@ -66,8 +66,8 @@ public:
};
static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN; /**< Length (in octets) of the BLE MAC address. */
typedef BLEProtocol::AddressBytes_t Address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */
typedef BLEProtocol::AddressBytes_t address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */
typedef BLEProtocol::AddressBytes_t Address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::AddressBytes_t instead. */
typedef BLEProtocol::AddressBytes_t address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::AddressBytes_t instead. */
public:
enum TimeoutSource_t {
@ -141,9 +141,9 @@ public:
typedef uint16_t Handle_t; /* Type for connection handle. */
typedef struct {
uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t slaveLatency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t slaveLatency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
} ConnectionParams_t;
@ -166,9 +166,9 @@ public:
Handle_t handle;
Role_t role;
BLEProtocol::AddressType_t peerAddrType;
BLEProtocol::AddressBytes_t peerAddr;
BLEProtocol::AddressBytes_t peerAddr;
BLEProtocol::AddressType_t ownAddrType;
BLEProtocol::AddressBytes_t ownAddr;
BLEProtocol::AddressBytes_t ownAddr;
const ConnectionParams_t *connectionParams;
ConnectionCallbackParams_t(Handle_t handleIn,
@ -226,7 +226,7 @@ public:
public:
/**
* Set the BTLE MAC address and type. Please note that the address format is
* least significant byte first (LSB). Please refer to BLEProtocol::Address_t.
* least significant byte first (LSB). Please refer to BLEProtocol::AddressBytes_t.
*
* @return BLE_ERROR_NONE on success.
*/
@ -1291,13 +1291,13 @@ protected:
/* Entry points for the underlying stack to report events back to the user. */
public:
void processConnectionEvent(Handle_t handle,
Role_t role,
BLEProtocol::AddressType_t peerAddrType,
void processConnectionEvent(Handle_t handle,
Role_t role,
BLEProtocol::AddressType_t peerAddrType,
const BLEProtocol::AddressBytes_t peerAddr,
BLEProtocol::AddressType_t ownAddrType,
BLEProtocol::AddressType_t ownAddrType,
const BLEProtocol::AddressBytes_t ownAddr,
const ConnectionParams_t *connectionParams) {
const ConnectionParams_t *connectionParams) {
state.connected = 1;
ConnectionCallbackParams_t callbackParams(handle, role, peerAddrType, peerAddr, ownAddrType, ownAddr, connectionParams);
connectionCallChain.call(&callbackParams);
@ -1309,7 +1309,7 @@ public:
disconnectionCallChain.call(&callbackParams);
}
void processAdvertisementReport(const BLEProtocol::AddressBytes_t peerAddr,
void processAdvertisementReport(const BLEProtocol::AddressBytes_t peerAddr,
int8_t rssi,
bool isScanResponse,
GapAdvertisingParams::AdvertisingType_t type,

Loading…
Cancel
Save