bgscan_simple: Time out short scan interval
We gain diminishing returns by the short scan interval. The short scan interval is used to hunt for a better AP if the RSSI of the current AP drops. However, if we never roam, and the AP continues to have low RSSI, at some point we should give up and return to the slow background scan rate, otherwise we waste a lot of power. Signed-off-by: Paul Stewart <pstew@google.com>
This commit is contained in:
parent
db03ddacff
commit
6d21d41125
1 changed files with 18 additions and 1 deletions
|
@ -28,6 +28,7 @@ struct bgscan_simple_data {
|
|||
const struct wpa_ssid *ssid;
|
||||
int scan_interval;
|
||||
int signal_threshold;
|
||||
int short_scan_count; /* counter for scans using short scan interval */
|
||||
int short_interval; /* use if signal < threshold */
|
||||
int long_interval; /* use if signal > threshold */
|
||||
struct os_time last_bgscan;
|
||||
|
@ -57,9 +58,24 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx)
|
|||
wpa_printf(MSG_DEBUG, "bgscan simple: Failed to trigger scan");
|
||||
eloop_register_timeout(data->scan_interval, 0,
|
||||
bgscan_simple_timeout, data, NULL);
|
||||
} else
|
||||
} else {
|
||||
if (data->scan_interval == data->short_interval) {
|
||||
data->short_scan_count++;
|
||||
/*
|
||||
* Spend at most the duration of a long scan interval
|
||||
* scanning at the short scan interval. After that,
|
||||
* revert to the long scan interval.
|
||||
*/
|
||||
if (data->short_scan_count >
|
||||
data->long_interval / data->short_interval + 1) {
|
||||
data->scan_interval = data->long_interval;
|
||||
wpa_printf(MSG_DEBUG, "bgscan simple: Backing "
|
||||
"off to long scan interval");
|
||||
}
|
||||
}
|
||||
os_get_time(&data->last_bgscan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int bgscan_simple_get_params(struct bgscan_simple_data *data,
|
||||
|
@ -206,6 +222,7 @@ static void bgscan_simple_notify_signal_change(void *priv, int above,
|
|||
wpa_printf(MSG_DEBUG, "bgscan simple: Start using short "
|
||||
"bgscan interval");
|
||||
data->scan_interval = data->short_interval;
|
||||
data->short_scan_count = 0;
|
||||
os_get_time(&now);
|
||||
if (now.sec > data->last_bgscan.sec + 1)
|
||||
scan = 1;
|
||||
|
|
Loading…
Reference in a new issue