fka mod
Fork of BLE_API by
Diff: ble/Gap.h
- Revision:
- 1115:82d4a8a56d91
- Parent:
- 1111:30326e58c830
- Child:
- 1116:9cb51490b3f7
diff -r 04913cb9706e -r 82d4a8a56d91 ble/Gap.h --- a/ble/Gap.h Mon Jan 11 08:52:00 2016 +0000 +++ b/ble/Gap.h Mon Jan 11 08:52:01 2016 +0000 @@ -24,7 +24,7 @@ #include "GapEvents.h" #include "CallChainOfFunctionPointersWithContext.h" #include "FunctionPointerWithContext.h" -#include "deprecate.h" +#include <set> /* Forward declarations for classes that will only be used for pointers or references in the following. */ class GapAdvertisingParams; @@ -52,13 +52,13 @@ /** * Address-type for BLEProtocol addresses. - * \deprecated: Use BLEProtocol::AddressType_t instead. + * @note: deprecated. Use BLEProtocol::AddressType_t instead. * * DEPRECATION ALERT: The following constants have been left in their * deprecated state to transparenly support existing applications which may * have used Gap::ADDR_TYPE_*. */ - enum DeprecatedAddressType_t { + enum { ADDR_TYPE_PUBLIC = BLEProtocol::AddressType::PUBLIC, ADDR_TYPE_RANDOM_STATIC = BLEProtocol::AddressType::RANDOM_STATIC, ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE = BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE, @@ -66,8 +66,8 @@ }; static const unsigned ADDR_LEN = BLEProtocol::ADDR_LEN; /**< Length (in octets) of the BLE MAC address. */ - typedef BLEProtocol::Address_t Address_t; /**< 48-bit address, LSB format. @Note: Deprecated. Use BLEProtocol::Address_t instead. */ - typedef BLEProtocol::Address_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::Address_t instead. */ public: enum TimeoutSource_t { @@ -114,7 +114,7 @@ }; struct AdvertisementCallbackParams_t { - BLEProtocol::Address_t peerAddr; + BLEProtocol::AddressBytes_t peerAddr; int8_t rssi; bool isScanResponse; GapAdvertisingParams::AdvertisingType_t type; @@ -127,9 +127,9 @@ Handle_t handle; Role_t role; BLEProtocol::AddressType_t peerAddrType; - BLEProtocol::Address_t peerAddr; + BLEProtocol::AddressBytes_t peerAddr; BLEProtocol::AddressType_t ownAddrType; - BLEProtocol::Address_t ownAddr; + BLEProtocol::AddressBytes_t ownAddr; const ConnectionParams_t *connectionParams; ConnectionCallbackParams_t(Handle_t handleIn, @@ -191,7 +191,7 @@ * * @return BLE_ERROR_NONE on success. */ - virtual ble_error_t setAddress(BLEProtocol::AddressType_t type, const BLEProtocol::Address_t address) { + virtual ble_error_t setAddress(BLEProtocol::AddressType_t type, const BLEProtocol::AddressBytes_t address) { /* avoid compiler warnings about unused variables */ (void)type; (void)address; @@ -204,7 +204,7 @@ * * @return BLE_ERROR_NONE on success. */ - virtual ble_error_t getAddress(BLEProtocol::AddressType_t *typeP, BLEProtocol::Address_t address) { + virtual ble_error_t getAddress(BLEProtocol::AddressType_t *typeP, BLEProtocol::AddressBytes_t address) { /* Avoid compiler warnings about unused variables. */ (void)typeP; (void)address; @@ -263,7 +263,7 @@ * successfully. The connectionCallChain (if set) will be invoked upon * a connection event. */ - virtual ble_error_t connect(const BLEProtocol::Address_t peerAddr, + virtual ble_error_t connect(const BLEProtocol::AddressBytes_t peerAddr, BLEProtocol::AddressType_t peerAddrType, const ConnectionParams_t *connectionParams, const GapScanningParams *scanParams) { @@ -277,23 +277,6 @@ } /** - * Create a connection (GAP Link Establishment). - * - * \deprecated: This funtion overloads Gap::connect(const BLEProtocol::Address_t peerAddr, - BLEProtocol::AddressType_t peerAddrType, - const ConnectionParams_t *connectionParams, - const GapScanningParams *scanParams) - * to maintain backward compatibility for change from Gap::AddressType_t to BLEProtocol::AddressType_t - */ - ble_error_t connect(const BLEProtocol::Address_t peerAddr, - DeprecatedAddressType_t peerAddrType, - const ConnectionParams_t *connectionParams, - const GapScanningParams *scanParams) - __deprecated_message("Gap::DeprecatedAddressType_t is deprecated, use BLEProtocol::AddressType_t instead") { - return connect(peerAddr, (BLEProtocol::AddressType_t) peerAddrType, connectionParams, scanParams); - } - - /** * This call initiates the disconnection procedure, and its completion will * be communicated to the application with an invocation of the * disconnectionCallback. @@ -1135,9 +1118,9 @@ void processConnectionEvent(Handle_t handle, Role_t role, BLEProtocol::AddressType_t peerAddrType, - const BLEProtocol::Address_t peerAddr, + const BLEProtocol::AddressBytes_t peerAddr, BLEProtocol::AddressType_t ownAddrType, - const BLEProtocol::Address_t ownAddr, + const BLEProtocol::AddressBytes_t ownAddr, const ConnectionParams_t *connectionParams) { state.connected = 1; ConnectionCallbackParams_t callbackParams(handle, role, peerAddrType, peerAddr, ownAddrType, ownAddr, connectionParams); @@ -1150,7 +1133,7 @@ disconnectionCallChain.call(&callbackParams); } - void processAdvertisementReport(const BLEProtocol::Address_t peerAddr, + void processAdvertisementReport(const BLEProtocol::AddressBytes_t peerAddr, int8_t rssi, bool isScanResponse, GapAdvertisingParams::AdvertisingType_t type, @@ -1172,6 +1155,76 @@ } } +/////////////////////////////////////////////////// +public: + enum AdvertisingPolicyMode_t { + ADV_POLICY_IGNORE_WHITELIST = 0, + ADV_POLICY_FILTER_SCAN_REQS = 1, + ADV_POLICY_FILTER_CONN_REQS = 2, + ADV_POLICY_FILTER_ALL_REQS = 3, + }; + + enum ScanningPolicyMode_t { + SCAN_POLICY_IGNORE_WHITELIST = 0, + SCAN_POLICY_FILTER_ALL_ADV = 1, + }; + + enum InitiatorPolicyMode_t { + INIT_POLICY_IGNORE_WHITELIST = 0, + INIT_POLICY_FILTER_ALL_ADV = 1, + }; + + // Things to be implemented by the porter + virtual int8_t getMaxWhitelistSize(void) const + { + return BLE_ERROR_NOT_IMPLEMENTED; + } + + virtual ble_error_t getWhitelist(std::set<BLEProtocol::Address_t> &whitelist) const + { + (void) whitelist; + return BLE_ERROR_NOT_IMPLEMENTED; + } + + virtual ble_error_t setWhitelist(std::set<BLEProtocol::Address_t> whitelist) + { + (void) whitelist; + return BLE_ERROR_NOT_IMPLEMENTED; + } + + // Accessors + virtual void setAdvertisingPolicyMode(AdvertisingPolicyMode_t mode) + { + (void) mode; + } + + virtual void setScanningPolicyMode(ScanningPolicyMode_t mode) + { + (void) mode; + } + + virtual void setInitiatorPolicyMode(InitiatorPolicyMode_t mode) + { + (void) mode; + } + + virtual AdvertisingPolicyMode_t getAdvertisingPolicyMode(void) const + { + return ADV_POLICY_IGNORE_WHITELIST; + } + + virtual ScanningPolicyMode_t getScanningPolicyMode(void) const + { + return SCAN_POLICY_IGNORE_WHITELIST; + } + + virtual InitiatorPolicyMode_t getInitiatorPolicyMode(void) const + { + return INIT_POLICY_IGNORE_WHITELIST; + } + +/////////////////////////////////////////////////// + protected: GapAdvertisingParams _advParams; GapAdvertisingData _advPayload;