diff mbox series

[Bluez,v1] core: Add RSSI sampling period in system parameter

Message ID 20210511152320.Bluez.v1.1.I3f63cfa802b3602a4ddd7604acc8e886f223912f@changeid (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [Bluez,v1] core: Add RSSI sampling period in system parameter | expand

Commit Message

Yun-hao Chung May 11, 2021, 7:23 a.m. UTC
From: Yun-Hao Chung <howardchung@chromium.org>

Add an option in main.conf to configure the default RSSI sampling
period for advertisement monitor.

Reviewed-by: apusaka@chromium.org
Reviewed-by: mmandlik@chromium.org
Reviewed-by: mcchou@chromium.org
---

 src/adv_monitor.c |  4 ++--
 src/btd.h         |  6 ++++++
 src/main.c        | 20 ++++++++++++++++++++
 src/main.conf     |  6 ++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

Comments

bluez.test.bot@gmail.com May 11, 2021, 7:41 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=480039

---Test result---

Test Summary:
CheckPatch                    FAIL      0.64 seconds
GitLint                       PASS      0.14 seconds
Prep - Setup ELL              PASS      48.69 seconds
Build - Prep                  PASS      0.13 seconds
Build - Configure             PASS      8.38 seconds
Build - Make                  PASS      210.10 seconds
Make Check                    PASS      8.80 seconds
Make Dist                     PASS      12.42 seconds
Make Dist - Configure         PASS      5.25 seconds
Make Dist - Make              PASS      84.75 seconds
Build w/ext ELL - Configure   PASS      8.56 seconds
Build w/ext ELL - Make        PASS      198.40 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
core: Add RSSI sampling period in system parameter
WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#74: FILE: src/main.c:148:
+static const char *advmon_options[] = {

- total: 0 errors, 1 warnings, 93 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] core: Add RSSI sampling period in system parameter" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Dist - PASS
Desc: Run 'make dist' and build the distribution tarball

##############################
Test: Make Dist - Configure - PASS
Desc: Configure the source from distribution tarball

##############################
Test: Make Dist - Make - PASS
Desc: Build the source from distribution tarball

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth
Yun-hao Chung May 20, 2021, 6:46 a.m. UTC | #2
Hi Linux-Bluez,
Gentle ping

On Tue, May 11, 2021 at 3:41 PM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=480039
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    FAIL      0.64 seconds
> GitLint                       PASS      0.14 seconds
> Prep - Setup ELL              PASS      48.69 seconds
> Build - Prep                  PASS      0.13 seconds
> Build - Configure             PASS      8.38 seconds
> Build - Make                  PASS      210.10 seconds
> Make Check                    PASS      8.80 seconds
> Make Dist                     PASS      12.42 seconds
> Make Dist - Configure         PASS      5.25 seconds
> Make Dist - Make              PASS      84.75 seconds
> Build w/ext ELL - Configure   PASS      8.56 seconds
> Build w/ext ELL - Make        PASS      198.40 seconds
>
> Details
> ##############################
> Test: CheckPatch - FAIL
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> Output:
> core: Add RSSI sampling period in system parameter
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> #74: FILE: src/main.c:148:
> +static const char *advmon_options[] = {
>
> - total: 0 errors, 1 warnings, 93 lines checked
>
> NOTE: For some of the reported defects, checkpatch may be able to
>       mechanically convert to the typical style using --fix or --fix-inplace.
>
> "[PATCH] core: Add RSSI sampling period in system parameter" has style problems, please review.
>
> NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
>
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
>
>
> ##############################
> Test: GitLint - PASS
> Desc: Run gitlint with rule in .gitlint
>
> ##############################
> Test: Prep - Setup ELL - PASS
> Desc: Clone, build, and install ELL
>
> ##############################
> Test: Build - Prep - PASS
> Desc: Prepare environment for build
>
> ##############################
> Test: Build - Configure - PASS
> Desc: Configure the BlueZ source tree
>
> ##############################
> Test: Build - Make - PASS
> Desc: Build the BlueZ source tree
>
> ##############################
> Test: Make Check - PASS
> Desc: Run 'make check'
>
> ##############################
> Test: Make Dist - PASS
> Desc: Run 'make dist' and build the distribution tarball
>
> ##############################
> Test: Make Dist - Configure - PASS
> Desc: Configure the source from distribution tarball
>
> ##############################
> Test: Make Dist - Make - PASS
> Desc: Build the source from distribution tarball
>
> ##############################
> Test: Build w/ext ELL - Configure - PASS
> Desc: Configure BlueZ source with '--enable-external-ell' configuration
>
> ##############################
> Test: Build w/ext ELL - Make - PASS
> Desc: Build BlueZ source with '--enable-external-ell' configuration
>
>
>
> ---
> Regards,
> Linux Bluetooth
>
Luiz Augusto von Dentz May 22, 2021, 12:30 a.m. UTC | #3
Hi Yun-hao,

On Wed, May 19, 2021 at 11:48 PM Yun-hao Chung <howardchung@google.com> wrote:
>
> Hi Linux-Bluez,
> Gentle ping
>
> On Tue, May 11, 2021 at 3:41 PM <bluez.test.bot@gmail.com> wrote:
> >
> > This is automated email and please do not reply to this email!
> >
> > Dear submitter,
> >
> > Thank you for submitting the patches to the linux bluetooth mailing list.
> > This is a CI test results with your patch series:
> > PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=480039

Looks like pw no longer has this set, can you please resend it.

> > ---Test result---
> >
> > Test Summary:
> > CheckPatch                    FAIL      0.64 seconds
> > GitLint                       PASS      0.14 seconds
> > Prep - Setup ELL              PASS      48.69 seconds
> > Build - Prep                  PASS      0.13 seconds
> > Build - Configure             PASS      8.38 seconds
> > Build - Make                  PASS      210.10 seconds
> > Make Check                    PASS      8.80 seconds
> > Make Dist                     PASS      12.42 seconds
> > Make Dist - Configure         PASS      5.25 seconds
> > Make Dist - Make              PASS      84.75 seconds
> > Build w/ext ELL - Configure   PASS      8.56 seconds
> > Build w/ext ELL - Make        PASS      198.40 seconds
> >
> > Details
> > ##############################
> > Test: CheckPatch - FAIL
> > Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> > Output:
> > core: Add RSSI sampling period in system parameter
> > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> > #74: FILE: src/main.c:148:
> > +static const char *advmon_options[] = {
> >
> > - total: 0 errors, 1 warnings, 93 lines checked
> >
> > NOTE: For some of the reported defects, checkpatch may be able to
> >       mechanically convert to the typical style using --fix or --fix-inplace.
> >
> > "[PATCH] core: Add RSSI sampling period in system parameter" has style problems, please review.
> >
> > NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
> >
> > NOTE: If any of the errors are false positives, please report
> >       them to the maintainer, see CHECKPATCH in MAINTAINERS.
> >
> >
> > ##############################
> > Test: GitLint - PASS
> > Desc: Run gitlint with rule in .gitlint
> >
> > ##############################
> > Test: Prep - Setup ELL - PASS
> > Desc: Clone, build, and install ELL
> >
> > ##############################
> > Test: Build - Prep - PASS
> > Desc: Prepare environment for build
> >
> > ##############################
> > Test: Build - Configure - PASS
> > Desc: Configure the BlueZ source tree
> >
> > ##############################
> > Test: Build - Make - PASS
> > Desc: Build the BlueZ source tree
> >
> > ##############################
> > Test: Make Check - PASS
> > Desc: Run 'make check'
> >
> > ##############################
> > Test: Make Dist - PASS
> > Desc: Run 'make dist' and build the distribution tarball
> >
> > ##############################
> > Test: Make Dist - Configure - PASS
> > Desc: Configure the source from distribution tarball
> >
> > ##############################
> > Test: Make Dist - Make - PASS
> > Desc: Build the source from distribution tarball
> >
> > ##############################
> > Test: Build w/ext ELL - Configure - PASS
> > Desc: Configure BlueZ source with '--enable-external-ell' configuration
> >
> > ##############################
> > Test: Build w/ext ELL - Make - PASS
> > Desc: Build BlueZ source with '--enable-external-ell' configuration
> >
> >
> >
> > ---
> > Regards,
> > Linux Bluetooth
> >
diff mbox series

Patch

diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index 9f04aaefbf22..17f1777eb1da 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -25,6 +25,7 @@ 
 #include "lib/mgmt.h"
 
 #include "adapter.h"
+#include "btd.h"
 #include "dbus-common.h"
 #include "device.h"
 #include "log.h"
@@ -49,7 +50,6 @@ 
 #define ADV_MONITOR_DEFAULT_HIGH_TIMEOUT 10	/* second */
 #define ADV_MONITOR_UNSET_SAMPLING_PERIOD 256	/* 100 ms */
 #define ADV_MONITOR_MAX_SAMPLING_PERIOD	255	/* 100 ms */
-#define ADV_MONITOR_DEFAULT_SAMPLING_PERIOD 0	/* 100 ms */
 
 struct btd_adv_monitor_manager {
 	struct btd_adapter *adapter;
@@ -831,7 +831,7 @@  static bool parse_rssi_and_timeout(struct adv_monitor *monitor,
 		h_rssi_timeout = ADV_MONITOR_DEFAULT_HIGH_TIMEOUT;
 
 	if (sampling_period == ADV_MONITOR_UNSET_SAMPLING_PERIOD)
-		sampling_period = ADV_MONITOR_DEFAULT_SAMPLING_PERIOD;
+		sampling_period = btd_opts.advmon.rssi_sampling_period;
 
 	if (h_rssi < ADV_MONITOR_MIN_RSSI || h_rssi > ADV_MONITOR_MAX_RSSI ||
 		l_rssi < ADV_MONITOR_MIN_RSSI ||
diff --git a/src/btd.h b/src/btd.h
index a3247e4fd80a..1c9e9b2eff1f 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -89,6 +89,10 @@  struct btd_avdtp_opts {
 	uint8_t  stream_mode;
 };
 
+struct btd_advmon_opts {
+	uint8_t		rssi_sampling_period;
+};
+
 struct btd_opts {
 	char		*name;
 	uint32_t	class;
@@ -122,6 +126,8 @@  struct btd_opts {
 	uint8_t		key_size;
 
 	enum jw_repairing_t jw_repairing;
+
+	struct btd_advmon_opts	advmon;
 };
 
 extern struct btd_opts btd_opts;
diff --git a/src/main.c b/src/main.c
index c32bda7d407d..617975d25cb1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -145,6 +145,11 @@  static const char *avdtp_options[] = {
 	NULL
 };
 
+static const char *advmon_options[] = {
+	"RSSISamplingPeriod",
+	NULL
+};
+
 static const struct group_table {
 	const char *name;
 	const char **options;
@@ -155,6 +160,7 @@  static const struct group_table {
 	{ "Policy",	policy_options },
 	{ "GATT",	gatt_options },
 	{ "AVDTP",	avdtp_options },
+	{ "AdvMon",	advmon_options },
 	{ }
 };
 
@@ -793,6 +799,18 @@  static void parse_config(GKeyFile *config)
 		}
 	}
 
+	val = g_key_file_get_integer(config, "AdvMon", "RSSISamplingPeriod",
+									&err);
+	if (err) {
+		DBG("%s", err->message);
+		g_clear_error(&err);
+	} else {
+		val = MIN(val, 0xFF);
+		val = MAX(val, 0);
+		DBG("RSSISamplingPeriod=%d", val);
+		btd_opts.advmon.rssi_sampling_period = val;
+	}
+
 	parse_br_config(config);
 	parse_le_config(config);
 }
@@ -832,6 +850,8 @@  static void init_defaults(void)
 
 	btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC;
 	btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC;
+
+	btd_opts.advmon.rssi_sampling_period = 0;
 }
 
 static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
diff --git a/src/main.conf b/src/main.conf
index f47cab46dc10..9ad8895bd700 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -244,3 +244,9 @@ 
 # The value is in seconds.
 # Default: 2
 #ResumeDelay = 2
+
+[AdvMon]
+# Default RSSI Sampling Period. This is used when a client registers an
+# advertisement monitor and leaves the RSSISamplingPeriod unset.
+# Default: 0
+#RSSISamplingPeriod=0