diff mbox series

[BlueZ] client: Add support for scan <le/bredr>

Message ID 20220303003136.4882-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ] client: Add support for scan <le/bredr> | expand

Commit Message

Luiz Augusto von Dentz March 3, 2022, 12:31 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds support for entering the transport directly as an scan
argument rather than having to first set it scan.transport.
---
 client/main.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

Comments

Luiz Augusto von Dentz March 8, 2022, 12:53 a.m. UTC | #1
Hi,

On Wed, Mar 2, 2022 at 7:17 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=619734
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    FAIL      1.60 seconds
> GitLint                       PASS      1.09 seconds
> Prep - Setup ELL              PASS      50.66 seconds
> Build - Prep                  PASS      0.92 seconds
> Build - Configure             PASS      10.27 seconds
> Build - Make                  PASS      1761.16 seconds
> Make Check                    PASS      13.30 seconds
> Make Check w/Valgrind         PASS      532.70 seconds
> Make Distcheck                PASS      280.62 seconds
> Build w/ext ELL - Configure   PASS      10.33 seconds
> Build w/ext ELL - Make        PASS      1735.38 seconds
> Incremental Build with patchesPASS      0.00 seconds
>
> Details
> ##############################
> Test: CheckPatch - FAIL
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> Output:
> [BlueZ] client: Add support for scan <le/bredr>
> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
> #102: FILE: client/main.c:1419:
> +static const char *scan_arguments[] = {
>
> /github/workspace/src/12766921.patch total: 0 errors, 1 warnings, 61 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.
>
> /github/workspace/src/12766921.patch 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.
>
>
>
>
> ---
> Regards,
> Linux Bluetooth
>

Pushed.
diff mbox series

Patch

diff --git a/client/main.c b/client/main.c
index 719cbefe0..6bb11b1ad 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1294,6 +1294,7 @@  static struct set_discovery_filter_args {
 	dbus_bool_t discoverable;
 	bool set;
 	bool active;
+	unsigned int timeout;
 } filter = {
 	.rssi = DISTANCE_VAL_INVALID,
 	.pathloss = DISTANCE_VAL_INVALID,
@@ -1415,18 +1416,33 @@  static void set_discovery_filter(bool cleared)
 	filter.set = true;
 }
 
+static const char *scan_arguments[] = {
+	"on",
+	"off",
+	"bredr",
+	"le",
+	NULL
+};
+
 static void cmd_scan(int argc, char *argv[])
 {
 	dbus_bool_t enable;
 	const char *method;
+	const char *mode;
 
-	if (!parse_argument(argc, argv, NULL, NULL, &enable, NULL))
+	if (!parse_argument(argc, argv, scan_arguments, "Mode", &enable,
+								&mode))
 		return bt_shell_noninteractive_quit(EXIT_FAILURE);
 
 	if (check_default_ctrl() == FALSE)
 		return bt_shell_noninteractive_quit(EXIT_FAILURE);
 
 	if (enable == TRUE) {
+		if (strcmp(mode, "")) {
+			g_free(filter.transport);
+			filter.transport = g_strdup(mode);
+		}
+
 		set_discovery_filter(false);
 		method = "StartDiscovery";
 	} else
@@ -2514,6 +2530,11 @@  static char *capability_generator(const char *text, int state)
 	return argument_generator(text, state, agent_arguments);
 }
 
+static char *scan_generator(const char *text, int state)
+{
+	return argument_generator(text, state, scan_arguments);
+}
+
 static void cmd_advertise(int argc, char *argv[])
 {
 	dbus_bool_t enable;
@@ -3117,7 +3138,8 @@  static const struct bt_shell_menu main_menu = {
 				"Enable/disable advertising with given type",
 							ad_generator},
 	{ "set-alias",    "<alias>",  cmd_set_alias, "Set device alias" },
-	{ "scan",         "<on/off>", cmd_scan, "Scan for devices", NULL },
+	{ "scan",         "<on/off/bredr/le>", cmd_scan,
+				"Scan for devices", scan_generator },
 	{ "info",         "[dev]",    cmd_info, "Device information",
 							dev_generator },
 	{ "pair",         "[dev]",    cmd_pair, "Pair with device",