Merge pull request #8904 from pan-/ble-extended-advertising-fixes

Ble extended advertising fixes
pull/8958/head
Martin Kojtal 2018-12-04 09:50:36 +01:00 committed by GitHub
commit c1c94c83c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 57 additions and 57 deletions

View File

@ -87,7 +87,7 @@ public:
element_t next()
{
element_t element = {
(ble::adv_data_type_t::type) data[TYPE_INDEX],
(ble::adv_data_type_t::type) data[position + TYPE_INDEX],
data.subspan(position + VALUE_INDEX, current_length() - (TYPE_SIZE))
};

View File

@ -135,7 +135,7 @@ public:
_minInterval(minInterval),
_maxInterval(maxInterval),
_peerAddressType(target_peer_address_type_t::PUBLIC),
_ownAddressType(own_address_type_t::PUBLIC),
_ownAddressType(own_address_type_t::RANDOM),
_policy(advertising_filter_policy_t::NO_FILTER),
_primaryPhy(phy_t::LE_1M),
_secondaryPhy(phy_t::LE_1M),

View File

@ -145,10 +145,10 @@ public:
phy_t phy = phy_t::LE_1M,
scan_interval_t scanInterval = scan_interval_t::min(),
scan_window_t scanWindow = scan_window_t::min(),
conn_interval_t minConnectionInterval = conn_interval_t::min(),
conn_interval_t maxConnectionInterval = conn_interval_t::max(),
conn_interval_t minConnectionInterval = conn_interval_t(50),
conn_interval_t maxConnectionInterval = conn_interval_t(100),
slave_latency_t slaveLatency = slave_latency_t::min(),
supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t::max(),
supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t(100),
conn_event_length_t minEventLength = conn_event_length_t::min(),
conn_event_length_t maxEventLength = conn_event_length_t::max()
);
@ -215,7 +215,7 @@ public:
*
* @return A reference to this.
*/
ConnectionParameters &setFilterPolicy(initiator_filter_policy_t filterPolicy)
ConnectionParameters &setFilter(initiator_filter_policy_t filterPolicy)
{
_filterPolicy = filterPolicy;
@ -282,7 +282,7 @@ public:
*
* @return The initiator policy.
*/
initiator_filter_policy_t getFilterPolicy() const
initiator_filter_policy_t getFilter() const
{
return _filterPolicy;
}

View File

@ -152,7 +152,7 @@ struct AdvertisingReportEvent {
}
/** Get payload. */
const mbed::Span<const uint8_t> &getAdvertisingData() const
const mbed::Span<const uint8_t> &getPayload() const
{
return advertisingData;
}
@ -630,10 +630,10 @@ private:
*
* @see ble::Gap::EventHandler::onDisconnectionComplete().
*/
struct DisconnectionEvent {
struct DisconnectionCompleteEvent {
#if !defined(DOXYGEN_ONLY)
DisconnectionEvent(
DisconnectionCompleteEvent(
connection_handle_t connectionHandle,
const disconnection_reason_t &reason
) :

View File

@ -427,7 +427,7 @@ public:
*
* @see disconnect()
*/
virtual void onDisconnectionComplete(const DisconnectionEvent &event)
virtual void onDisconnectionComplete(const DisconnectionCompleteEvent &event)
{
}
@ -536,7 +536,7 @@ public:
*
* @return Maximum advertising data length supported.
*/
virtual uint8_t getMaxAdvertisingDataLength();
virtual uint16_t getMaxAdvertisingDataLength();
/** Create an advertising set and apply the passed in parameters. The handle returned
* by this function must be used for all other calls that accept an advertising handle.
@ -711,8 +711,8 @@ public:
/** Start scanning.
*
* @param filtering Filtering policy.
* @param duration How long to scan for. Special value 0 means scan forever.
* @param filtering Filtering policy.
* @param period How long to scan for in single period. If the period is 0 and duration
* is nonzero the scan will last for single duration.
*
@ -726,8 +726,8 @@ public:
* @see EventHandler::onScanTimeout when scanning timeout.
*/
virtual ble_error_t startScan(
duplicates_filter_t filtering = duplicates_filter_t::DISABLE,
scan_duration_t duration = scan_duration_t::forever(),
duplicates_filter_t filtering = duplicates_filter_t::DISABLE,
scan_period_t period = scan_period_t(0)
);

View File

@ -121,7 +121,7 @@ public:
scan_window_t scan_interval = scan_interval_t::min(),
scan_interval_t scan_window = scan_window_t::min(),
bool active_scanning = false,
own_address_type_t own_address_type = own_address_type_t::PUBLIC,
own_address_type_t own_address_type = own_address_type_t::RANDOM,
scanning_filter_policy_t scanning_filter_policy = scanning_filter_policy_t::NO_FILTER
) :
own_address_type(own_address_type),

View File

@ -891,6 +891,9 @@ struct peripheral_privacy_configuration_t {
PERFORM_AUTHENTICATION_PROCEDURE
};
MBED_DEPRECATED_SINCE("mbed-os-5.11", "Use resolution_strategy_t instead.")
typedef resolution_strategy_t ResolutionStrategy;
/**
* Connection strategy to use when a connection request contains a
* private resolvable address.
@ -941,6 +944,9 @@ struct central_privay_configuration_t {
RESOLVE_AND_FILTER
};
MBED_DEPRECATED_SINCE("mbed-os-5.11", "Use resolution_strategy_t instead.")
typedef resolution_strategy_t ResolutionStrategy;
/**
* Resolution strategy applied to advertising packets received by the
* local device.

View File

@ -90,7 +90,7 @@ public:
/** @copydoc Gap::getMaxAdvertisingDataLength
*/
virtual uint8_t getMaxAdvertisingDataLength();
virtual uint16_t getMaxAdvertisingDataLength();
/** @copydoc Gap::createAdvertisingSet
*/
@ -175,8 +175,8 @@ public:
/** @copydoc Gap::startScan
*/
virtual ble_error_t startScan(
duplicates_filter_t filtering,
scan_duration_t duration,
duplicates_filter_t filtering,
scan_period_t period
);

View File

@ -17,6 +17,7 @@
#include <stdio.h>
#include "ble/BLE.h"
#include "ble/BLEInstanceBase.h"
#include "platform/mbed_critical.h"
#if defined(TARGET_OTA_ENABLED)
#include "ble/services/DFUService.h"
@ -299,16 +300,19 @@ void BLE::waitForEvent(void)
void BLE::processEvents()
{
core_util_critical_section_enter();
if (event_signaled == false) {
core_util_critical_section_exit();
return;
}
event_signaled = false;
core_util_critical_section_exit();
if (!transport) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}
event_signaled = false;
transport->processEvents();
}
@ -328,11 +332,14 @@ void BLE::onEventsToProcess(const BLE::OnEventsToProcessCallback_t& callback)
void BLE::signalEventsToProcess()
{
core_util_critical_section_enter();
if (event_signaled == true) {
core_util_critical_section_exit();
return;
}
event_signaled = true;
core_util_critical_section_exit();
if (whenEventsToProcess) {
OnEventsToProcessCallbackContext params = {

View File

@ -30,7 +30,7 @@ ConnectionParameters::ConnectionParameters(
conn_event_length_t maxEventLength
) :
_filterPolicy(initiator_filter_policy_t::NO_FILTER),
_ownAddressType(own_address_type_t::PUBLIC)
_ownAddressType(own_address_type_t::RANDOM)
{
for (uint8_t i = 0; i < MAX_PARAM_PHYS; ++i) {
_enabledPhy[i] = false;

View File

@ -30,7 +30,7 @@ uint8_t Gap::getMaxAdvertisingSetNumber()
return 1;
}
uint8_t Gap::getMaxAdvertisingDataLength()
uint16_t Gap::getMaxAdvertisingDataLength()
{
/* Requesting action from porter(s): override this API if this capability is supported. */
return LEGACY_ADVERTISING_MAX_SIZE;
@ -145,8 +145,8 @@ ble_error_t Gap::setScanParameters(const ScanParameters &params)
};
ble_error_t Gap::startScan(
duplicates_filter_t filtering,
scan_duration_t duration,
duplicates_filter_t filtering,
scan_period_t period
)
{

View File

@ -675,10 +675,13 @@ ble_error_t GenericGap::connect(
return BLE_ERROR_INVALID_PARAM;
}
// ensure scan is stopped.
_pal_gap.scan_enable(false, false);
return _pal_gap.create_connection(
connectionParams.getScanIntervalArray()[0],
connectionParams.getScanWindowArray()[0],
connectionParams.getFilterPolicy(),
connectionParams.getFilter(),
(pal::connection_peer_address_type_t::type) peerAddressType.value(),
peerAddress,
connectionParams.getOwnAddressType(),
@ -691,6 +694,9 @@ ble_error_t GenericGap::connect(
);
}
// ensure scan is stopped.
_pal_gap.extended_scan_enable(false, pal::duplicates_filter_t::DISABLE, 0, 0);
// reduce the address type to public or random
peer_address_type_t adjusted_address_type(peer_address_type_t::PUBLIC);
@ -701,7 +707,7 @@ ble_error_t GenericGap::connect(
}
return _pal_gap.extended_create_connection(
connectionParams.getFilterPolicy(),
connectionParams.getFilter(),
connectionParams.getOwnAddressType(),
adjusted_address_type,
peerAddress,
@ -1442,7 +1448,7 @@ void GenericGap::processDisconnectionEvent(
if (_eventHandler) {
_eventHandler->onDisconnectionComplete(
DisconnectionEvent(
DisconnectionCompleteEvent(
handle,
(disconnection_reason_t::type) reason
)
@ -1997,7 +2003,7 @@ uint8_t GenericGap::getMaxAdvertisingSetNumber()
}
}
uint8_t GenericGap::getMaxAdvertisingDataLength()
uint16_t GenericGap::getMaxAdvertisingDataLength()
{
useVersionTwoAPI();
return _pal_gap.get_maximum_advertising_data_length();
@ -2053,7 +2059,7 @@ ble_error_t GenericGap::destroyAdvertisingSet(advertising_handle_t handle)
return BLE_ERROR_INVALID_PARAM;
}
if (_existing_sets.get(handle) == false) {
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_PARAM;
}
@ -2357,10 +2363,14 @@ ble_error_t GenericGap::stopAdvertising(advertising_handle_t handle)
return BLE_ERROR_INVALID_PARAM;
}
if (_existing_sets.get(handle)) {
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_PARAM;
}
if (!_active_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
}
ble_error_t status;
if (is_extended_advertising_available()) {
@ -2427,7 +2437,7 @@ ble_error_t GenericGap::setPeriodicAdvertisingParameters(
}
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_ERROR_INVALID_PARAM;
}
return _pal_gap.set_periodic_advertising_parameters(
@ -2454,7 +2464,7 @@ ble_error_t GenericGap::setPeriodicAdvertisingPayload(
}
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_ERROR_INVALID_PARAM;
}
if (payload.size() > getMaxAdvertisingDataLength()) {
@ -2511,7 +2521,7 @@ ble_error_t GenericGap::startPeriodicAdvertising(advertising_handle_t handle)
}
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_ERROR_INVALID_PARAM;
}
if (_active_sets.get(handle) == false) {
@ -2544,7 +2554,7 @@ ble_error_t GenericGap::stopPeriodicAdvertising(advertising_handle_t handle)
}
if (!_existing_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_ERROR_INVALID_PARAM;
}
if (_active_periodic_sets.get(handle) == false) {
@ -2859,8 +2869,8 @@ ble_error_t GenericGap::setScanParameters(const ScanParameters &params)
}
ble_error_t GenericGap::startScan(
duplicates_filter_t filtering,
scan_duration_t duration,
duplicates_filter_t filtering,
scan_period_t period
)
{

View File

@ -511,29 +511,6 @@ void Gap::gap_handler(const wsfMsgHdr_t *msg)
}
break;
case DM_CONN_OPEN_IND: {
if (!handler) {
break;
}
// TODO: filter with old event ...
const hciLeConnCmplEvt_t *evt = (const hciLeConnCmplEvt_t *) msg;
handler->on_enhanced_connection_complete(
hci_error_code_t(evt->status),
evt->handle,
connection_role_t(evt->role),
connection_peer_address_type_t(evt->addrType),
evt->peerAddr,
evt->localRpa,
evt->peerRpa,
evt->connInterval,
evt->connLatency,
evt->supTimeout,
clock_accuracy_t(evt->clockAccuracy)
);
}
break;
case DM_SCAN_REQ_RCVD_IND: {
if (!handler) {
break;