#include "inet.h"
#include "supplicant.h"
-#define CLEANUP_PENDING_TIMEOUT 8 /* in seconds */
+#define CLEANUP_TIMEOUT 8 /* in seconds */
+#define INACTIVE_TIMEOUT 12 /* in seconds */
struct wifi_data {
GSList *current;
GSList *pending;
- guint timer;
+ guint cleanup_timer;
+ guint inactive_timer;
gchar *identifier;
gboolean connected;
};
return NULL;
}
+static gboolean inactive_scan(gpointer user_data)
+{
+ struct connman_element *device = user_data;
+ struct wifi_data *data = connman_element_get_data(device);
+
+ DBG("");
+
+ if (data->cleanup_timer > 0) {
+ g_source_remove(data->cleanup_timer);
+ data->cleanup_timer = 0;
+ }
+
+ __supplicant_scan(device);
+
+ data->inactive_timer = 0;
+
+ return FALSE;
+}
+
static void state_change(struct connman_element *parent,
enum supplicant_state state)
{
DBG("state %d", state);
+ if (state == STATE_INACTIVE && data->inactive_timer == 0)
+ data->inactive_timer = g_timeout_add_seconds(INACTIVE_TIMEOUT,
+ inactive_scan, parent);
+
if (data == NULL)
return;
g_slist_free(data->pending);
data->pending = NULL;
- data->timer = 0;
+ data->cleanup_timer = 0;
return FALSE;
}
data->pending = data->current;
data->current = NULL;
- if (data->timer == 0)
- data->timer = g_timeout_add_seconds(CLEANUP_PENDING_TIMEOUT,
+ if (data->cleanup_timer > 0)
+ return;
+
+ data->cleanup_timer = g_timeout_add_seconds(CLEANUP_TIMEOUT,
cleanup_pending, data);
}
DBG("element %p name %s", element, element->name);
- if (data->timer > 0) {
- g_source_remove(data->timer);
- data->timer = 0;
+ if (data->cleanup_timer > 0) {
+ g_source_remove(data->cleanup_timer);
+ data->cleanup_timer = 0;
+ }
+
+ if (data->inactive_timer > 0) {
+ g_source_remove(data->inactive_timer);
+ data->inactive_timer = 0;
}
__supplicant_disconnect(element);