bgscan learn: Skip immediate scan on initial signal event

The driver is likely to indicate an immediate signal event when the
threshold value is configured. Since we do this immediately after
association, there is not much point in requesting a new scan to be
started based on this event.
This commit is contained in:
Jouni Malinen 2010-08-27 20:30:19 +03:00
parent 1e6ef6455c
commit 9ff80a10e8

View file

@ -428,6 +428,15 @@ static void * bgscan_learn_init(struct wpa_supplicant *wpa_s,
data->scan_interval = data->short_interval; data->scan_interval = data->short_interval;
eloop_register_timeout(data->scan_interval, 0, bgscan_learn_timeout, eloop_register_timeout(data->scan_interval, 0, bgscan_learn_timeout,
data, NULL); data, NULL);
/*
* This function is called immediately after an association, so it is
* reasonable to assume that a scan was completed recently. This makes
* us skip an immediate new scan in cases where the current signal
* level is below the bgscan threshold.
*/
os_get_time(&data->last_bgscan);
return data; return data;
} }
@ -550,6 +559,7 @@ static void bgscan_learn_notify_signal_change(void *priv, int above,
int current_signal) int current_signal)
{ {
struct bgscan_learn_data *data = priv; struct bgscan_learn_data *data = priv;
struct os_time now;
if (data->short_interval == data->long_interval || if (data->short_interval == data->long_interval ||
data->signal_threshold == 0) data->signal_threshold == 0)
@ -558,12 +568,12 @@ static void bgscan_learn_notify_signal_change(void *priv, int above,
wpa_printf(MSG_DEBUG, "bgscan learn: signal level changed " wpa_printf(MSG_DEBUG, "bgscan learn: signal level changed "
"(above=%d current_signal=%d)", above, current_signal); "(above=%d current_signal=%d)", above, current_signal);
if (data->scan_interval == data->long_interval && !above) { if (data->scan_interval == data->long_interval && !above) {
wpa_printf(MSG_DEBUG, "bgscan learn: Trigger immediate scan " wpa_printf(MSG_DEBUG, "bgscan learn: Start using short bgscan "
"and start using short bgscan interval"); "interval");
data->scan_interval = data->short_interval; data->scan_interval = data->short_interval;
eloop_cancel_timeout(bgscan_learn_timeout, data, NULL); os_get_time(&now);
eloop_register_timeout(0, 0, bgscan_learn_timeout, data, if (now.sec > data->last_bgscan.sec + 1)
NULL); scan = 1;
} else if (data->scan_interval == data->short_interval && above) { } else if (data->scan_interval == data->short_interval && above) {
wpa_printf(MSG_DEBUG, "bgscan learn: Start using long bgscan " wpa_printf(MSG_DEBUG, "bgscan learn: Start using long bgscan "
"interval"); "interval");
@ -572,20 +582,19 @@ static void bgscan_learn_notify_signal_change(void *priv, int above,
eloop_register_timeout(data->scan_interval, 0, eloop_register_timeout(data->scan_interval, 0,
bgscan_learn_timeout, data, NULL); bgscan_learn_timeout, data, NULL);
} else if (!above) { } else if (!above) {
struct os_time now;
/* /*
* Signal dropped further 4 dB. Request a new scan if we have * Signal dropped further 4 dB. Request a new scan if we have
* not yet scanned in a while. * not yet scanned in a while.
*/ */
os_get_time(&now); os_get_time(&now);
if (now.sec > data->last_bgscan.sec + 10) { if (now.sec > data->last_bgscan.sec + 10)
wpa_printf(MSG_DEBUG, "bgscan learn: Trigger " scan = 1;
"immediate scan");
eloop_cancel_timeout(bgscan_learn_timeout, data,
NULL);
eloop_register_timeout(0, 0, bgscan_learn_timeout,
data, NULL);
} }
if (scan) {
wpa_printf(MSG_DEBUG, "bgscan learn: Trigger immediate scan");
eloop_cancel_timeout(bgscan_learn_timeout, data, NULL);
eloop_register_timeout(0, 0, bgscan_learn_timeout, data, NULL);
} }
} }