In particular cases, it can be useful to tweak such parameters.
Depending on target device.
---
 include/setting.h |  1 +
 src/main.c        | 23 ++++++++++++++++++++++-
 src/main.conf     | 12 ++++++++++++
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/include/setting.h b/include/setting.h
index a882021..f492373 100644
--- a/include/setting.h
+++ b/include/setting.h
@@ -31,6 +31,7 @@ extern "C" {
 bool connman_setting_get_bool(const char *key);
 char **connman_setting_get_string_list(const char *key);
 unsigned int *connman_setting_get_uint_list(const char *key);
+char *connman_setting_get_string(const char *key);
 
 unsigned int connman_timeout_input_request(void);
 unsigned int connman_timeout_browser_launch(void);
diff --git a/src/main.c b/src/main.c
index 3a667d6..accfb0f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
 
 #define DEFAULT_INPUT_REQUEST_TIMEOUT (120 * 1000)
 #define DEFAULT_BROWSER_LAUNCH_TIMEOUT (300 * 1000)
+#define DEFAULT_AUTOSCAN_PARAMETERS "exponential:3:300"
 
 #define MAINFILE "main.conf"
 #define CONFIGMAINFILE CONFIGDIR "/" MAINFILE
@@ -72,6 +73,7 @@ static struct {
        bool single_tech;
        char **tethering_technologies;
        bool persistent_tethering_mode;
+       char *autoscan_parameters;
 } connman_settings  = {
        .bg_scan = true,
        .pref_timeservers = NULL,
@@ -85,6 +87,7 @@ static struct {
        .single_tech = false,
        .tethering_technologies = NULL,
        .persistent_tethering_mode = false,
+       .autoscan_parameters = DEFAULT_AUTOSCAN_PARAMETERS,
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
@@ -97,8 +100,9 @@ static struct {
 #define CONF_BLACKLISTED_INTERFACES     "NetworkInterfaceBlacklist"
 #define CONF_ALLOW_HOSTNAME_UPDATES     "AllowHostnameUpdates"
 #define CONF_SINGLE_TECH                "SingleConnectedTechnology"
-#define CONF_TETHERING_TECHNOLOGIES      "TetheringTechnologies"
+#define CONF_TETHERING_TECHNOLOGIES     "TetheringTechnologies"
 #define CONF_PERSISTENT_TETHERING_MODE  "PersistentTetheringMode"
+#define CONF_AUTOSCAN_PARAMETERS        "AutoscanParameters"
 
 static const char *supported_options[] = {
        CONF_BG_SCAN,
@@ -113,6 +117,7 @@ static const char *supported_options[] = {
        CONF_SINGLE_TECH,
        CONF_TETHERING_TECHNOLOGIES,
        CONF_PERSISTENT_TETHERING_MODE,
+       CONF_AUTOSCAN_PARAMETERS,
        NULL
 };
 
@@ -233,6 +238,7 @@ static void parse_config(GKeyFile *config)
        char **interfaces;
        char **str_list;
        char **tethering;
+       char *parameters;
        gsize len;
        int timeout;
 
@@ -351,6 +357,13 @@ static void parse_config(GKeyFile *config)
                connman_settings.persistent_tethering_mode = boolean;
 
        g_clear_error(&error);
+
+       parameters = g_key_file_get_string(config, "General",
+                                       CONF_AUTOSCAN_PARAMETERS, &error);
+       if (!error)
+               connman_settings.autoscan_parameters = parameters;
+
+       g_clear_error(&error);
 }
 
 static int config_init(const char *file)
@@ -556,6 +569,14 @@ unsigned int *connman_setting_get_uint_list(const char 
*key)
        return NULL;
 }
 
+char *connman_setting_get_string(const char *key)
+{
+       if (g_str_equal(key, CONF_AUTOSCAN_PARAMETERS))
+               return connman_settings.autoscan_parameters;
+
+       return NULL;
+}
+
 unsigned int connman_timeout_input_request(void)
 {
        return connman_settings.timeout_inputreq;
diff --git a/src/main.conf b/src/main.conf
index b8b3239..cb8d72f 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -15,11 +15,23 @@
 # BrowserLaunchTimeout = 300
 
 # Enable background scanning. Default is true.
+# This enables 2 different background scanning:
+# - when connected, useful when roaming
+# - when disconnected, useful for autoconnection to known networks
 # Background scanning will start every 5 minutes unless
 # the scan list is empty. In that case, a simple backoff
 # mechanism starting from 10s up to 5 minutes will run.
 # BackgroundScanning = true
 
+# Set the automatic scanning parameters. Default is "exponential:3:300"
+# Used to tweak automatic scanning parameters following this format:
+# <type>:<param1><:param2>
+# when type can be:
+# - exponential: where param1 is the starting delay and param2 the limit.
+# - periodic: where param1 is the delay, there is no param1
+# Unused if BackgroundScanning is false.
+# AutoscanParameters = 
+
 # List of Fallback timeservers separated by ",".
 # These timeservers are used for NTP sync when there are
 # no timeserver set by the user or by the service.
-- 
1.8.3.2

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to