simplify params to avoid holding state

pull/8738/head
paul-szczepanek-arm 2018-11-07 11:12:47 +00:00 committed by Vincent Coubard
parent b9d7e63911
commit f35ebcc900
2 changed files with 71 additions and 47 deletions

View File

@ -1145,57 +1145,63 @@ public:
/* advertising */
uint8_t getMaxAdvertisingSetNumber() {
virtual uint8_t getMaxAdvertisingSetNumber() {
/* Requesting action from porter(s): override this API if this capability is supported. */
return 1;
}
uint8_t getMaxAdvertisingDataLength() {
virtual uint8_t getMaxAdvertisingDataLength() {
/* Requesting action from porter(s): override this API if this capability is supported. */
return 0x1F;
}
ble_error_t createAdvertisingSet(AdvHandle_t* handle) {
virtual ble_error_t createAdvertisingSet(AdvHandle_t* handle) {
(void) handle;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t destroyAdvertisingSet(AdvHandle_t handle) {
virtual ble_error_t destroyAdvertisingSet(AdvHandle_t handle) {
(void) handle;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t setAdvertisingParams(AdvHandle_t handle, const GapAdvertisingParams* params) {
virtual ble_error_t setAdvertisingParams(AdvHandle_t handle, const GapAdvertisingParams* params) {
(void) handle;
(void) params;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t setAdvertisingParams(AdvHandle_t handle, const GapExtendedAdvertisingParams* params) {
virtual ble_error_t setAdvertisingParams(AdvHandle_t handle, const GapExtendedAdvertisingParams* params) {
(void) handle;
(void) params;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t setAdvertisingPayload(AdvHandle_t handle, const GapAdvertisingData* payload) {
virtual ble_error_t setAdvertisingPayload(AdvHandle_t handle, const GapAdvertisingData* payload) {
(void) handle;
(void) payload;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t setAdvertisingScanResponse(AdvHandle_t handle, const GapAdvertisingData* response) {
virtual ble_error_t setAdvertisingScanResponse(AdvHandle_t handle, const GapAdvertisingData* response) {
(void) handle;
(void) response;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t startAdvertising(AdvHandle_t handle) {
virtual ble_error_t startAdvertising(
AdvHandle_t handle,
uint8_t maxEvents = 0,
uint32_t maxDuration = 0
) {
(void) maxEvents;
(void) maxDuration;
/* deprecation compatibility */
if (handle != LEGACY_ADVERTISING_HANDLE) {
return BLE_ERROR_NOT_IMPLEMENTED;
@ -1211,13 +1217,13 @@ public:
return status;
}
ble_error_t stopAdvertising(AdvHandle_t handle) {
virtual ble_error_t stopAdvertising(AdvHandle_t handle) {
(void) handle;
/* Requesting action from porter(s): override this API if this capability is supported. */
return BLE_ERROR_NOT_IMPLEMENTED;
}
bool isAdvertisingActive(AdvHandle_t handle) const {
virtual bool isAdvertisingActive(AdvHandle_t handle) const {
if (handle != LEGACY_ADVERTISING_HANDLE) {
return false;
}

View File

@ -257,29 +257,47 @@ private:
uint16_t _timeout;
};
class GapExtendedAdvertisingParams : public GapAdvertisingParams {
GapExtendedAdvertisingParams()
: GapAdvertisingParams(),
_minInterval(0),
_maxInterval(0),
_maxDuration(0),
_peerAddressType(),
_ownAddressType(),
_policy(ble::ADV_POLICY_IGNORE_WHITELIST),
_primaryPhy(ble::phy_t::LE_1M),
_secondaryPhy(ble::phy_t::LE_1M),
_peerAddress(),
_maxEvents(0),
_txPower(0),
_eventNumber(0),
_channel37(1),
_channel38(1),
_channel39(1),
_anonymous(0),
_notifyOnScan(1) {
class GapExtendedAdvertisingParams {
GapExtendedAdvertisingParams() :
_advType(ble::EXT_ADV_CONNECTABLE_UNDIRECTED),
_minInterval(0),
_maxInterval(0),
_maxDuration(0),
_peerAddressType(),
_ownAddressType(),
_policy(ble::ADV_POLICY_IGNORE_WHITELIST),
_primaryPhy(ble::phy_t::LE_1M),
_secondaryPhy(ble::phy_t::LE_1M),
_peerAddress(),
_maxEvents(0),
_txPower(0),
_eventNumber(0),
_channel37(1),
_channel38(1),
_channel39(1),
_anonymous(0),
_notifyOnScan(1) {
}
/**
* Update the advertising type.
*
* @param[in] newAdvType The new advertising type.
*/
void setAdvertisingType(ble::advertising_type_t newAdvType) {
_advType = newAdvType;
}
/**
* Return advertising type.
*
* @return Advertising type.
*/
ble::advertising_type_t setAdvertisingType() {
return _advType;
}
bool getAnonymousAdvertising() {
return _anonymous;
}
@ -420,34 +438,34 @@ class GapExtendedAdvertisingParams : public GapAdvertisingParams {
_notifyOnScan = enable;
}
ble_error_t getDuration(
uint32_t *maxDuration /* ms */,
uint8_t *maxEvents
) {
if (!maxDuration || !maxEvents) {
return BLE_ERROR_INVALID_PARAM;
}
return BLE_ERROR_NONE;
/**/
uint32_t getMinPrimaryAdvertisingInterval() const {
return _minInterval;
}
void setDuration(
uint32_t maxDuration /* ms */,
uint8_t maxEvents = 0
) {
_maxDuration = maxDuration;
_maxEvents = maxEvents;
uint32_t getMinPrimaryAdvertisingInterval() const {
return _maxInterval;
}
BLEProtocol::AddressBytes_t* getPeerAddress() {
return _peerAddress;
};
ble::peer_address_type_t getPeerAddressType() {
return _peerAddressType;
};
private:
ble::advertising_type_t _advType;
uint32_t _minInterval;
uint32_t _maxInterval;
uint32_t _maxDuration;
ble::peer_address_type_t _peerAddressType;
BLEProtocol::AddressType_t _ownAddressType;
ble::advertising_policy_mode_t _policy;
ble::phy_t _primaryPhy;
ble::phy_t _secondaryPhy;
BLEProtocol::AddressBytes_t _peerAddress;
uint8_t _maxEvents;
uint8_t _txPower;
uint8_t _eventNumber;
uint8_t _channel37:1;