mirror of https://github.com/ARMmbed/mbed-os.git
simplify params to avoid holding state
parent
b9d7e63911
commit
f35ebcc900
|
@ -1145,57 +1145,63 @@ public:
|
||||||
|
|
||||||
/* advertising */
|
/* advertising */
|
||||||
|
|
||||||
uint8_t getMaxAdvertisingSetNumber() {
|
virtual uint8_t getMaxAdvertisingSetNumber() {
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getMaxAdvertisingDataLength() {
|
virtual uint8_t getMaxAdvertisingDataLength() {
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return 0x1F;
|
return 0x1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_error_t createAdvertisingSet(AdvHandle_t* handle) {
|
virtual ble_error_t createAdvertisingSet(AdvHandle_t* handle) {
|
||||||
(void) handle;
|
(void) handle;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_error_t destroyAdvertisingSet(AdvHandle_t handle) {
|
virtual ble_error_t destroyAdvertisingSet(AdvHandle_t handle) {
|
||||||
(void) handle;
|
(void) handle;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
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) handle;
|
||||||
(void) params;
|
(void) params;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
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) handle;
|
||||||
(void) params;
|
(void) params;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
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) handle;
|
||||||
(void) payload;
|
(void) payload;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
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) handle;
|
||||||
(void) response;
|
(void) response;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
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 */
|
/* deprecation compatibility */
|
||||||
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
|
@ -1211,13 +1217,13 @@ public:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_error_t stopAdvertising(AdvHandle_t handle) {
|
virtual ble_error_t stopAdvertising(AdvHandle_t handle) {
|
||||||
(void) handle;
|
(void) handle;
|
||||||
/* Requesting action from porter(s): override this API if this capability is supported. */
|
/* Requesting action from porter(s): override this API if this capability is supported. */
|
||||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAdvertisingActive(AdvHandle_t handle) const {
|
virtual bool isAdvertisingActive(AdvHandle_t handle) const {
|
||||||
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
if (handle != LEGACY_ADVERTISING_HANDLE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,29 +257,47 @@ private:
|
||||||
uint16_t _timeout;
|
uint16_t _timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GapExtendedAdvertisingParams : public GapAdvertisingParams {
|
class GapExtendedAdvertisingParams {
|
||||||
GapExtendedAdvertisingParams()
|
GapExtendedAdvertisingParams() :
|
||||||
: GapAdvertisingParams(),
|
_advType(ble::EXT_ADV_CONNECTABLE_UNDIRECTED),
|
||||||
_minInterval(0),
|
_minInterval(0),
|
||||||
_maxInterval(0),
|
_maxInterval(0),
|
||||||
_maxDuration(0),
|
_maxDuration(0),
|
||||||
_peerAddressType(),
|
_peerAddressType(),
|
||||||
_ownAddressType(),
|
_ownAddressType(),
|
||||||
_policy(ble::ADV_POLICY_IGNORE_WHITELIST),
|
_policy(ble::ADV_POLICY_IGNORE_WHITELIST),
|
||||||
_primaryPhy(ble::phy_t::LE_1M),
|
_primaryPhy(ble::phy_t::LE_1M),
|
||||||
_secondaryPhy(ble::phy_t::LE_1M),
|
_secondaryPhy(ble::phy_t::LE_1M),
|
||||||
_peerAddress(),
|
_peerAddress(),
|
||||||
_maxEvents(0),
|
_maxEvents(0),
|
||||||
_txPower(0),
|
_txPower(0),
|
||||||
_eventNumber(0),
|
_eventNumber(0),
|
||||||
_channel37(1),
|
_channel37(1),
|
||||||
_channel38(1),
|
_channel38(1),
|
||||||
_channel39(1),
|
_channel39(1),
|
||||||
_anonymous(0),
|
_anonymous(0),
|
||||||
_notifyOnScan(1) {
|
_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() {
|
bool getAnonymousAdvertising() {
|
||||||
return _anonymous;
|
return _anonymous;
|
||||||
}
|
}
|
||||||
|
@ -420,34 +438,34 @@ class GapExtendedAdvertisingParams : public GapAdvertisingParams {
|
||||||
_notifyOnScan = enable;
|
_notifyOnScan = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
ble_error_t getDuration(
|
/**/
|
||||||
uint32_t *maxDuration /* ms */,
|
|
||||||
uint8_t *maxEvents
|
uint32_t getMinPrimaryAdvertisingInterval() const {
|
||||||
) {
|
return _minInterval;
|
||||||
if (!maxDuration || !maxEvents) {
|
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
|
||||||
}
|
|
||||||
return BLE_ERROR_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDuration(
|
uint32_t getMinPrimaryAdvertisingInterval() const {
|
||||||
uint32_t maxDuration /* ms */,
|
return _maxInterval;
|
||||||
uint8_t maxEvents = 0
|
|
||||||
) {
|
|
||||||
_maxDuration = maxDuration;
|
|
||||||
_maxEvents = maxEvents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BLEProtocol::AddressBytes_t* getPeerAddress() {
|
||||||
|
return _peerAddress;
|
||||||
|
};
|
||||||
|
|
||||||
|
ble::peer_address_type_t getPeerAddressType() {
|
||||||
|
return _peerAddressType;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ble::advertising_type_t _advType;
|
||||||
uint32_t _minInterval;
|
uint32_t _minInterval;
|
||||||
uint32_t _maxInterval;
|
uint32_t _maxInterval;
|
||||||
uint32_t _maxDuration;
|
|
||||||
ble::peer_address_type_t _peerAddressType;
|
ble::peer_address_type_t _peerAddressType;
|
||||||
BLEProtocol::AddressType_t _ownAddressType;
|
BLEProtocol::AddressType_t _ownAddressType;
|
||||||
ble::advertising_policy_mode_t _policy;
|
ble::advertising_policy_mode_t _policy;
|
||||||
ble::phy_t _primaryPhy;
|
ble::phy_t _primaryPhy;
|
||||||
ble::phy_t _secondaryPhy;
|
ble::phy_t _secondaryPhy;
|
||||||
BLEProtocol::AddressBytes_t _peerAddress;
|
BLEProtocol::AddressBytes_t _peerAddress;
|
||||||
uint8_t _maxEvents;
|
|
||||||
uint8_t _txPower;
|
uint8_t _txPower;
|
||||||
uint8_t _eventNumber;
|
uint8_t _eventNumber;
|
||||||
uint8_t _channel37:1;
|
uint8_t _channel37:1;
|
||||||
|
|
Loading…
Reference in New Issue