diff mbox series

[BlueZ,v4,2/3] core: Add param to disable interleave scan

Message ID 20200928154344.BlueZ.v4.2.Iac5207375d22fb7b96ae4ef73b49ae4ab457219c@changeid (mailing list archive)
State New, archived
Headers show
Series [BlueZ,v4,1/3] core: Add params to set interleaving durations | expand

Commit Message

Howard Chung Sept. 28, 2020, 7:44 a.m. UTC
This patch adds parameter to enable/disable the interleave scan feature.
---

Changes in v4:
- Set type of EnableAdvMonInterleaveScan to u8

Changes in v3:
- Set EnableAdvMonInterleaveScan default to Disable

 src/adapter.c | 10 ++++++++++
 src/hcid.h    |  1 +
 src/main.c    |  6 ++++++
 src/main.conf |  6 ++++++
 4 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index f072541aad35..553db4aa8b1f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4169,6 +4169,7 @@  static void load_default_system_params(struct btd_adapter *adapter)
 		struct mgmt_tlv entry;
 		union {
 			uint16_t u16;
+			uint8_t  u8;
 		};
 	} __packed *params;
 	uint16_t i = 0;
@@ -4436,6 +4437,15 @@  static void load_default_system_params(struct btd_adapter *adapter)
 		len += sizeof(params[i].u16);
 	}
 
+	if (main_opts.default_params.enable_advmon_interleave_scan != 0xFF) {
+		params[i].entry.type = 0x001f;
+		params[i].entry.length = sizeof(params[i].u8);
+		params[i].u8 =
+			main_opts.default_params.enable_advmon_interleave_scan;
+		++i;
+		len += sizeof(params[i].u8);
+	}
+
 	err = mgmt_send(adapter->mgmt, MGMT_OP_SET_DEF_SYSTEM_CONFIG,
 			adapter->dev_id, len, params, NULL, NULL, NULL);
 	if (!err)
diff --git a/src/hcid.h b/src/hcid.h
index 713eab8e03ae..34d22b3470f9 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -83,6 +83,7 @@  struct main_opts {
 
 		uint16_t	advmon_allowlist_scan_duration;
 		uint16_t	advmon_no_filter_scan_duration;
+		uint8_t		enable_advmon_interleave_scan;
 	} default_params;
 
 
diff --git a/src/main.c b/src/main.c
index 38f193a093df..bcdde069d843 100644
--- a/src/main.c
+++ b/src/main.c
@@ -112,6 +112,7 @@  static const char *controller_options[] = {
 	"LEAutoconnecttimeout",
 	"AdvMonAllowlistScanDuration",
 	"AdvMonNoFilterScanDuration",
+	"EnableAdvMonInterleaveScan",
 	NULL
 };
 
@@ -431,6 +432,10 @@  static void parse_controller_config(GKeyFile *config)
 		  &main_opts.default_params.advmon_no_filter_scan_duration,
 		  1,
 		  10000},
+		{ "EnableAdvMonInterleaveScan",
+		  &main_opts.default_params.enable_advmon_interleave_scan,
+		  0,
+		  1},
 	};
 	uint16_t i;
 
@@ -698,6 +703,7 @@  static void init_defaults(void)
 	main_opts.default_params.num_entries = 0;
 	main_opts.default_params.br_page_scan_type = 0xFFFF;
 	main_opts.default_params.br_scan_type = 0xFFFF;
+	main_opts.default_params.enable_advmon_interleave_scan = 0xFF;
 
 	if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2)
 		return;
diff --git a/src/main.conf b/src/main.conf
index 3b341f44c9cf..82ffc5813204 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -159,6 +159,12 @@ 
 # Default: 500
 #AdvMonNoFilterScanDuration=
 
+# Enable/Disable Advertisement Monitor interleave scan for power saving.
+# 0: disable
+# 1: enable
+# Defaults to 0
+#EnableAdvMonInterleaveScan=
+
 [GATT]
 # GATT attribute cache.
 # Possible values: