aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Stewart <pstew@google.com>2011-03-31 15:04:48 (GMT)
committerJouni Malinen <j@w1.fi>2011-03-31 15:04:48 (GMT)
commit6d21d4112509da37982809817e8f83ffedb55d3b (patch)
tree63094dd07e1aeec6c3f0cd08e33a7b4964eb98a6
parentdb03ddacffb7fadc5949b2fc37cdbd1aac5b3f6d (diff)
downloadhostap-6d21d4112509da37982809817e8f83ffedb55d3b.zip
hostap-6d21d4112509da37982809817e8f83ffedb55d3b.tar.gz
hostap-6d21d4112509da37982809817e8f83ffedb55d3b.tar.bz2
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>
-rw-r--r--wpa_supplicant/bgscan_simple.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c
index e2692c4..a62dac1 100644
--- a/wpa_supplicant/bgscan_simple.c
+++ b/wpa_supplicant/bgscan_simple.c
@@ -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,8 +58,23 @@ 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);
+ }
}
@@ -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;