mirror of https://github.com/ARMmbed/mbed-os.git
proposed scan type changes
parent
60fb78795b
commit
8c253a3dfe
|
@ -108,10 +108,16 @@ public:
|
|||
* @note If interval is equal to window
|
||||
*/
|
||||
GapScanningParams(
|
||||
uint16_t interval = SCAN_INTERVAL_MAX,
|
||||
uint16_t window = SCAN_WINDOW_MAX,
|
||||
uint16_t interval = 0,
|
||||
uint16_t window = 0,
|
||||
uint16_t timeout = 0,
|
||||
bool activeScanning = false
|
||||
bool activeScanning = false,
|
||||
ble::scanning_policy_mode_t policy = ble::SCAN_POLICY_IGNORE_WHITELIST,
|
||||
uint16_t codedInterval = 0,
|
||||
uint16_t codedWindow = 0,
|
||||
uint16_t codedTimeout = 0,
|
||||
bool codedActiveScanning = false,
|
||||
ble::scanning_policy_mode_t codedPolicy = ble::SCAN_POLICY_IGNORE_WHITELIST
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -203,7 +209,15 @@ public:
|
|||
*/
|
||||
bool getActiveScanning(void) const
|
||||
{
|
||||
return _activeScanning;
|
||||
return _active_scanning;
|
||||
}
|
||||
|
||||
ble::scanning_policy_mode_t getScanningPolicy() {
|
||||
return _policy;
|
||||
}
|
||||
|
||||
void setScanningPolicy(ble::scanning_policy_mode_t policy) {
|
||||
_policy = policy;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -222,10 +236,34 @@ private:
|
|||
*/
|
||||
uint16_t _timeout;
|
||||
|
||||
/**
|
||||
* Scan interval in units of 625us (between 2.5ms and 10.24s).
|
||||
*/
|
||||
uint16_t _interval_coded;
|
||||
|
||||
/**
|
||||
* Scan window in units of 625us (between 2.5ms and 10.24s).
|
||||
*/
|
||||
uint16_t _window_coded;
|
||||
|
||||
/**
|
||||
* Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout.
|
||||
*/
|
||||
uint16_t _timeout_coded;
|
||||
|
||||
ble::scanning_policy_mode_t _policy;
|
||||
ble::scanning_policy_mode_t _policy_coded;
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the peer device's advertising data and (if possible) scanResponse.
|
||||
*/
|
||||
bool _activeScanning;
|
||||
uint8_t _active_scanning:1;
|
||||
uint8_t _active_scanning_coded:1;
|
||||
|
||||
uint8_t _phy_1m:1;
|
||||
uint8_t _phy_coded:1;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,11 +17,31 @@
|
|||
#include "ble/Gap.h"
|
||||
#include "ble/GapScanningParams.h"
|
||||
|
||||
GapScanningParams::GapScanningParams(uint16_t interval, uint16_t window, uint16_t timeout, bool activeScanning) :
|
||||
GapScanningParams::GapScanningParams(
|
||||
uint16_t interval,
|
||||
uint16_t window,
|
||||
uint16_t timeout,
|
||||
bool activeScanning,
|
||||
ble::scanning_policy_mode_t policy,
|
||||
uint16_t codedInterval,
|
||||
uint16_t codedWindow,
|
||||
uint16_t codedTimeout,
|
||||
bool codedActiveScanning,
|
||||
ble::scanning_policy_mode_t codedPolicy
|
||||
) :
|
||||
_interval(MSEC_TO_SCAN_DURATION_UNITS(interval)),
|
||||
_window(MSEC_TO_SCAN_DURATION_UNITS(window)),
|
||||
_timeout(timeout),
|
||||
_activeScanning(activeScanning) {
|
||||
_active_scanning(activeScanning),
|
||||
_policy(policy),
|
||||
_interval_coded(MSEC_TO_SCAN_DURATION_UNITS(codedWindow)),
|
||||
_window_coded(MSEC_TO_SCAN_DURATION_UNITS(codedWindow)),
|
||||
_timeout_coded(codedTimeout),
|
||||
_active_scanning_coded(codedActiveScanning),
|
||||
_policy_coded(codedPolicy),
|
||||
_phy_1m(window != 0),
|
||||
_phy_coded(codedWindow != 0) {
|
||||
//TODO: refactor
|
||||
/* stay within limits */
|
||||
if (_interval < SCAN_INTERVAL_MIN) {
|
||||
_interval = SCAN_INTERVAL_MIN;
|
||||
|
@ -35,6 +55,19 @@ GapScanningParams::GapScanningParams(uint16_t interval, uint16_t window, uint16_
|
|||
if (_window > SCAN_WINDOW_MAX) {
|
||||
_window = SCAN_WINDOW_MAX;
|
||||
}
|
||||
|
||||
if (_interval_coded < SCAN_INTERVAL_MIN) {
|
||||
_interval_coded = SCAN_INTERVAL_MIN;
|
||||
}
|
||||
if (_interval_coded > SCAN_INTERVAL_MAX) {
|
||||
_interval_coded = SCAN_INTERVAL_MAX;
|
||||
}
|
||||
if (_window_coded < SCAN_WINDOW_MIN) {
|
||||
_window_coded = SCAN_WINDOW_MIN;
|
||||
}
|
||||
if (_window_coded > SCAN_WINDOW_MAX) {
|
||||
_window_coded = SCAN_WINDOW_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
ble_error_t
|
||||
|
@ -71,5 +104,5 @@ GapScanningParams::setTimeout(uint16_t newTimeout)
|
|||
void
|
||||
GapScanningParams::setActiveScanning(bool activeScanning)
|
||||
{
|
||||
_activeScanning = activeScanning;
|
||||
_active_scanning = activeScanning;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue