main: add configurable RemoteNameRequestRetryDelay parameter
authorArchie Pusaka <apusaka@chromium.org>
Thu, 25 Nov 2021 07:06:26 +0000 (15:06 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:38 +0000 (19:08 +0530)
This specifies how long will the userspace ignore a peer with an
unknown name after a failed remote name resolving procedure.

The peer device can still be connected, this only prevents the remote
name resolving procedure retry.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/btd.h
src/device.c
src/main.c
src/main.conf

index cc827c1..aae2298 100755 (executable)
--- a/src/btd.h
+++ b/src/btd.h
@@ -104,6 +104,7 @@ struct btd_opts {
        uint32_t        tmpto;
        uint8_t         privacy;
        bool            device_privacy;
+       uint32_t        name_request_retry_delay;
 
        struct btd_defaults defaults;
 
index ef181e0..058780a 100644 (file)
@@ -84,7 +84,6 @@
 #define GATT_SND_SVC_UUID_STR  "2801"
 #define GATT_INCLUDE_UUID_STR "2802"
 #define GATT_CHARAC_UUID_STR "2803"
-#define NAME_RESOLVE_RETRY_DELAY       300 /* seconds */
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
 #define DEV_MAX_MANUFACTURER_DATA_LEN  248
@@ -7074,7 +7073,7 @@ bool device_is_name_resolve_allowed(struct btd_device *device)
         */
        return now.tv_sec < device->name_resolve_failed_time ||
                now.tv_sec >= device->name_resolve_failed_time +
-                                               NAME_RESOLVE_RETRY_DELAY;
+                                       btd_opts.name_request_retry_delay;
 }
 
 void device_name_resolve_fail(struct btd_device *device)
index 7a2fb51..0596d4b 100755 (executable)
 
 #define BLUEZ_NAME "org.bluez"
 
-#define DEFAULT_PAIRABLE_TIMEOUT       0 /* disabled */
-#define DEFAULT_DISCOVERABLE_TIMEOUT 180 /* 3 minutes */
-#define DEFAULT_TEMPORARY_TIMEOUT     30 /* 30 seconds */
+#define DEFAULT_PAIRABLE_TIMEOUT           0 /* disabled */
+#define DEFAULT_DISCOVERABLE_TIMEOUT     180 /* 3 minutes */
+#define DEFAULT_TEMPORARY_TIMEOUT         30 /* 30 seconds */
+#define DEFAULT_NAME_REQUEST_RETRY_DELAY 300 /* 5 minutes */
 
 #define SHUTDOWN_GRACE_SECONDS 10
 
@@ -81,6 +82,7 @@ static const char *supported_options[] = {
        "JustWorksRepairing",
        "TemporaryTimeout",
        "Experimental",
+       "RemoteNameRequestRetryDelay",
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        "EnableLEPrivacy",
        "PinCode",
@@ -820,6 +822,16 @@ static void parse_config(GKeyFile *config)
                g_strfreev(strlist);
        }
 
+       val = g_key_file_get_integer(config, "General",
+                                       "RemoteNameRequestRetryDelay", &err);
+       if (err) {
+               DBG("%s", err->message);
+               g_clear_error(&err);
+       } else {
+               DBG("RemoteNameRequestRetryDelay=%d", val);
+               btd_opts.name_request_retry_delay = val;
+       }
+
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        boolean = g_key_file_get_boolean(config, "General",
                                                "EnableLEPrivacy", &err);
@@ -957,6 +969,7 @@ static void init_defaults(void)
        btd_opts.name_resolv = TRUE;
        btd_opts.debug_keys = FALSE;
        btd_opts.refresh_discovery = TRUE;
+       btd_opts.name_request_retry_delay = DEFAULT_NAME_REQUEST_RETRY_DELAY;
 
        btd_opts.defaults.num_entries = 0;
        btd_opts.defaults.br.page_scan_type = 0xFFFF;
index 94005f1..b285995 100755 (executable)
 # Defaults to false.
 #Experimental = false
 
+# The duration to avoid retrying to resolve a peer's name, if the previous
+# try failed.
+# The value is in seconds. Default is 300, i.e. 5 minutes.
+#RemoteNameRequestRetryDelay = 300
+
 [BR]
 # The following values are used to load default adapter parameters for BR/EDR.
 # BlueZ loads the values into the kernel before the adapter is powered if the