Message ID | 20200701131328.3835273-1-alainm@chromium.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [BlueZ,v3] profiles/scanparam: use configured scanparams when available | expand |
Hi Alain, On Wed, Jul 1, 2020 at 6:16 AM Alain Michaud <alainm@chromium.org> wrote: > > This patch updates the scan parameter service to use the configured scan > parameters when available rather than the hardcoded kernel defaults. > > Reviewed-by: Miao-Chen Chou <mcchou@chromium.org> > Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> > Reviewed-by: Manish Mandlik <mmandlik@chromium.org> > > --- > > Changes in v3: > - Addin Chromium/Gerrit reviewers > > Changes in v2: > - Fixing checkpatch comment warning. > > profiles/scanparam/scan.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c > index 9e8f57747..d72be3dff 100644 > --- a/profiles/scanparam/scan.c > +++ b/profiles/scanparam/scan.c > @@ -45,12 +45,11 @@ > #include "src/shared/gatt-db.h" > #include "src/shared/gatt-client.h" > #include "attrib/att.h" > +#include "src/hcid.h" > > #define SCAN_INTERVAL_WIN_UUID 0x2A4F > #define SCAN_REFRESH_UUID 0x2A31 > > -#define SCAN_INTERVAL 0x0060 > -#define SCAN_WINDOW 0x0030 > #define SERVER_REQUIRES_REFRESH 0x00 > > struct scan { > @@ -75,8 +74,16 @@ static void write_scan_params(struct scan *scan) > { > uint8_t value[4]; > > - put_le16(SCAN_INTERVAL, &value[0]); > - put_le16(SCAN_WINDOW, &value[2]); > + /* Unless scan parameters are configured, use the known kernel default > + * parameters > + */ > + put_le16(main_opts.default_params.le_scan_interval_autoconnect ? > + main_opts.default_params.le_scan_interval_autoconnect : > + 0x60, &value[0]); > + > + put_le16(main_opts.default_params.le_scan_win_autoconnect ? > + main_opts.default_params.le_scan_win_autoconnect : > + 0x30, &value[2]); > > bt_gatt_client_write_without_response(scan->client, scan->iwhandle, > false, value, sizeof(value)); > -- > 2.27.0.212.ge8ba1cc988-goog > Applied, thanks.
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c index 9e8f57747..d72be3dff 100644 --- a/profiles/scanparam/scan.c +++ b/profiles/scanparam/scan.c @@ -45,12 +45,11 @@ #include "src/shared/gatt-db.h" #include "src/shared/gatt-client.h" #include "attrib/att.h" +#include "src/hcid.h" #define SCAN_INTERVAL_WIN_UUID 0x2A4F #define SCAN_REFRESH_UUID 0x2A31 -#define SCAN_INTERVAL 0x0060 -#define SCAN_WINDOW 0x0030 #define SERVER_REQUIRES_REFRESH 0x00 struct scan { @@ -75,8 +74,16 @@ static void write_scan_params(struct scan *scan) { uint8_t value[4]; - put_le16(SCAN_INTERVAL, &value[0]); - put_le16(SCAN_WINDOW, &value[2]); + /* Unless scan parameters are configured, use the known kernel default + * parameters + */ + put_le16(main_opts.default_params.le_scan_interval_autoconnect ? + main_opts.default_params.le_scan_interval_autoconnect : + 0x60, &value[0]); + + put_le16(main_opts.default_params.le_scan_win_autoconnect ? + main_opts.default_params.le_scan_win_autoconnect : + 0x30, &value[2]); bt_gatt_client_write_without_response(scan->client, scan->iwhandle, false, value, sizeof(value));