connman_bool_t disconnected;
connman_bool_t reconnect;
connman_uint16_t scan_interval;
+ connman_uint16_t backoff_interval;
char *name;
char *node;
char *address;
char *interface;
char *ident;
+ char *path;
int phyindex;
unsigned int connections;
guint scan_timeout;
GHashTable *networks;
};
+#define SCAN_INITIAL_DELAY 10
+
static gboolean device_scan_trigger(gpointer user_data)
{
struct connman_device *device = user_data;
clear_scan_trigger(device);
if (device->scan_interval > 0) {
- guint interval = device->scan_interval;
+ guint interval;
+
+ if (g_hash_table_size(device->networks) == 0) {
+ if (device->backoff_interval >= device->scan_interval)
+ device->backoff_interval = SCAN_INITIAL_DELAY;
+ interval = device->backoff_interval;
+ } else
+ interval = device->scan_interval;
+
+ DBG("interval %d", interval);
+
device->scan_timeout = g_timeout_add_seconds(interval,
device_scan_trigger, device);
+
+ device->backoff_interval *= 2;
+ if (device->backoff_interval > device->scan_interval)
+ device->backoff_interval = device->scan_interval;
}
}
g_free(device->name);
g_free(device->address);
g_free(device->interface);
+ g_free(device->path);
g_free(device->last_network);
struct connman_device *device;
const char *str;
enum connman_service_type service_type;
+ connman_bool_t bg_scan;
DBG("node %s type %d", node, type);
DBG("device %p", device);
+ bg_scan = connman_setting_get_bool("BackgroundScanning");
+
__connman_element_initialize(&device->element);
device->element.name = g_strdup(node);
connman_element_set_string(&device->element,
CONNMAN_PROPERTY_ID_TYPE, str);
- device->element.ipv4.method = CONNMAN_IPCONFIG_METHOD_DHCP;
-
device->type = type;
device->name = g_strdup(type2description(device->type));
service_type = __connman_device_get_service_type(device);
device->blocked = __connman_technology_get_blocked(service_type);
+ device->backoff_interval = SCAN_INITIAL_DELAY;
switch (type) {
case CONNMAN_DEVICE_TYPE_UNKNOWN:
- case CONNMAN_DEVICE_TYPE_VENDOR:
- device->scan_interval = 0;
- break;
case CONNMAN_DEVICE_TYPE_ETHERNET:
- case CONNMAN_DEVICE_TYPE_WIFI:
- device->scan_interval = 300;
- break;
case CONNMAN_DEVICE_TYPE_WIMAX:
- device->scan_interval = 0;
- break;
case CONNMAN_DEVICE_TYPE_BLUETOOTH:
- device->scan_interval = 0;
- break;
- case CONNMAN_DEVICE_TYPE_GPS:
- device->scan_interval = 0;
- break;
case CONNMAN_DEVICE_TYPE_CELLULAR:
- device->scan_interval = 0;
- break;
+ case CONNMAN_DEVICE_TYPE_GPS:
case CONNMAN_DEVICE_TYPE_GADGET:
+ case CONNMAN_DEVICE_TYPE_VENDOR:
device->scan_interval = 0;
break;
+ case CONNMAN_DEVICE_TYPE_WIFI:
+ if (bg_scan == TRUE)
+ device->scan_interval = 300;
+ else
+ device->scan_interval = 0;
+ break;
}
device->networks = g_hash_table_new_full(g_str_hash, g_str_equal,
while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
struct connman_network *network = value;
- if (__connman_network_get_connecting(network) == TRUE) {
+ if (connman_network_get_connecting(network) == TRUE) {
/*
* Skip network in the process of connecting.
* This is a workaround for WiFi networks serviced
* will fail. There is nothing to be gained by
* removing the network here anyway.
*/
- connman_warn("Skipping disconnect of %s",
+ connman_warn("Skipping disconnect of %s, network is connecting.",
connman_network_get_identifier(network));
continue;
}
} else if (g_str_equal(key, "Node") == TRUE) {
g_free(device->node);
device->node = g_strdup(value);
+ } else if (g_str_equal(key, "Path") == TRUE) {
+ g_free(device->path);
+ device->path = g_strdup(value);
+ } else {
+ return -EINVAL;
}
- return connman_element_set_string(&device->element, key, value);
+ return 0;
}
/**
return device->node;
else if (g_str_equal(key, "Interface") == TRUE)
return device->interface;
+ else if (g_str_equal(key, "Path") == TRUE)
+ return device->path;
- return connman_element_get_string(&device->element, key);
+ return NULL;
}
static void set_offlinemode(struct connman_element *element, gpointer user_data)
return;
device->connections--;
+
+ if (device->connections == 0)
+ device->backoff_interval = SCAN_INITIAL_DELAY;
}
/**
GError *error = NULL;
gchar *identifier;
connman_bool_t powered;
- int val;
DBG("device %p", device);
device->powered_persistent = powered;
g_clear_error(&error);
- val = g_key_file_get_integer(keyfile, identifier,
- "ScanInterval", &error);
- if (error == NULL)
- device->scan_interval = val;
- g_clear_error(&error);
-
done:
g_free(identifier);
g_key_file_set_boolean(keyfile, identifier,
"Powered", device->powered_persistent);
- g_key_file_set_integer(keyfile, identifier,
- "ScanInterval", device->scan_interval);
-
done:
g_free(identifier);