Lancaster University's fork of the mbed BLE API. Lives on github, https://github.com/lancaster-university/BLE_API
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Revision 1119:7a487d506451, committed 2016-01-11
- Comitter:
- vcoubard
- Date:
- Mon Jan 11 08:52:03 2016 +0000
- Parent:
- 1118:88af68f0226b
- Child:
- 1120:85a019284052
- Commit message:
- Synchronized with git rev 819a0ca7
Author: Andres Amaya Garcia
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.
Changed in this revision
--- a/ble/BLE.h Mon Jan 11 08:52:02 2016 +0000 +++ b/ble/BLE.h Mon Jan 11 08:52:03 2016 +0000 @@ -752,10 +752,10 @@ * 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); }
--- a/ble/BLEProtocol.h Mon Jan 11 08:52:02 2016 +0000 +++ b/ble/BLEProtocol.h Mon Jan 11 08:52:03 2016 +0000 @@ -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 @@ 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 @@ 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() { } }; };
--- a/ble/Gap.h Mon Jan 11 08:52:02 2016 +0000 +++ b/ble/Gap.h Mon Jan 11 08:52:03 2016 +0000 @@ -66,8 +66,8 @@ }; 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 @@ 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 @@ 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: /** * 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 @@ /* 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 @@ 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,