BLE: rework ScanParameters::phy_configuration_t

pull/8738/head
Vincent Coubard 2018-11-24 22:09:46 +00:00
parent 4db8ddfb90
commit e130bec6a0
2 changed files with 47 additions and 11 deletions

View File

@ -32,10 +32,21 @@ namespace ble {
class ScanParameters {
public:
/**
* Scan configuration of a physical channel.
*/
struct phy_configuration_t {
/**
* Construct a phy_configuration_t.
* @param scan_interval The scan interval.
* @param scan_window The scan window
* @param active_scanning True if scan request should be sent and false
* otherwise.
*/
phy_configuration_t(
scan_window_t scan_interval = scan_interval_t::min(),
scan_interval_t scan_window = scan_window_t::min(),
scan_interval_t scan_interval = scan_interval_t::min(),
scan_window_t scan_window = scan_window_t::min(),
bool active_scanning = false
) :
interval(scan_interval),
@ -47,6 +58,31 @@ public:
}
}
/**
* Get the scan interval.
*/
const scan_window_t &getInterval() const
{
return interval;
}
/**
* Get the scan window.
*/
const scan_interval_t &getWindow() const
{
return window;
}
/**
* Return if active scanning is set.
*/
bool isActiveScanningSet() const
{
return active_scanning;
}
private:
scan_window_t interval;
scan_interval_t window;
bool active_scanning;

View File

@ -2570,18 +2570,18 @@ ble_error_t GenericGap::setScanParameters(const ScanParameters &params)
if (is_extended_advertising_available()) {
bool active_scanning[] = {
params.get1mPhyConfiguration().active_scanning,
params.getCodedPhyConfiguration().active_scanning
params.get1mPhyConfiguration().isActiveScanningSet(),
params.getCodedPhyConfiguration().isActiveScanningSet()
};
uint16_t scan_interval[] = {
params.get1mPhyConfiguration().interval.value(),
params.getCodedPhyConfiguration().interval.value()
params.get1mPhyConfiguration().getInterval().value(),
params.getCodedPhyConfiguration().getInterval().value()
};
uint16_t scan_window[] = {
params.get1mPhyConfiguration().window.value(),
params.getCodedPhyConfiguration().window.value()
params.get1mPhyConfiguration().getWindow().value(),
params.getCodedPhyConfiguration().getWindow().value()
};
return _pal_gap.set_extended_scan_parameters(
@ -2601,9 +2601,9 @@ ble_error_t GenericGap::setScanParameters(const ScanParameters &params)
params.get1mPhyConfiguration();
return _pal_gap.set_scan_parameters(
legacy_configuration.active_scanning,
legacy_configuration.interval.value(),
legacy_configuration.window.value(),
legacy_configuration.isActiveScanningSet(),
legacy_configuration.getInterval().value(),
legacy_configuration.getWindow().value(),
params.getOwnAddressType(),
params.getFilter()
);